--- Begin Message ---
Subject: |
Visiting files from zip archives should not modify directory time |
Date: |
Mon, 22 Jan 2018 23:52:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
Visiting a file from zip archive changes the modification time of
its directory. It's possible to prevent directory time modification
by setting ‘buffer-file-truename’ later after the extractor prepares
the file in its buffer:
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index adb3669..d6add45 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -1045,8 +1045,6 @@ archive-extract
(setq just-created t)
(with-current-buffer buffer
(setq buffer-file-name arcfilename)
- (setq buffer-file-truename
- (abbreviate-file-name buffer-file-name))
;; Set the default-directory to the dir of the superior buffer.
(setq default-directory arcdir)
(make-local-variable 'archive-superior-buffer)
@@ -1077,6 +1075,9 @@ archive-extract
(progn
(set-buffer-modified-p nil)
(kill-buffer buffer))
+ ;; Set this later to avoid changing dir mtime by lock_file
+ (setq buffer-file-truename
+ (abbreviate-file-name buffer-file-name))
(archive-try-jka-compr) ;Pretty ugly hack :-(
(archive-set-buffer-as-visiting-file ename)
(goto-char (point-min))
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#30215: Visiting files from zip archives should not modify directory time |
Date: |
Thu, 25 Jan 2018 23:41:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>> > If that's the problem, then I think it would be cleaner to disable
>> > creation of lock files and backup files by less subtle means -- by
>> > let-binding create-lockfiles and make-backup-files. Doing that by
>> > leaving buffer-file-truename at nil leaves the code less clear IMO,
>> > and relies on assumptions that might not hold at some future point.
>>
>> Thanks for the suggestion, this is better indeed:
>>
>> diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
>> index adb3669..4fe1b03 100644
>> --- a/lisp/arc-mode.el
>> +++ b/lisp/arc-mode.el
>> @@ -807,7 +807,7 @@ archive-summarize
>> Optional argument SHUT-UP, if non-nil, means don't print messages
>> when parsing the archive."
>> (widen)
>> - (let ((buffer-file-truename nil) ; avoid changing dir mtime by lock_file
>> + (let ((create-lockfiles nil) ; avoid changing dir mtime by lock_file
>
> This LGTM,
Installed.
> but wasn't the problem also with creation of a backup file?
Creation of a backup file is not a problem, because backups are created
on saving. Visiting a file from a zip archive doesn't save it, and
thus doesn't create a backup. But when the user explicitly saves
a file inside a zip archive, only then it should modify the time
of its directory.
--- End Message ---