emacs-diffs
[Top][All Lists]
Advanced

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

master 268a3d3: Show image as text when trying to search/replace in imag


From: Juri Linkov
Subject: master 268a3d3: Show image as text when trying to search/replace in image buffer (bug#25905)
Date: Wed, 23 Dec 2020 04:30:19 -0500 (EST)

branch: master
commit 268a3d32fb5a26c09787627d12a4dfc61ba059ff
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    Show image as text when trying to search/replace in image buffer (bug#25905)
    
    * lisp/image-mode.el (image-mode-isearch-filter): New function.
    (image-mode--setup-mode): Use it to add it as :before-while to
    isearch-filter-predicate.
---
 lisp/image-mode.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 465bf86..143b68f 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -667,6 +667,9 @@ Key bindings:
   (when image-auto-resize-on-window-resize
     (add-hook 'window-state-change-functions #'image--window-state-change nil 
t))
 
+  (add-function :before-while (local 'isearch-filter-predicate)
+                #'image-mode-isearch-filter)
+
   (run-mode-hooks 'image-mode-hook)
   (let ((image (image-get-display-property))
        (msg1 (substitute-command-keys
@@ -782,6 +785,14 @@ Remove text properties that display the image."
     (if (called-interactively-p 'any)
        (message "Repeat this command to go back to displaying the image"))))
 
+(defun image-mode-isearch-filter (_beg _end)
+  "Show image as text when trying to search/replace in the image buffer."
+  (save-match-data
+    (when (and (derived-mode-p 'image-mode)
+               (image-get-display-property))
+      (image-mode-as-text)))
+  t)
+
 (defvar archive-superior-buffer)
 (defvar tar-superior-buffer)
 (declare-function image-flush "image.c" (spec &optional frame))



reply via email to

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