From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc. Date: Sun, 09 Jan 2022 11:02:46 +0100 Message-ID: <87tuedp6pl.fsf@gmail.com> References: <87sftyweb2.fsf@gmail.com> <861r1iyrvw.fsf@mail.linkov.net> <87zgo6owaf.fsf@gmail.com> <86k0f9xnrn.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27146"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.90 (gnu/linux) Cc: 53126@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 09 11:03:21 2022 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 1n6V2m-0006nA-99 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 11:03:20 +0100 Original-Received: from localhost ([::1]:46930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6V2k-00076d-8S for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 05:03:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6V2U-00076F-2y for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 05:03:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6V2T-0002pS-Qv for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 05:03:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n6V2T-0008No-Lp for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 05:03:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Jan 2022 10:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 53126-submit@debbugs.gnu.org id=B53126.164172258032217 (code B ref 53126); Sun, 09 Jan 2022 10:03:01 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 9 Jan 2022 10:03:00 +0000 Original-Received: from localhost ([127.0.0.1]:49246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6V2S-0008NZ-HC for submit@debbugs.gnu.org; Sun, 09 Jan 2022 05:03:00 -0500 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:51962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6V2N-0008NF-Fh for 53126@debbugs.gnu.org; Sun, 09 Jan 2022 05:02:59 -0500 Original-Received: by mail-wm1-f51.google.com with SMTP id e5so6883737wmq.1 for <53126@debbugs.gnu.org>; Sun, 09 Jan 2022 02:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=NR3hJ1pJzoUao3ou56k+2G1jNK69h6AnXUqpzG1VZS4=; b=CZ2/eKk2TFa9nW4pVqGl7vIOmcBPoJL+K36VfKIvvBwvntNkDJuT/CE4zzSmR1pvPH Pa+5QvHkKT0xiIwV47Q+hZ8Iv8zOEiOZ9hCZbNIYDjQtBPJa6eV+gKPAsbFFCo+LI99a X/+8AEXegm2D/fQqlK3wnOIDe+QqdowylbuZ+FWAMqB+/bWfyGFWNZjYYrlbu8ur8cDZ i4mpabTZuvaxZIGaIm7zb6FJVvfyFnT1Oj2bLu4eKnJFjsVQCHcRQDClQK+6y9MKOzQQ FPlKR2VeDvpLRfmD53OMXA7GRwpFUCyEHLSWPCRchi/6RDg1CC5rNRgt81bocFFVnqSE COPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=NR3hJ1pJzoUao3ou56k+2G1jNK69h6AnXUqpzG1VZS4=; b=6cCKJEzvHCC2141CyheIzGuDKZPCkYF64HeVUOxTm5SK3o5CowcaDqNE5PLpQw5s4Y iZt5SLHft1bGF8ctqex5hAYU4qRpPaCbLPPcTGcsia4AbqVIaDIpnWiBaFzxoOU5FVLz tnTtPjE49Xgns/oKDTq2ARr9aU+or7b+nB+QC9QeYKzTswSRn+7TvNoG7jv3hWRtPzYh NXbth95bFCbZhK4lwIgqZuDPgxH7VfA/yKKBPnPg1c+h0Rud84gR84kA8n1EENdQO5SQ EMsGvSyGuAQMIYO2Qrq+K5On0cqh6gl9ZfFZEU0GjvIWPrKqCJYtJVSHaEWHjMAcArWU ykAA== X-Gm-Message-State: AOAM532hbRDOv/8NB1A/keyBUjrqSDMERn7szdMFxp0NEbTuXQ6mElpN 2/+QcddSFxkwFsfNikevld50yRMtuFI= X-Google-Smtp-Source: ABdhPJw802vdoShSRUq0cUhQhuQ2I1HTYo5Ugd8qd4ipoDWu2zuESRH9Gb3hKe3p5WvTRGPsraMCMw== X-Received: by 2002:a05:600c:1e24:: with SMTP id ay36mr18065529wmb.84.1641722568968; Sun, 09 Jan 2022 02:02:48 -0800 (PST) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::15a6]) by smtp.gmail.com with ESMTPSA id f8sm4134376wry.16.2022.01.09.02.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 02:02:48 -0800 (PST) In-Reply-To: <86k0f9xnrn.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 09 Jan 2022 11:10:13 +0200") 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:223837 Archived-At: On Sun, 9 Jan 2022 at 11:10, Juri Linkov wrote: > It seems the "Query replacing" prompt in perform-replace could just > display the values of isearch-lazy-count-current and > isearch-lazy-count-total. Yes, I guess you are right. > Or for asynchronous lazy-count a new hook needs to be run at the end > of isearch-lazy-highlight-buffer-update in addition to the call of > isearch-message. > That's what the patch does (but with a variable pointing to a function instead of a hook, although this can be changed). But note that it's not enough to do something =E2=80=9Cin addition to the call of isearch-mess= age=E2=80=9D; it's necessary to _suppress_ the call to isearch-message. >>> But your patches are intended for a different feature - highlighting >>> of matches in the buffer while entering an input string in the minibuff= er. >>> >>> I wonder how many users need this feature, when it's easy to construct >>> a query-replace string using highlighting/counting in isearch-mode, >>> then type M-% >>> (isearch-query-replace) that invokes query-replace with the >>> query-replace string. >> >> Sure, this alternative method works. But somehow it's not the way I >> usually start a replace, and I think there's nothing wrong with that >> preference :-) > > But this method is more limiting - no keys to pull text from the buffer > like 'C-w' (isearch-yank-word-or-char) does in isearch-mode, no way > to navigate to the first match like it's possible in isearch-mode, etc. > OTOH, you can't do a replace-in-region that way. > Maybe then this feature could be added to read-regexp or even > to read-from-minibuffer? And activated by adding a setup function > to minibuffer-setup-hook like other minibuffer's features do, such as > icomplete-minibuffer-setup, minibuffer-depth-setup, rfn-eshadow-setup-min= ibuffer. > > Then maybe a new feature could be named e.g. "lazy-minibuffer"? This is what the patch does, with code of this kind: ``` (let ((isearch-regexp t) ;; Whatever else isearch / lazy-highlight settings might be needed (isearch-lazy-count-display-function #'isearch-read-with-highlight-co= unt)) (minibuffer-with-setup-hook #'isearch-read-with-highlight-setup (read-from-minibuffer "Type a regexp with preview: "))) ``` There could be a convenience wrapper for this code, but I'm not sure that makes much sense, because isearch and lazy-highlight have too many parameters one might need to set so it's better to be explicit/flexible.