unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: 48009@debbugs.gnu.org
Subject: bug#48009: 28.0.50; Support query-regexp-replace using re-builder
Date: Sun, 25 Apr 2021 15:36:07 +1200	[thread overview]
Message-ID: <d285a7fb-f7bd-545f-1d1b-7ed4f9abb461@orcon.net.nz> (raw)

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






             reply	other threads:[~2021-04-25  3:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25  3:36 Phil Sainty [this message]
2021-04-25 10:46 ` bug#48009: 28.0.50; Support query-regexp-replace using re-builder Stefan Kangas
2021-04-25 14:51   ` Phil Sainty
2021-04-25 15:19     ` Stefan Kangas
2021-04-26 23:53 ` Tak Kunihiro
2021-05-03  3:42 ` Karthik Chikmagalur

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=d285a7fb-f7bd-545f-1d1b-7ed4f9abb461@orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=48009@debbugs.gnu.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).