From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Karthik Chikmagalur Newsgroups: gmane.emacs.bugs Subject: bug#49842: re-builder restriction to region (lisp/emacs-lisp/re-builder) Date: Mon, 02 Aug 2021 21:03:31 -0700 Message-ID: <87lf5jqing.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33027"; mail-complaints-to="usenet@ciao.gmane.io" To: 49842@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 03 06:04:10 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 1mAlf0-0008QB-8d for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Aug 2021 06:04:10 +0200 Original-Received: from localhost ([::1]:42926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAley-000192-PT for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Aug 2021 00:04:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAles-00018t-V4 for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 00:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAles-0001I2-Nq for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 00:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mAles-0001no-Hv for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 00:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Karthik Chikmagalur Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Aug 2021 04:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49842 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.16279634226891 (code B ref -1); Tue, 03 Aug 2021 04:04:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Aug 2021 04:03:42 +0000 Original-Received: from localhost ([127.0.0.1]:39600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAleY-0001n5-3i for submit@debbugs.gnu.org; Tue, 03 Aug 2021 00:03:42 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAleW-0001my-VW for submit@debbugs.gnu.org; Tue, 03 Aug 2021 00:03:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAleW-00018Q-NQ for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 00:03:40 -0400 Original-Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:54786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAleV-0000w4-2x for bug-gnu-emacs@gnu.org; Tue, 03 Aug 2021 00:03:40 -0400 Original-Received: by mail-pj1-x1030.google.com with SMTP id a8so5000550pjk.4 for ; Mon, 02 Aug 2021 21:03:38 -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=mwq0tA6JoDe+3JxInZbJDEczSNXRCRb4mjcWR/eYPI8=; b=ZNzOOmSDkVbzvwE3kuTWTslUtoIn+PS72dHxnTAN8jPLc3ZSmSwMA5jw9GgeoGCurh GIR+m+FadN0Z5Rg+gL6ts9FB2GY0Vogx5fTW+Y4IQJCBteBsM6J+yqN72YdsEk8tovvn O2bcNw7sXtDLc/HxwnOx60SlCQteb+WZHz45FaaBKJ27R7YlXUwEx/EAlglrN97aTxtb EX7M/pgoJq77N07AZej3HgwZq3z/rL2ScuFDuXa/pOysjX0TpcHshvATt1xYv03khoKz Ea46HaD+KW63E2Vg9faw356LkW7M5QgLlr9zHxZ7q8JfSwZ07wgx/HIkHqJgJcw805qJ NUhA== 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=mwq0tA6JoDe+3JxInZbJDEczSNXRCRb4mjcWR/eYPI8=; b=um8BRSbdsn5/dJIrQC/fPLuBBZHvr5IUtSTKvQ9EMeWO9fEW2sM6L2v8eQ278s3Cun Bqo2YLIlrRPktyRtmncjzSndvimQVCIWBbunZKiEfy3TAgTtfdi+3cAhHYQ/EaeEl841 CW1MRBrnMlIswGMmQZHciab6L3gpAbk0qjK4dHJTevFZBdb4zshPvBMEkDAuz0M3K2Vd vbjwJhsZMYx6ShL1K0hrCYijUUjVXcMPxQjSMKcVXA4YNfmhr+IQ2XLcHChSeD2SC6M4 rZQCg/dNmSJ99LkY+5BqxYxhpciNmHbXs0Xp+HCoSFqvKCWwI0fDiSBa3y+nWUZooyN9 BkWQ== X-Gm-Message-State: AOAM5319HRvk77X6M/Z2pseEPmrzni7+cCI48eWqVAJJw8AA+KRiOOJq PJLidBilft5b1VltL9G4wmEUWT5mwDerWw== X-Google-Smtp-Source: ABdhPJyTAkmz0QTSKQpXutiCzTI8gm8lZOSYqS+UEFQND520h/cmTqAmWhM3RGsCC8VRhA5J+CNFVw== X-Received: by 2002:a63:e807:: with SMTP id s7mr805787pgh.200.1627963417138; Mon, 02 Aug 2021 21:03:37 -0700 (PDT) Original-Received: from localhost (169-231-132-213.wireless.ucsb.edu. [169.231.132.213]) by smtp.gmail.com with ESMTPSA id y139sm13163843pfb.107.2021.08.02.21.03.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 21:03:36 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=karthikchikmagalur@gmail.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:211086 Archived-At: --=-=-= Content-Type: text/plain Hello, The function "reb-update-overlays" (in lisp/emacs-lisp/re-builder.el) displays matches in the whole of reb-target-buffer starting at (point-min) even when the region is active. In keeping with the behavior of commands like query-replace, replace-regexp and query-replace-regexp, I modified it so that when the region is active re-builder only displays matches in the active region. It's behavior is unchanged when the region is inactive. I think this change makes sense without disrupting the expectations of re-builder users. More generally, I think re-builder needs some work: 1. When the user quits re-builder, the point in reb-target-buffer is not restored correctly. 2. Without an active region, there should be an option to match forward or backward from reb-target-buffer's point instead of always matching from (point-min), with the ability to customize the default behavior. 3. re-builder's overlay system (or some modification of it) can be used by query-replace-regexp to show matches as the user types. I am waiting to sign the copyright papers from FSF (which I have applied for) before sending in these larger patches. Commit log entry: * lisp/emacs-lisp/re-builder.el (reb-update-overlays): Restrict re-builder matches to region when the region is active. Karthik Chikmagalur --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=re-builder.patch diff -u emacs-src/lisp/emacs-lisp/re-builder.el emacs-src/lisp/emacs-lisp/re-builder-new.el --- /lisp/emacs-lisp/re-builder.el 2021-08-02 20:47:39.226669281 -0700 +++ /lisp/emacs-lisp/re-builder-new.el 2021-08-02 20:37:27.442020958 -0700 @@ -642,16 +642,19 @@ (submatches 0) firstmatch here + start end firstmatch-after-here) (with-current-buffer reb-target-buffer (setq here (if reb-target-window (with-selected-window reb-target-window (window-point)) - (point))) + (point)) + start (if (region-active-p) (region-beginning) (point-min)) + end (if (region-active-p) (region-end) (point-max))) (reb-delete-overlays) - (goto-char (point-min)) + (goto-char start) (while (and (not (eobp)) - (re-search-forward re (point-max) t) + (re-search-forward re end t) (or (not reb-auto-match-limit) (< matches reb-auto-match-limit))) (when (and (= 0 (length (match-string 0))) Diff finished. Mon Aug 2 20:48:01 2021 --=-=-=--