emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] add modification hook for inline images
@ 2010-06-01 23:10 Martin Pohlack
  0 siblings, 0 replies; only message in thread
From: Martin Pohlack @ 2010-06-01 23:10 UTC (permalink / raw)
  To: org-mode

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

Hi,

this patch adds a modification hook to remove inline-image overlays if
the underlying text is modified.  This prevents blind editing of text
behind images.

Cheers,
Martin Pohlack

[-- Attachment #2: inline-display-modification-hook.diff --]
[-- Type: text/plain, Size: 816 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 62131be..5a00236 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15565,8 +15565,17 @@ BEG and END default to the buffer boundaries."
 		(overlay-put ov 'display img)
 		(overlay-put ov 'face 'default)
 		(overlay-put ov 'org-image-overlay t)
+		(overlay-put ov 'modification-hooks
+			     (list 'org-display-inline-modification-hook))
 		(push ov org-inline-image-overlays)))))))))
 
+(defun org-display-inline-modification-hook (ov after beg end &optional len)
+  "Remove inline-display overlay if a corresponding region is modified."
+  (let ((inhibit-modification-hooks t))
+    (when (and ov after)
+      (delete ov org-inline-image-overlays)
+      (delete-overlay ov))))
+
 (defun org-remove-inline-images ()
   "Remove inline display of images."
   (interactive)

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-01 23:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01 23:10 [PATCH] add modification hook for inline images Martin Pohlack

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).