GNU bug report logs -
#48009
28.0.50; Support query-regexp-replace using re-builder
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
It would be nice to be able to use `re-builder' to interactively
craft a regexp to pass to `query-replace-regexp' in a streamlined
manner.
Here's a starter, which you can call from `re-builder'.
(defun reb-query-replace-regexp ()
"Invoke `query-replace-regexp' in the target buffer."
(interactive)
(let ((from (reb-target-binding reb-regexp)))
(with-selected-window reb-target-window
(with-current-buffer reb-target-buffer
(let ((to (query-replace-read-to from "Query replace regexp" t)))
(query-replace-regexp from to))))))
(define-key reb-mode-map (kbd "C-c %") #'reb-query-replace-regexp)
(define-key reb-lisp-mode-map (kbd "C-c %") #'reb-query-replace-regexp)
A complete solution would presumably support the other
`query-replace-regexp' arguments.
I initially wondered about a command for "query-replace-regexp but
automatically using re-builder" (i.e. instead of typing M-C-%), but
I'm not sure that would be very different to just binding `re-builder'
to a key, as you'd still need a custom binding from inside re-builder
to say you were done. Perhaps such a command would automatically
close the re-builder buffer once the replacements stopped, though?
What do people think?
-Phil
In GNU Emacs 28.0.50 (build 8, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.10, Xaw3d scroll bars)
of 2021-04-18 built on shodan
Repository revision: 75c898edc3d7e06b589ce42917ae56e0c40082ac
Repository branch: feature/native-comp
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 18.04.5 LTS
This bug report was last modified 4 years and 43 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.