From: Jens Lechtenboerger <lechten@wi.uni-muenster.de>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Eli Zaretskii <eliz@gnu.org>, <emacs-orgmode@gnu.org>
Subject: Proposal: Change publication timestamps (was: Publishing cache)
Date: Mon, 12 Aug 2024 09:55:55 +0200 [thread overview]
Message-ID: <87bk1yxjhw.fsf_-_@wi.uni-muenster.de> (raw)
In-Reply-To: <87a5jnk347.fsf@localhost> (Ihor Radchenko's message of "Fri, 14 Jun 2024 14:31:20 +0000")
[-- Attachment #1.1: Type: text/plain, Size: 1879 bytes --]
On 2024-06-14, Ihor Radchenko wrote:
> Jens Lechtenboerger <lechten@wi.uni-muenster.de> writes:
>
>> Jumping in here, I do not understand the publishing cache. Some of
>> my org documents are re-published every time, while others are only
>> re-published after changes. What is checked where?
>
> See "14.4 Triggering Publication" section of Org mode manual:
>
> Org uses timestamps to track when a file has changed. The above
> functions normally only publish changed files. You can override this
> [...]
I propose to change caching and checking of timestamps as in the
attached path.
Currently, org-publish-cache-file-needs-publishing checks whether
the source file was modified after the cached modification time,
which is fine. However, for each included file B, it checks whether
that was modified more recently than the source file A. If so, the
source is file A is considered to need publishing. This does not
make sense. File A will be published again and again, even if
neither A nor B changed since the last publishing.
In the patch, I store the current time in the publish cache, not the
source file’s modification time. Also, for included files, I do not
check their timestamp against the one of the source file but against
the cached publish timestamp.
What do you think?
As an aside, recursive inclusions are currently not checked.
Maybe code to collect all included files is available elsewhere in
the code base?
Also, in my case, it would be useful to have a new keyword like
“#+PUBLISH_DEPENDENCY: some-file” to record timestamps for
additional dependencies, whose changes should also trigger
publishing. Currently, that could be added as alternative to the
regexp for INCLUDE. However, maybe you prefer to refactor that
code to deal with recursive inclusions?
Best wishes,
Jens
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-lisp-ox-publish.el-Use-publish-time-in-publish-cache.patch --]
[-- Type: text/x-diff, Size: 2493 bytes --]
From 5f1c5d4e56afd91db85884df6018960f3639230b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20Lechtenb=C3=B6rger?= <lechten@wi.uni-muenster.de>
Date: Mon, 12 Aug 2024 09:40:13 +0200
Subject: [PATCH] lisp/ox-publish.el: Use publish time in publish cache
* lisp/ox-publish.el (org-publish-update-timestamp): Store current
time in publish cache, instead of modification time of source file.
(org-publish-cache-file-needs-publishing): Return t, if source or an
included file was modified more recently.
Previously, a source file including a newer file was published again
and again. Now, publishing only happens if either source or an
included file changed since the last publishing.
---
lisp/ox-publish.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 9f943cedc..e26e2ca37 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -389,7 +389,7 @@ still decide about that independently."
"Update publishing timestamp for file FILENAME.
If there is no timestamp, create one."
(let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
- (stamp (org-publish-cache-mtime-of-src filename)))
+ (stamp (current-time)))
(org-publish-cache-set key stamp)))
(defun org-publish-remove-all-timestamps ()
@@ -1286,9 +1286,10 @@ If FREE-CACHE, empty the cache."
(defun org-publish-cache-file-needs-publishing
(filename &optional pub-dir pub-func _base-dir)
"Check the timestamp of the last publishing of FILENAME.
-Return non-nil if the file needs publishing. Also check if
-any included files have been more recently published, so that
-the file including them will be republished as well."
+Return non-nil if the file needs publishing. This is the case
+if either FILENAME does not occur in the publication cache or
+if FILENAME, or any file included by it, was modified after the
+most recent publication."
(unless org-publish-cache
(error
"`org-publish-cache-file-needs-publishing' called, but no cache present"))
@@ -1322,7 +1323,7 @@ the file including them will be republished as well."
(or (null pstamp)
(let ((mtime (org-publish-cache-mtime-of-src filename)))
(or (time-less-p pstamp mtime)
- (cl-some (lambda (ct) (time-less-p mtime ct))
+ (cl-some (lambda (ct) (time-less-p pstamp ct))
included-files-mtime))))))
(defun org-publish-cache-set-file-property
--
2.25.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6187 bytes --]
next prev parent reply other threads:[~2024-08-12 7:57 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 9:38 Please document the caching and its user options Eli Zaretskii
2024-06-14 13:12 ` Ihor Radchenko
2024-06-14 13:41 ` Eli Zaretskii
2024-06-14 15:31 ` Ihor Radchenko
2024-06-14 15:56 ` Eli Zaretskii
2024-06-15 12:47 ` Ihor Radchenko
2024-06-15 13:01 ` Eli Zaretskii
2024-06-15 14:13 ` Ihor Radchenko
2024-06-15 14:37 ` Eli Zaretskii
2024-06-16 9:05 ` Ihor Radchenko
2024-06-16 10:41 ` Eli Zaretskii
2024-06-23 9:12 ` Björn Bidar
2024-06-15 13:47 ` Ihor Radchenko
2024-06-14 13:56 ` Jens Lechtenboerger
2024-06-14 14:31 ` Publishing cache (was: Please document the caching and its user options) Ihor Radchenko
2024-08-12 7:55 ` Jens Lechtenboerger [this message]
2024-08-15 18:29 ` Proposal: Change publication timestamps (was: Publishing cache) Ihor Radchenko
2024-08-25 17:00 ` Proposal: Change publication timestamps Jens Lechtenboerger
2024-09-15 12:02 ` Jens Lechtenboerger
2024-09-17 18:33 ` Ihor Radchenko
2024-06-16 5:40 ` Please document the caching and its user options Daniel Clemente
2024-06-16 12:36 ` Ihor Radchenko
2024-06-17 12:41 ` Daniel Clemente
2024-06-18 15:53 ` Ihor Radchenko
2024-06-18 16:15 ` Eli Zaretskii
2024-06-18 16:25 ` Ihor Radchenko
2024-06-18 16:33 ` Eli Zaretskii
2024-06-18 16:55 ` Ihor Radchenko
2024-06-19 9:27 ` Colin Baxter
2024-06-19 10:35 ` Ihor Radchenko
2024-06-19 13:04 ` Eli Zaretskii
2024-06-19 13:30 ` Ihor Radchenko
2024-06-19 16:07 ` Colin Baxter
2024-06-19 16:15 ` Ihor Radchenko
2024-06-18 22:06 ` Rudolf Adamkovič
2024-06-19 4:29 ` tomas
2024-06-23 11:45 ` Daniel Clemente
2024-06-24 10:36 ` Ihor Radchenko
2024-06-26 12:59 ` Daniel Clemente
2024-06-26 13:21 ` org-crypt leaking data when encryption password is not entered twice (was: Please document the caching and its user options) Ihor Radchenko
2024-06-27 8:55 ` Daniel Clemente
2024-06-27 10:15 ` org-encrypt-entries is slow (was: org-crypt leaking data when encryption password is not entered twice (was: Please document the caching and its user options)) Ihor Radchenko
2024-07-02 16:54 ` Daniel Clemente
2024-07-02 19:16 ` Ihor Radchenko
2024-07-04 10:36 ` Daniel Clemente
2024-07-06 13:02 ` Ihor Radchenko
2024-07-10 13:09 ` Daniel Clemente
2024-07-11 10:40 ` Ihor Radchenko
2024-07-15 17:00 ` Daniel Clemente
2024-07-20 14:14 ` Ihor Radchenko
2024-07-24 13:47 ` Daniel Clemente
2024-07-25 7:31 ` Ihor Radchenko
2024-07-25 14:08 ` Daniel Clemente
2024-07-25 14:15 ` Ihor Radchenko
2024-10-05 18:56 ` Daniel Clemente
2024-10-20 12:57 ` Ihor Radchenko
2024-06-27 10:34 ` org-crypt leaking data when encryption password is not entered twice (was: Please document the caching and its user options) Ihor Radchenko
2024-07-02 16:53 ` Daniel Clemente
2024-06-27 9:27 ` Please document the caching and its user options Eli Zaretskii
2024-06-27 10:11 ` Ihor Radchenko
2024-06-27 10:30 ` Eli Zaretskii
2024-06-28 12:54 ` Rudolf Adamkovič
2024-06-28 15:31 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bk1yxjhw.fsf_-_@wi.uni-muenster.de \
--to=lechten@wi.uni-muenster.de \
--cc=eliz@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).