emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] org-macs.el: Do not compare wall time and file modification


From: Max Nikulin
Subject: Re: [PATCH] org-macs.el: Do not compare wall time and file modification time
Date: Thu, 12 May 2022 23:55:38 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

On 11/05/2022 23:24, Paul Eggert wrote:
The comments don't seem to match the code here.

+  (let* ((tangled-file (concat (file-name-sans-extension file) ".el"))
+         (file-mtime (file-attribute-modification-time
+                      (file-attributes (file-truename file))))
+         (tangled-mtime (file-attribute-modification-time
+                         (file-attributes (file-truename tangled-file)))))
+    ;; Tangle only if the Elisp file is older than the Org file.
+    ;; Filesystem may have coarse timestamp resolution (HFS+, FAT)
+    ;; so no need to update if timestamps are equal and thus
+    ;; `org-file-newer-than-p' can not be used here.
+    (unless (and file-mtime
+                 tangled-mtime
+                 (not (time-less-p tangled-mtime file-mtime)))

Although this looks correct, there's no need to go to the work of computing file-mtime in the common case where tangled-mtime is nil.

Thank you, I missed such case. I discovered that the code below recompiles an .el file even the .elc one is newer, moreover loading of compiled file is broken by another modernization of emacs code (see the dedicated thread). That is why I did not bother if the code may be optimized a bit.

Finally I have found `file-newer-than-file-p' that looks suitable for such case.

Attachment: 0001-org-macs.el-Do-not-compare-wall-time-and-file-modifi.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]