emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100540: * lisp/iimage.el: Remove ima


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100540: * lisp/iimage.el: Remove images as soon as the underlying text is modified.
Date: Mon, 07 Jun 2010 17:01:23 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100540
author: Martin Pohlack <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2010-06-07 17:01:23 -0400
message:
  * lisp/iimage.el: Remove images as soon as the underlying text is modified.
  (iimage-modification-hook): New function.
  (iimage-mode-buffer): Use it.
modified:
  lisp/ChangeLog
  lisp/ChangeLog.13
  lisp/iimage.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-06-07 19:37:50 +0000
+++ b/lisp/ChangeLog    2010-06-07 21:01:23 +0000
@@ -1,3 +1,9 @@
+2010-06-07  Martin Pohlack  <address@hidden>
+
+       * 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  <address@hidden>
 
        * emacs-lisp/smie.el (smie-indent-offset-rule): Rename from
@@ -4691,8 +4697,8 @@
 
 2009-12-10  Vinicius Jose Latorre  <address@hidden>
 
-       * 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 <address@hidden>.
        New version 12.1.
 

=== modified file 'lisp/ChangeLog.13'
--- a/lisp/ChangeLog.13 2010-05-11 02:04:13 +0000
+++ b/lisp/ChangeLog.13 2010-06-07 21:01:23 +0000
@@ -7161,7 +7161,7 @@
        * doc-view.el (doc-view-search-backward, doc-view-search):
        Fix assignment to free variable bug.
 
-2007-11-16  Martin Pohlack  <address@hidden>  (tiny change)
+2007-11-16  Martin Pohlack  <address@hidden>
 
        * emulation/pc-select.el (pc-select-shifted-mark): New var.
        (ensure-mark): Set it.

=== modified file 'lisp/iimage.el'
--- a/lisp/iimage.el    2010-05-11 18:51:27 +0000
+++ b/lisp/iimage.el    2010-06-07 21:01:23 +0000
@@ -101,6 +101,19 @@
   (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 @@
         (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


reply via email to

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