From: ndame via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: 52558@debbugs.gnu.org
Subject: bug#52558: Option for easier typing of regexps
Date: Sat, 18 Dec 2021 16:47:47 +0000 [thread overview]
Message-ID: <Pcc0FsT8Z6hd57CBXuRG3_5LuqSC9qES0LyDiRGQGMyhMgGJti6ZsWOxlDSBQmqUVlykTv8G_rYNLgvfs_bhNqvUC6wjtqfE2AHJdW2AMjQ=@protonmail.com> (raw)
In-Reply-To: <2af49892e35fa76d89fece4b2abc8a11@webmail.orcon.net.nz>
> You can probably implement what you want by overriding
> `read-regexp'. In principle I'd expect anything prompting
> for a regexp to be using this.
That's what I thought too at first, but turns out it's not
the right way, because then history contains the normalized
regexp, so if the user goes back in history then he doesn't
see the easy version, though the goal is that the user works
with the easy variant.
So read-regexp is not the right place, because the result of
that goes into history. The translation has to be done only
before the regexp is used.
In case of query-replace-regexp it can be done before
perform-replace. Here's a solution with advice:
(defun my-perform-replace (origfun &rest args)
(apply
origfun
(if (fourth args) ;; do conversion only for regexp replace
(cons (let ((s (car args))
(chars '("|" "(" ")"))
(placeholder (format "@placeholder%s@"
(int-to-string
(buffer-modified-tick)))))
(dolist (char chars)
(setq s (replace-regexp-in-string
placeholder char
(replace-regexp-in-string
char (concat "\\\\" char)
(replace-regexp-in-string
(concat "\\\\" char) placeholder
s)))))
s)
(cdr args))
args)))
(advice-add 'perform-replace :around 'my-perform-replace)
next prev parent reply other threads:[~2021-12-18 16:47 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 17:41 bug#52558: Option for easier typing of regexps ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-17 10:07 ` Phil Sainty
2021-12-18 16:47 ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-12-18 4:41 ` Richard Stallman
2021-12-19 11:56 ` Lars Ingebrigtsen
2021-12-19 13:03 ` Phil Sainty
2021-12-19 14:08 ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-19 16:11 ` Phil Sainty
2021-12-19 15:10 ` Michael Heerdegen
2021-12-20 4:43 ` Richard Stallman
2021-12-20 19:46 ` Jim Porter
2021-12-22 4:16 ` Richard Stallman
2021-12-19 17:01 ` Juri Linkov
2021-12-19 17:39 ` ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-19 17:52 ` Juri Linkov
2021-12-19 17:57 ` Juri Linkov
2021-12-19 18:38 ` Juri Linkov
2021-12-19 18:48 ` Juri Linkov
2021-12-28 19:15 ` Juri Linkov
2021-12-28 20:21 ` Eli Zaretskii
2021-12-28 20:25 ` Juri Linkov
2021-12-28 20:35 ` Eli Zaretskii
2021-12-28 20:51 ` Juri Linkov
2021-12-29 12:32 ` Eli Zaretskii
2021-12-29 17:17 ` Juri Linkov
2021-12-29 18:25 ` Eli Zaretskii
2022-01-22 14:23 ` Lars Ingebrigtsen
2022-01-22 19:01 ` Juri Linkov
2022-01-23 12:36 ` Lars Ingebrigtsen
2022-01-23 18:09 ` Juri Linkov
2022-01-23 18:29 ` Lars Ingebrigtsen
2022-01-24 18:46 ` 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='Pcc0FsT8Z6hd57CBXuRG3_5LuqSC9qES0LyDiRGQGMyhMgGJti6ZsWOxlDSBQmqUVlykTv8G_rYNLgvfs_bhNqvUC6wjtqfE2AHJdW2AMjQ=@protonmail.com' \
--to=bug-gnu-emacs@gnu.org \
--cc=52558@debbugs.gnu.org \
--cc=laszlomail@protonmail.com \
--cc=psainty@orcon.net.nz \
/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.