bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#5669: 23.1.50; auto-revert and image mode doesnt cooperate


From: Juri Linkov
Subject: bug#5669: 23.1.50; auto-revert and image mode doesnt cooperate
Date: Tue, 02 Mar 2010 23:21:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.93 (x86_64-pc-linux-gnu)

> It seems auto-revert mode and image mode doesnt cooperate, at least for
> me.
>
> To reproduce:
> - create a jpeg image with gimp or something
> - open the same image with emacs
> - enable auto-revert for the image
> - save a changed image with gimp
>
> the buffer shows corruption, the images textual and visual
> representation is mixed.

The patch below should fix this.  As you can see, it has to call
`(clear-image-cache)' to update the display.  It seems `image-refresh'
in `image-toggle-display-image' is supposed to do this, but doesn't do.
I don't know if `image-refresh' was designed that way or not?

=== modified file 'lisp/image-mode.el'
--- lisp/image-mode.el  2010-02-09 19:22:31 +0000
+++ lisp/image-mode.el  2010-03-02 21:19:38 +0000
@@ -355,6 +355,7 @@ (defun image-mode ()
        (image-mode-setup-winprops)
 
        (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
+       (add-hook 'after-revert-hook 'image-after-revert-hook nil t)
        (run-mode-hooks 'image-mode-hook)
        (message "%s" (concat
                       (substitute-command-keys
@@ -501,6 +502,15 @@ (defun image-toggle-display ()
   (if (image-get-display-property)
       (image-mode-as-text)
     (image-mode)))
+
+(defun image-after-revert-hook ()
+  (when (image-get-display-property)
+    (image-toggle-display-text)
+    ;; FIXME: `image-refresh' in `image-toggle-display-image' currently
+    ;; doesn't update image display.  Force this by clearing the image cache.
+    (clear-image-cache)
+    (image-toggle-display-image)))
+
 
 ;;; Support for bookmark.el
 (declare-function bookmark-make-record-default "bookmark"

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






reply via email to

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