[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25905: 25.1; Can't find regexp and replace in SVG files
From: |
Juri Linkov |
Subject: |
bug#25905: 25.1; Can't find regexp and replace in SVG files |
Date: |
Sat, 19 Dec 2020 22:29:14 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>> +(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)
>
> This would switch to text representation for all images, though. Is
> that what we want? Hm... perhaps?
It makes sense to do this even in binary formats when
the user wants to search the text of e.g. EXIF tags, etc.
> So that's a good solution for isearch, but I don't think we'd want that
> for search/replace. Possibly.
This is what OP wanted (unfortunately, mails to his mailbox bounce back).
But we could install the patch anyway. The only problem I noticed
that the previous patch shows isearch highlighting at wrong places
because there is a need to wrap the call to image-mode-as-text
in save-match-data (alas, global match data bites again).
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 032ebf3873..fdac7164d4 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 +785,14 @@ 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."
+ (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))
- bug#25905: 25.1; Can't find regexp and replace in SVG files, (continued)
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Lars Ingebrigtsen, 2020/12/13
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Dmitry Gutov, 2020/12/13
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/13
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Lars Ingebrigtsen, 2020/12/14
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/14
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Lars Ingebrigtsen, 2020/12/15
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/15
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/17
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/18
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Lars Ingebrigtsen, 2020/12/18
- bug#25905: 25.1; Can't find regexp and replace in SVG files,
Juri Linkov <=
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Lars Ingebrigtsen, 2020/12/23
- bug#25905: 25.1; Can't find regexp and replace in SVG files, Juri Linkov, 2020/12/23