From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#48009: 28.0.50; Support query-regexp-replace using re-builder Date: Sun, 25 Apr 2021 15:36:07 +1200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12259"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: 48009@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 25 05:37:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1laVa6-00036B-Em for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 25 Apr 2021 05:37:14 +0200 Original-Received: from localhost ([::1]:43986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laVa5-0003g4-Fw for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Apr 2021 23:37:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laVZu-0003a6-Ic for bug-gnu-emacs@gnu.org; Sat, 24 Apr 2021 23:37:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1laVZu-0008Lu-Aq for bug-gnu-emacs@gnu.org; Sat, 24 Apr 2021 23:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1laVZu-0002Pz-7k for bug-gnu-emacs@gnu.org; Sat, 24 Apr 2021 23:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Apr 2021 03:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48009 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16193217779238 (code B ref -1); Sun, 25 Apr 2021 03:37:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Apr 2021 03:36:17 +0000 Original-Received: from localhost ([127.0.0.1]:41831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laVZB-0002Ow-Id for submit@debbugs.gnu.org; Sat, 24 Apr 2021 23:36:17 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44168) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laVZ8-0002On-Km for submit@debbugs.gnu.org; Sat, 24 Apr 2021 23:36:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laVZ8-00035P-5F for bug-gnu-emacs@gnu.org; Sat, 24 Apr 2021 23:36:14 -0400 Original-Received: from smtp-4.orcon.net.nz ([60.234.4.59]:54937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laVZ5-0007mo-0h for bug-gnu-emacs@gnu.org; Sat, 24 Apr 2021 23:36:13 -0400 Original-Received: from [101.53.216.162] (port=29582 helo=[192.168.20.103]) by smtp-4.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1laVZ1-00008f-DK for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2021 15:36:08 +1200 Content-Language: en-GB X-GeoIP: NZ Received-SPF: pass client-ip=60.234.4.59; envelope-from=psainty@orcon.net.nz; helo=smtp-4.orcon.net.nz X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:204841 Archived-At: 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