GNU bug report logs - #25905
25.1; Can't find regexp and replace in SVG files

Previous Next

Package: emacs;

Reported by: Matthias Meulien <matthias.meulien <at> delair-tech.com>

Date: Wed, 1 Mar 2017 00:25:01 UTC

Severity: minor

Tags: fixed

Found in version 25.1

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 25905 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: bug#25905: 25.1; Can't find regexp and replace in SVG files
Date: Fri, 18 Dec 2020 10:46:38 +0200
[Message part 1 (text/plain, inline)]
>>>> There is also the dired-do-isearch command that searches in marked files.
>>>>
>>>> OTOH, when such "making text visible to search" would be implemented
>>>> for isearch, then it will be used automatically by query-replace that
>>>> relies on the same search functions.
>>>
>>> That's true...
>>>
>>> So we basically need some new functionality for switching to text mode
>>> in image buffers when we're doing searches?
>>
>> Maybe isearch-open-necessary-overlays should detect if there is an image
>> over point, then switch the buffer to text mode.
>
> Here is one possible fix, but I'm still unsure if using image functions
> in isearch is a good style.  Perhaps a better fix would be to add this
> code to a buffer-local isearch-mode-hook in image-mode.el that runs
> when isearch starts.

Here is a more correct implementation:

[image-mode-isearch-filter.patch (text/x-diff, inline)]
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 032ebf3873..87a8dc9ef2 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -667,6 +667,9 @@ image-mode--setup-mode
   (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 +790,13 @@ image-toggle-display-text
     (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 in the image buffer."
+  (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))

This bug report was last modified 4 years and 211 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.