GNU bug report logs - #2295
Viewing images with image-mode changes directory time

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Wed, 11 Feb 2009 23:25:04 UTC

Severity: normal

Tags: patch, pending

Merged with 10602

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2295 in the body.
You can then email your comments to 2295 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2295; Package emacs. (Wed, 11 Feb 2009 23:25:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Feb 2009 23:25:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: emacs-pretest-bug <at> gnu.org
Subject: Viewing images with image-mode changes directory time
Date: Thu, 12 Feb 2009 00:55:48 +0200
Using image-mode to visit image files touches directory modification
dates.  This is especially annoying when image files are in an old
archive.  The problem is in the function `add-text-properties' that
temporarily modifies the image buffer causing lock-file to create a lock
file in the current directory that modifies the directory timestamp.

As a solution I propose to let-bind `buffer-file-truename' to nil
around the call to `add-text-properties' to prevent directory time
modification:

Index: lisp/image-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/image-mode.el,v
retrieving revision 1.55
diff -c -r1.55 image-mode.el
*** lisp/image-mode.el	7 Feb 2009 15:29:14 -0000	1.55
--- lisp/image-mode.el	11 Feb 2009 22:52:35 -0000
***************
*** 457,464 ****
  	   (buffer-undo-list t)
  	   (modified (buffer-modified-p)))
        (image-refresh image)
!       (add-text-properties (point-min) (point-max) props)
!       (set-buffer-modified-p modified)
        ;; Inhibit the cursor when the buffer contains only an image,
        ;; because cursors look very strange on top of images.
        (setq cursor-type nil)
--- 457,465 ----
  	   (buffer-undo-list t)
  	   (modified (buffer-modified-p)))
        (image-refresh image)
!       (let ((buffer-file-truename nil)) ; avoid changing dir mtime by lock_file
!         (add-text-properties (point-min) (point-max) props)
!         (set-buffer-modified-p modified))
        ;; Inhibit the cursor when the buffer contains only an image,
        ;; because cursors look very strange on top of images.
        (setq cursor-type nil)

-- 
Juri Linkov
http://www.jurta.org/emacs/




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2295; Package emacs. (Thu, 12 Feb 2009 02:50:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Feb 2009 02:50:03 GMT) Full text and rfc822 format available.

Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 2295 <at> debbugs.gnu.org, emacs-pretest-bug <at> gnu.org
Subject: Re: bug#2295: Viewing images with image-mode changes directory time
Date: Wed, 11 Feb 2009 21:40:54 -0500
> As a solution I propose to let-bind `buffer-file-truename' to nil
> around the call to `add-text-properties' to prevent directory time
> modification:

That sounds OK.  We should provide at least a macro for that.
BTW, while you're there, change set-buffer-modified-p to
restore-buffer-modified-p.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2295; Package emacs. (Thu, 12 Feb 2009 02:50:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Feb 2009 02:50:04 GMT) Full text and rfc822 format available.

Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Thu, 12 Feb 2009 22:00:03 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> jurta.org>:
bug acknowledged by developer. (Thu, 12 Feb 2009 22:00:04 GMT) Full text and rfc822 format available.

Message #20 received at 2295-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 2295-done <at> debbugs.gnu.org
Subject: Re: bug#2295: Viewing images with image-mode changes directory time
Date: Thu, 12 Feb 2009 23:49:52 +0200
>> As a solution I propose to let-bind `buffer-file-truename' to nil
>> around the call to `add-text-properties' to prevent directory time
>> modification:
>
> That sounds OK.  We should provide at least a macro for that.

Maybe it would be better (after the release) to improve
`add-text-properties' to not modify the current buffer
(with a new flag to keep the default behavior unchanged).
This is an old problem with buffers that don't save text properties,
so modifying them is meaningless and sometimes harmful.

> BTW, while you're there, change set-buffer-modified-p to
> restore-buffer-modified-p.

Done.

-- 
Juri Linkov
http://www.jurta.org/emacs/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Fri, 13 Mar 2009 14:24:06 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Fri, 28 Sep 2012 16:54:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2295; Package emacs. (Fri, 28 Sep 2012 17:06:02 GMT) Full text and rfc822 format available.

Message #27 received at 2295 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 2295 <at> debbugs.gnu.org
Subject: Re: bug#2295: Viewing archives with arc-mode changes directory time
Date: Fri, 28 Sep 2012 19:59:19 +0300
>> Using image-mode to visit image files touches directory modification
>> dates.  This is especially annoying when image files are in an old
>> archive.  The problem is in the function `add-text-properties' that
>> temporarily modifies the image buffer causing lock-file to create a lock
>> file in the current directory that modifies the directory timestamp.
>>
>> As a solution I propose to let-bind `buffer-file-truename' to nil
>> around the call to `add-text-properties' to prevent directory time
>> modification:
>
> That sounds OK.  We should provide at least a macro for that.

I don't know how this macro could look, but there is exactly the same
problem in arc-mode and tar-mode.el.  Visiting an archive file modifies
the mtime of its directory.  This can be fixed with the same method
as used to fix image-mode (by binding buffer-file-truename to nil):

=== modified file 'lisp/arc-mode.el'
--- lisp/arc-mode.el	2012-05-04 06:13:18 +0000
+++ lisp/arc-mode.el	2012-09-28 16:51:56 +0000
@@ -787,7 +789,8 @@ (defun archive-summarize (&optional shut
 Optional argument SHUT-UP, if non-nil, means don't print messages
 when parsing the archive."
   (widen)
-  (let ((inhibit-read-only t))
+  (let ((buffer-file-truename nil) ; avoid changing dir mtime by lock_file
+	(inhibit-read-only t))
     (setq archive-proper-file-start (copy-marker (point-min) t))
     (set (make-local-variable 'change-major-mode-hook) 'archive-desummarize)
     (or shut-up

=== modified file 'lisp/tar-mode.el'
--- lisp/tar-mode.el	2012-08-13 10:34:25 +0000
+++ lisp/tar-mode.el	2012-08-20 01:25:16 +0000
@@ -518,12 +518,13 @@ (defun tar-summarize-buffer ()
         (progress-reporter-done progress-reporter)
       (message "Warning: premature EOF parsing tar file"))
     (goto-char (point-min))
-    (let ((inhibit-read-only t)
+    (let ((buffer-file-truename nil) ; avoid changing dir mtime by lock_file
+	  (inhibit-read-only t)
           (total-summaries
            (mapconcat 'tar-header-block-summarize tar-parse-info "\n")))
-      (insert total-summaries "\n"))
+      (insert total-summaries "\n")
     (goto-char (point-min))
-    (restore-buffer-modified-p modified)))
+      (restore-buffer-modified-p modified))))
 
 (defvar tar-mode-map
   (let ((map (make-keymap)))





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 27 Oct 2012 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Tue, 09 Dec 2014 01:15:02 GMT) Full text and rfc822 format available.

Forcibly Merged 2295 10602. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Tue, 09 Dec 2014 01:15:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 06 Jan 2015 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.