From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 24 23:36:17 2021 Received: (at submit) by debbugs.gnu.org; 25 Apr 2021 03:36:17 +0000 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 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 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 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 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 To: bug-gnu-emacs@gnu.org From: Phil Sainty Subject: 28.0.50; Support query-regexp-replace using re-builder Message-ID: Date: Sun, 25 Apr 2021 15:36:07 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 25 06:46:50 2021 Received: (at 48009) by debbugs.gnu.org; 25 Apr 2021 10:46:50 +0000 Received: from localhost ([127.0.0.1]:42078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lacHq-0004nC-9B for submit@debbugs.gnu.org; Sun, 25 Apr 2021 06:46:50 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:37665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lacHh-0004mh-Qu for 48009@debbugs.gnu.org; Sun, 25 Apr 2021 06:46:42 -0400 Received: by mail-pj1-f49.google.com with SMTP id e8-20020a17090a7288b029014e51f5a6baso3537454pjg.2 for <48009@debbugs.gnu.org>; Sun, 25 Apr 2021 03:46:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc; bh=D6bA5kq3Fd/HF9rPvQ2K5c7Ez8F6evvXo8bZEMUntCE=; b=Qk7+vACuS2oXNo3r1IBIfVM8dqHUg5RP6++aVAH4kIkj4JjmNQ0tngERg2LRb4Q9s6 MjByEbNnyTKNnvOBEleYgbMXhej4hyharMSDCkS8SLyNIKlZAWgt9fUkyvC07W8z4AMK pctk4rZNEJtDFy9g+qWZKMvoFWIQ5KqR3Ml1tEyxXVa+JAk2M/608iymoZ3t0FYmNcZh yzcc6yFvRYYZT6qFKFG6D4GnS6rwm4+QKyN8JGrkhC+A89m1MVSGZpz3R0jniBhZJYta rjxH/EyRQBQTDfMtqbzRw3255lc2w+PXqC/oZ/T4aWPaHjnILbS+I3Krb9Be9si2F/gs Fw3w== X-Gm-Message-State: AOAM5308Gkj/TwKJUVg/D0O2cw6UDJQJwn+ZJJszEjXUsAJUn/1u+UOq hTBI5vExV+g6WqrJGfjS0RQAeMqF1/vWx1vafv+TwJh3 X-Google-Smtp-Source: ABdhPJxZwwYLicDeTKXg/bcWdXazYu2EqFDkNC+9STxSJPs63bKXQ3sI9Px1escz2hax5Z5S0R1zEvThIGXJWm6qrRg= X-Received: by 2002:a17:902:e9c4:b029:eb:4626:feba with SMTP id 4-20020a170902e9c4b02900eb4626febamr13491637plk.39.1619347596163; Sun, 25 Apr 2021 03:46:36 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 25 Apr 2021 05:46:35 -0500 From: Stefan Kangas In-Reply-To: (Phil Sainty's message of "Sun, 25 Apr 2021 15:36:07 +1200") References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Date: Sun, 25 Apr 2021 05:46:35 -0500 Message-ID: Subject: Re: bug#48009: 28.0.50; Support query-regexp-replace using re-builder To: Phil Sainty Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 48009 Cc: 48009@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Phil Sainty writes: > 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. I think it's a good idea. > 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? Why not make `query-replace-regexp' work exactly like isearch does, i.e. interactively update its matches? I.e. why should users need to know about `re-builder' to take advantage of this? Something like that could be added in addition to a command to go from `re-builder' to `query-replace-regexp'. From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 25 10:51:47 2021 Received: (at 48009) by debbugs.gnu.org; 25 Apr 2021 14:51:47 +0000 Received: from localhost ([127.0.0.1]:43383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lag6t-0004nr-Fb for submit@debbugs.gnu.org; Sun, 25 Apr 2021 10:51:47 -0400 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:33289) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lag6r-0004nh-5n for 48009@debbugs.gnu.org; Sun, 25 Apr 2021 10:51:45 -0400 Received: from [101.53.216.162] (port=13153 helo=[192.168.20.103]) by smtp-2.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1lag6o-0001Gw-Sd; Mon, 26 Apr 2021 02:51:43 +1200 Subject: Re: bug#48009: 28.0.50; Support query-regexp-replace using re-builder To: Stefan Kangas References: From: Phil Sainty Message-ID: Date: Mon, 26 Apr 2021 02:51:42 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-GeoIP: NZ X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 48009 Cc: 48009@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 25/04/21 10:46 pm, Stefan Kangas wrote: > Why not make `query-replace-regexp' work exactly like isearch does, > i.e. interactively update its matches? I.e. why should users need > to know about `re-builder' to take advantage of this? > > Something like that could be added in addition to a command to go > from `re-builder' to `query-replace-regexp'. That could be very nice, although it feels like a pretty significant complication. Also, re-builder's interactive updates can sometimes need a manual C-c C-u (`reb-force-update') if it gets confused (which I think occasionally happens when the regexp is invalid?), and that might not be great. Or did you mean to use the isearch highlighting code, which is perhaps more forgiving of temporary invalid states? From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 25 11:19:12 2021 Received: (at 48009) by debbugs.gnu.org; 25 Apr 2021 15:19:12 +0000 Received: from localhost ([127.0.0.1]:43395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lagXP-0005Qc-VI for submit@debbugs.gnu.org; Sun, 25 Apr 2021 11:19:12 -0400 Received: from mail-pj1-f45.google.com ([209.85.216.45]:43954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lagXO-0005QM-HI for 48009@debbugs.gnu.org; Sun, 25 Apr 2021 11:19:11 -0400 Received: by mail-pj1-f45.google.com with SMTP id f6-20020a17090a6546b029015088cf4a1eso3833014pjs.2 for <48009@debbugs.gnu.org>; Sun, 25 Apr 2021 08:19:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=dgIAgtQ7sDFcMUkmgekgreAmeGfyexwjWM8YSAjfRmk=; b=b0ICYuJn7JZStFJ7mpb+WRZliHnKmfGu7jy5vcmLRl52dGPHRlRl4u7DcKqlRIH5M/ t9VgNViu3Tfi3kX28nTKWaA2qGIUzK9H5ZfYiTyI6mYvYfn1SRmxQe4RO5czpa7rwShQ fYfxUEzBEWE00neHpyLiV70kg4lRpZyVvTu4kxLw1ej3XAeeHzI2yHvaD7sOp9MM8l0K 7hFAqc3PHhSLRPrBzNakf8pT7atUhiobUipw+3wmM2XrYjdcriVj9+4ZlI3OoODw3dSM qoia/oKcZn1no5GrGLfmrjhkBvEbd/R/ofMug2YCsqHpIQ9QZNtI5oJeMefr8OZNVFJr J6cA== X-Gm-Message-State: AOAM531TAew7oAxgKavyow8CbvX6FC+CUSR2vxH8uZU6gi2/5ILYpr9p rYFlvHvr3YZx171AfVieTUIC6CS76ImaWeXGKdA= X-Google-Smtp-Source: ABdhPJxke3K/IIxKTqJyG6N6yhvB8Fa2hW5SqZh8RqptQKKPE7fzO9By1Zxc3uNMoih15Y3D1ejXpddnzhHM6iCTjm0= X-Received: by 2002:a17:90a:670b:: with SMTP id n11mr16102451pjj.104.1619363944864; Sun, 25 Apr 2021 08:19:04 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 25 Apr 2021 10:19:04 -0500 From: Stefan Kangas In-Reply-To: References: MIME-Version: 1.0 Date: Sun, 25 Apr 2021 10:19:04 -0500 Message-ID: Subject: Re: bug#48009: 28.0.50; Support query-regexp-replace using re-builder To: Phil Sainty Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 48009 Cc: 48009@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) Phil Sainty writes: > That could be very nice, although it feels like a pretty significant > complication. Also, re-builder's interactive updates can sometimes > need a manual C-c C-u (`reb-force-update') if it gets confused (which > I think occasionally happens when the regexp is invalid?), and that > might not be great. True, it would need to be robust enough to handle most of what you throw at it. But even with some warts, it would be a significant improvement, I think. If it is optional, users run less risk of being caught unawares. A naive approach would be to run something akin to `reb-force-update' automatically after some delay, but I have no idea if that would work in practice. > Or did you mean to use the isearch highlighting code, which is perhaps > more forgiving of temporary invalid states? I'm not familiar with the code, so I can't help with ideas for how to best implement something like this, unfortunately. From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 26 19:54:04 2021 Received: (at 48009) by debbugs.gnu.org; 26 Apr 2021 23:54:04 +0000 Received: from localhost ([127.0.0.1]:47507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbB3E-0006DJ-3N for submit@debbugs.gnu.org; Mon, 26 Apr 2021 19:54:04 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:33461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbB3C-0006Cc-Cq for 48009@debbugs.gnu.org; Mon, 26 Apr 2021 19:54:02 -0400 Received: by mail-pj1-f49.google.com with SMTP id kb13-20020a17090ae7cdb02901503d67f0beso413154pjb.0 for <48009@debbugs.gnu.org>; Mon, 26 Apr 2021 16:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=cBFyfnQ3U11DwXT0cEdL7+ihmcZDtOiIOa67iaKGf9w=; b=aBSZwlvncFhZak9MJuw8vfe6YzaeXxm0O5G8Dplgwuwt2NbNRvUX996G+8VdvMpxLJ OhaZUeEWVGkFDikbic4qBERTAyzXLiYZNZ480N6Wm3PEGekr+tPPg6rUF8KQArEaWoNU jzF9BQMyb1AMYG/l0Kg3aXFcUWeTAoVekjUWAi7AQfPmNO7oRi6N6G/LnLvrAJiOCxG2 EYWknKbZU18jwCYP2tIfzijaXjey9Wxypm7iysbLdA56sMu/imENZZVVXSqhwjEEzRIr +e2M4R28n34MFyypgYxHq2GmHWoiKwW9F/SuScGUFOvDB4VbCVQle+YaS2vfeu4xxqSJ gzeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=cBFyfnQ3U11DwXT0cEdL7+ihmcZDtOiIOa67iaKGf9w=; b=NX/G1OddjiXud5dcL3dLd0/UGbmIDuN/0+gNMx6iaUZlQCQEnjCLw7YQbFYYsVaaP4 XA5785oBo4nHrxiD2lAQj0KduzFs+TS3DKrxSPfrOdZzfd/tR/qWuxR5qDopn5YvOKzk ylf/Mi+QPsWYPWF5O3upYUFTSvlBe9rkJWw23BEpHWW7NseeNqn/laclQIkayfEhI6vo dR2DsLmoBn9cKwTUllMeFJA9e839wL393DKFB9WKeKY4/FnZ4/Hv1xHnp8wkeRKdzIGp N1ule5dMKYzA9AJrlZYqk5jE8LkGrJvMcWrK2DJW8AafTFQLhpqQ3qBvbHYVp9x/uqKF gVuw== X-Gm-Message-State: AOAM533aXGC+MKW68dlFL6URxM5pnqYs5kYJdF12lz6S9T3oZC0Bmn7S vTM4Z6bXi/1Yqw9mvoEabV1+Ha9LyLc= X-Google-Smtp-Source: ABdhPJwLmnBQ3ZcnFlkdEuk/5gegwQzvn9AwK6BeJWB2E3Mk1mXsgCWiliJjulCQCXskji5BzII2XA== X-Received: by 2002:a17:902:e851:b029:eb:1fd0:fa8e with SMTP id t17-20020a170902e851b02900eb1fd0fa8emr21779788plg.38.1619481235564; Mon, 26 Apr 2021 16:53:55 -0700 (PDT) Received: from DreamMini2019.local (vesta.misasa.okayama-u.ac.jp. [150.46.48.154]) by smtp.gmail.com with ESMTPSA id w17sm659674pfq.187.2021.04.26.16.53.54 for <48009@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 16:53:55 -0700 (PDT) From: Tak Kunihiro X-Google-Original-From: Tak Kunihiro To: 48009@debbugs.gnu.org Subject: Re: bug#48009: 28.0.50; Support query-regexp-replace using re-builder References: Date: Tue, 27 Apr 2021 08:53:52 +0900 In-Reply-To: (Phil Sainty's message of "Sun, 25 Apr 2021 15:36:07 +1200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 48009 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > 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. I think it is a good idea. Also pass to isearch-forward-regexp or vr/query-replace is handy too. From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 27 10:12:28 2021 Received: (at control) by debbugs.gnu.org; 27 Apr 2021 14:12:29 +0000 Received: from localhost ([127.0.0.1]:50433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbORw-0007uC-KN for submit@debbugs.gnu.org; Tue, 27 Apr 2021 10:12:28 -0400 Received: from mail-pg1-f172.google.com ([209.85.215.172]:38664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lbORn-0007tT-L8 for control@debbugs.gnu.org; Tue, 27 Apr 2021 10:12:19 -0400 Received: by mail-pg1-f172.google.com with SMTP id w10so5004361pgh.5 for ; Tue, 27 Apr 2021 07:12:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=B77zu+wov6nHdH5SsC9ZC7H8nDMu3mveGD+lBUdS3AI=; b=XS5fKwA6weSkwOC8tcoMNrnFf5xNBKf6mL/zLvIEkWGuy9Apu40l1lgzDOA4wlAu1d XaU8LJHSiE9saVjN0s54lPyxoq3FujTL6H7zv2TJ9QgvPra3EQZrxfIjHsGaytns93ug Wm1OKOQ0o75PYN30MI9CgOEsfyIksfvsFhETgAkva8/kCaijojb7j5U8eVpsLJOS8GdM zbqcd0igBc6dJa601N3QPDSAqBRdamr1u9f1xgc4JxR3Ly/jaRIMQ1zD+ygU4kpYJR0+ ug87M9pttE7FDSGG+jbUVYjzl6hiR4sx5Q8CyjmDQZlHJRs/BR8XyZ7nk5jDoW5baZvn S1Og== X-Gm-Message-State: AOAM530xWFhHGfMAE4mA2oKeIhVptUsMCaKnyA24A9tjPd7HBcoF6fFw FonxVwcjvnAdi/dClxwfVIxlx1sTC69kqC50q8JZWXNR X-Google-Smtp-Source: ABdhPJz+pWaVXjL80buZe1AMF4oUjOkmqtjLArfnmlYydOcON0nsB1Omg4e65ggr7mFyJPXPFImu7eMXTxiqkAa2vmQ= X-Received: by 2002:a05:6a00:238c:b029:274:70be:f085 with SMTP id f12-20020a056a00238cb029027470bef085mr13729049pfc.58.1619532734122; Tue, 27 Apr 2021 07:12:14 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 27 Apr 2021 09:12:13 -0500 From: Stefan Kangas MIME-Version: 1.0 Date: Tue, 27 Apr 2021 09:12:13 -0500 Message-ID: Subject: To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: severity 48009 wishlist thanks Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.215.172 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.215.172 listed in list.dnswl.org] 2.0 BLANK_SUBJECT Subject is present but empty 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: severity 48009 wishlist thanks Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.215.172 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.215.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 2.0 BLANK_SUBJECT Subject is present but empty 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different severity 48009 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Mon May 03 01:02:57 2021 Received: (at 48009) by debbugs.gnu.org; 3 May 2021 05:02:57 +0000 Received: from localhost ([127.0.0.1]:46009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldQjQ-0007Li-HX for submit@debbugs.gnu.org; Mon, 03 May 2021 01:02:57 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:46005) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldPTn-0006fk-6V for 48009@debbugs.gnu.org; Sun, 02 May 2021 23:42:44 -0400 Received: by mail-pj1-f41.google.com with SMTP id gc22-20020a17090b3116b02901558435aec1so2543344pjb.4 for <48009@debbugs.gnu.org>; Sun, 02 May 2021 20:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=NPAkT40aeAujjzzths7lFAVGQtTsSW+wv6Fc10quSAA=; b=tBf4mteZ28Q7N2KMDpluRUwWq4sWBDne1ESQcMi58T+u1cczpdgdGBFmu2cFL0ggjw 4evxLglaLbDOkqC8m1XB8t8f0HZqmUsOp+FTPA881R7JYlQxPZxEmYTCdjOAF8lZOFEO TpkhJ3ghxxCcRz0Ym/rQRvTWVg2V7BsiZlemqUo5rFpp64qr8leS1ql5+s7rYhWUY00/ wvUpqSWpDR/tr52WAJb7tglHzFTVNf5wyUYTjo4L33IYw69oFkWQdpH1WHcvMzhQDqiF 0BrE9TMAOWrz+sJQtAcZe8BaWmXU3vyYgj1tqbvWuzpcO1vn8gOrqJMRyYPGTsA9mL4c 206g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=NPAkT40aeAujjzzths7lFAVGQtTsSW+wv6Fc10quSAA=; b=o9GotIVuDOlTVBOD6IXY3vfdxdNGjsIrK5GNDJaKrYkU5+pQlzL9/ld53WqjQDVLUI qG3yt2LEPLA+X2lcHmAWcg+n1a9lAqKf5wgPYc64ijpwtXtllgvbthygO6h1kyJD1qax X3P5kitSH9VynsD3I1U0PMuUkUkn2ViVbHBXcTD2Q9vsgza4hrmdbNY+YVnGYB8WHCyy YNMdwV667RAV8xFRiWUYliwN270huO8OfkG40J4cTP9MjrATLUehdZG/SPEKj3ZrBcal I5yLtDMwYucKMjLLumtjmRfO73NHBghUArwU2gnckK2TKD+cCUdg8Hkn9jph7B4Rgem4 Td9w== X-Gm-Message-State: AOAM532i/VzYY+WrnZub6tmt7M0jAebYE1fyoVUIHGdoB8HHcoqUBX8Q xUPuoVXmZUstBxaJ9GDcacYyz/WZ6Uz+TA== X-Google-Smtp-Source: ABdhPJyl0bmizXg+AMkADy31E8vQgVRnxTxqMTwkjXjfZjLkte9TF0+Me+9iwXAqqiher5nmrlSfFw== X-Received: by 2002:a17:90a:6583:: with SMTP id k3mr19249879pjj.227.1620013357006; Sun, 02 May 2021 20:42:37 -0700 (PDT) Received: from localhost (c-73-231-38-92.hsd1.ca.comcast.net. [73.231.38.92]) by smtp.gmail.com with ESMTPSA id b140sm7645336pfb.98.2021.05.02.20.42.36 for <48009@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 20:42:36 -0700 (PDT) From: Karthik Chikmagalur To: 48009@debbugs.gnu.org Subject: Re: bug#48009: 28.0.50; Support query-regexp-replace using re-builder Date: Sun, 02 May 2021 20:42:35 -0700 Message-ID: <874kfkh49g.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 48009 X-Mailman-Approved-At: Mon, 03 May 2021 01:02:55 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I wrote up a version of this feature at: https://karthinks.com/software/bridging-islands-in-emacs-1/ It includes a couple of video demos. This makes using an re-builder regexp as the input to query-replace-regexp more convenient. Specifically, it does the following: 1. When re-builder is called with a region active and then used as the input to reb-replace-regexp, replacements are limited to the region. (This is the behavior of query-replace-regexp) 2. When re-builder is called with the region inactive, replacements by reb-replace-regexp are carried out from the location of point in the main buffer. By default re-builder moves the point around when constructing the regexp (incrementally), so where the replacements begin from in the main buffer is not predictable. 3. This code involves advising re-builder (to remember the region and point), re-builder can probably be modified to include restoring the point/region state as a user option. 4. Ideally, it would be great if query-replace-regexp showed incremental matches the way isearch-forward-regexp does, but I'm not familiar with how that works. One advantage to calling reb-regexp-replace from re-builder instead of query-replace-regexp is that the user can specify the regexp in the rx format. CODE: ---------------------------------- (defvar my/re-builder-positions nil "Store point and region bounds before calling re-builder") (advice-add 're-builder :before (defun my/re-builder-save-state (&rest _) "Save into `my/re-builder-positions' the point and region positions before calling `re-builder'." (setq my/re-builder-positions (cons (point) (when (region-active-p) (list (region-beginning) (region-end))))))) (defun reb-replace-regexp (&optional delimited) "Run `query-replace-regexp' with the contents of re-builder. With non-nil optional argument DELIMITED, only replace matches surrounded by word boundaries." (interactive "P") (reb-update-regexp) (let* ((re (reb-target-binding reb-regexp)) (replacement (query-replace-read-to re (concat "Query replace" (if current-prefix-arg (if (eq current-prefix-arg '-) " backward" " word") "") " regexp" (if (with-selected-window reb-target-window (region-active-p)) " in region" "")) t)) (pnt (car my/re-builder-positions)) (beg (cadr my/re-builder-positions)) (end (caddr my/re-builder-positions))) (with-selected-window reb-target-window (goto-char pnt) ; replace with (goto-char (match-beginning 0)) if you want ; to control where in the buffer the replacement starts ; with re-builder (setq my/re-builder-positions nil) (reb-quit) (query-replace-regexp re replacement delimited beg end)))) -------------------- - Karthik Chikmagalur