Subject: Viewing images with image-mode changes directory time

From: Juri Linkov <[email-masked]>
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/