all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 25905@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#25905: 25.1; Can't find regexp and replace in SVG files
Date: Sat, 19 Dec 2020 22:29:14 +0200	[thread overview]
Message-ID: <877dpdmtet.fsf@mail.linkov.net> (raw)
In-Reply-To: <87czz7jusw.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 18 Dec 2020 11:02:55 +0100")

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

>> +(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).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: image-mode-isearch-filter.patch --]
[-- Type: text/x-diff, Size: 1091 bytes --]

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))

  reply	other threads:[~2020-12-19 20:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01  0:20 bug#25905: 25.1; Can't find regexp and replace in SVG files Matthias Meulien
2020-12-12 19:56 ` Lars Ingebrigtsen
2020-12-12 20:24   ` Juri Linkov
2020-12-13 12:35     ` Lars Ingebrigtsen
2020-12-12 21:29   ` Dmitry Gutov
2020-12-13 12:42     ` Lars Ingebrigtsen
2020-12-13 18:39       ` Dmitry Gutov
2020-12-13 20:02       ` Juri Linkov
2020-12-14 16:21         ` Lars Ingebrigtsen
2020-12-14 19:55           ` Juri Linkov
2020-12-15  6:34             ` Lars Ingebrigtsen
2020-12-15 20:42               ` Juri Linkov
2020-12-17 22:03                 ` Juri Linkov
2020-12-18  8:46                   ` Juri Linkov
2020-12-18 10:02                     ` Lars Ingebrigtsen
2020-12-19 20:29                       ` Juri Linkov [this message]
2020-12-23  7:13                         ` Lars Ingebrigtsen
2020-12-23  9:30                           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877dpdmtet.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=25905@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.