Subject: bug#25905: 25.1; Can't find regexp and replace in SVG files

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 13 Dec 2020 13:42:29 +0100

Dmitry Gutov <[email-masked]> writes:

> On 12.12.2020 21:56, Lars Ingebrigtsen wrote:
>> But I wonder whether this problem should nevertheless have a general
>> solution.  That is, should this command have a variation that works on
>> literal files instead?  Perhaps a prefix of `C-u' to make the query
>> replace use find-file-literally?
>
> Perhaps there could be a whitelist of such modes instead, with
> commands that can be used to switch buffer contents to "replacable"
> form?
>
> At least in this particular example, it's hard for me to imagine users
> *not* wanting the replacements work by default. So it makes sense as
> the default behavior.

That's true.  There's probably not a lot of these formats -- svg,
xpm...  uhm...  the pnm formats, possibly?  that are "text-like" enough
that people would want to perform search-replaces on them, so writing a
whitelist would probably not be a big job.

So this command would use that whitelist to bind those formats to
fundamental-mode?  Or it could be on auto-mode-alist form:

(defvar query-replace-overriding-mode-alist
  '(("\\.svgz?\\'" . image-mode-as-text)
    ("\\.x[bp]m\\'" . image-mode-as-text)
    ("\\.p[bpgn]m\\'" . image-mode-as-text)))

That would make this trivial to implement.  Comments?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no