]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/iimage.el: Remove images as soon as the underlying text is modified.
authorMartin Pohlack <mp26@os.inf.tu-dresden.de>
Mon, 7 Jun 2010 21:01:23 +0000 (17:01 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 7 Jun 2010 21:01:23 +0000 (17:01 -0400)
(iimage-modification-hook): New function.
(iimage-mode-buffer): Use it.

lisp/ChangeLog
lisp/ChangeLog.13
lisp/iimage.el

index fd2f42c7b00e53ea80eeef8acb5214f046c8c363..2f324e5ee0435cc69ec23c281c3ff0637991b0e4 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-07  Martin Pohlack  <mp26@os.inf.tu-dresden.de>
+
+       * iimage.el: Remove images as soon as the underlying text is modified.
+       (iimage-modification-hook): New function.
+       (iimage-mode-buffer): Use it.
+
 2010-06-07  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/smie.el (smie-indent-offset-rule): Rename from
 
 2009-12-10  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
-       * whitespace.el (whitespace-display-char-on): Ensure
-       `buffer-display-table' is unique when two or more windows are
+       * whitespace.el (whitespace-display-char-on):
+       Ensure `buffer-display-table' is unique when two or more windows are
        visible.  Reported by Martin Pohlack <mp26@os.inf.tu-dresden.de>.
        New version 12.1.
 
index d219c7a56602686aadf6dda7b2cc38fd96461fba..da88e3334c233be55b296c464b3f822845e90df7 100644 (file)
        * doc-view.el (doc-view-search-backward, doc-view-search):
        Fix assignment to free variable bug.
 
-2007-11-16  Martin Pohlack  <mp26@os.inf.tu-dresden.de>  (tiny change)
+2007-11-16  Martin Pohlack  <mp26@os.inf.tu-dresden.de>
 
        * emulation/pc-select.el (pc-select-shifted-mark): New var.
        (ensure-mark): Set it.
index 87591724dbbdb7ade982a465b532764f8c8a6466..1c9b092738b2d3cfb1d4c4dd6f5509b821aa181c 100644 (file)
@@ -101,6 +101,19 @@ Examples of image filename regexps:
   (interactive)
   (iimage-mode 0))
 
+(defun iimage-modification-hook (beg end)
+  "Remove display property if a display region is modified."
+  ;;(debug-print "ii1 begin %d, end %d\n" beg end)
+  (let ((inhibit-modification-hooks t)
+        (beg (previous-single-property-change end 'display
+                                              nil (line-beginning-position)))
+        (end (next-single-property-change     beg 'display
+                                              nil (line-end-position))))
+    (when (and beg end (plist-get (text-properties-at beg) 'display))
+      ;;(debug-print "ii2 begin %d, end %d\n" beg end)
+      (remove-text-properties beg end
+                              '(display nil modification-hooks nil)))))
+
 (defun iimage-mode-buffer (arg)
   "Display images if ARG is non-nil, undisplay them otherwise."
   (let ((image-path (cons default-directory iimage-mode-image-search-path))
@@ -110,16 +123,18 @@ Examples of image filename regexps:
         (goto-char (point-min))
         (dolist (pair iimage-mode-image-regex-alist)
           (while (re-search-forward (car pair) nil t)
-            (if (and (setq file (match-string (cdr pair)))
-                     (setq file (locate-file file image-path)))
-                ;; FIXME: we don't mark our images, so we can't reliably
-                ;; remove them either (we may leave some of ours, and we
-                ;; may remove other packages's display properties).
-                (if arg
-                    (add-text-properties (match-beginning 0) (match-end 0)
-                                         (list 'display (create-image file)))
-                  (remove-text-properties (match-beginning 0) (match-end 0)
-                                          '(display))))))))))
+            (when (and (setq file (match-string (cdr pair)))
+                       (setq file (locate-file file image-path)))
+              ;; FIXME: we don't mark our images, so we can't reliably
+              ;; remove them either (we may leave some of ours, and we
+              ;; may remove other packages's display properties).
+              (if arg
+                  (add-text-properties (match-beginning 0) (match-end 0)
+                                       `(display ,(create-image file)
+                                         modification-hooks
+                                         (iimage-modification-hook)))
+                (remove-text-properties (match-beginning 0) (match-end 0)
+                                        '(display modification-hooks))))))))))
 
 ;;;###autoload
 (define-minor-mode iimage-mode