* bug#5980: iimage.el and modification hooks
@ 2010-04-20 7:41 Martin Pohlack
2010-06-07 21:03 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Martin Pohlack @ 2010-04-20 7:41 UTC (permalink / raw)
To: 5980
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
Hi,
I started to use iimage.el yesterday and like it. However, it still
seems possible to *blindly* modify contents inside the display blocks
which is confusing. Furthermore, if the regexp defining the block is
destroyed that way, disabling iimage-mode does not remove the display
block --- it will be stuck forever.
I therefore use a modification hook for removing the display block in
case the underlying text is modified. Please find the patch attached,
in case you like it.
Cheers,
Martin Pohlack
[-- Attachment #2: iimage_modification-hooks.diff --]
[-- Type: text/x-patch, Size: 1700 bytes --]
--- /home/mp26/src/emacs/lisp/iimage.el 2009-11-21 12:03:13.000000000 +0100
+++ iimage.el 2010-04-18 23:24:10.000000000 +0200
@@ -109,6 +109,19 @@
(defalias 'iimage-locate-file 'locate-file)
+(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/undisplay images.
With numeric ARG, display the images if and only if ARG is positive."
@@ -128,9 +141,12 @@
iimage-mode-image-search-path))))
(if ing
(add-text-properties (match-beginning 0) (match-end 0)
- (list 'display (create-image file)))
- (remove-text-properties (match-beginning 0) (match-end 0)
- '(display)))))))
+ (list 'display (create-image file)
+ 'modification-hooks
+ (list 'iimage-modification-hook)))
+ (remove-list-of-text-properties
+ (match-beginning 0) (match-end 0)
+ '(display modification-hooks)))))))
(set-buffer-modified-p modp)))
;;;###autoload
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-07 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20 7:41 bug#5980: iimage.el and modification hooks Martin Pohlack
2010-06-07 21:03 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.