From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#29321: Isearch hit count Date: Mon, 29 Oct 2018 00:38:56 +0200 Organization: LINKOV.NET Message-ID: <874ld5elxb.fsf@mail.linkov.net> References: <87o9bfqfc3.fsf@mail.linkov.net> <988284b2-58af-428d-9c6f-da56db0c6565@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1540766381 9309 195.159.176.226 (28 Oct 2018 22:39:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2018 22:39:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: charles@aurox.ch, 29321@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 28 23:39:36 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGtiZ-0002J4-Pt for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2018 23:39:36 +0100 Original-Received: from localhost ([::1]:42429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGtkg-0001C5-0v for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Oct 2018 18:41:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gGtkA-0000pa-Ag for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2018 18:41:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gGtk3-0001vo-Q5 for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2018 18:41:13 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gGtjy-0001pU-1B for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2018 18:41:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gGtjx-0000lt-Qj for bug-gnu-emacs@gnu.org; Sun, 28 Oct 2018 18:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Oct 2018 22:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29321 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29321-submit@debbugs.gnu.org id=B29321.15407664502939 (code B ref 29321); Sun, 28 Oct 2018 22:41:01 +0000 Original-Received: (at 29321) by debbugs.gnu.org; 28 Oct 2018 22:40:50 +0000 Original-Received: from localhost ([127.0.0.1]:49428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGtjm-0000lK-72 for submit@debbugs.gnu.org; Sun, 28 Oct 2018 18:40:50 -0400 Original-Received: from cichlid.maple.relay.mailchannels.net ([23.83.214.36]:63857) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGtjj-0000lA-Eu for 29321@debbugs.gnu.org; Sun, 28 Oct 2018 18:40:49 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 9B9F45C32E5; Sun, 28 Oct 2018 22:40:45 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (unknown [100.96.35.77]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 549655C2640; Sun, 28 Oct 2018 22:40:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Sun, 28 Oct 2018 22:40:45 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Language-Macabre: 4cf28d456997d21e_1540766445501_3286231298 X-MC-Loop-Signature: 1540766445501:3635744068 X-MC-Ingress-Time: 1540766445500 Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTP id 0D5597F7BC; Sun, 28 Oct 2018 15:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=8uGvUX/JdnB0Tc3X7JVZLhPDkKo=; b= 0ckIHAJ6c0Kshm+uV5MS2kk3UNxRLlPK0koZzj7x/KJAfxR19ke4JIv+3lMKXoe+ UjZuHJVIl04ZRJFAxfbQp0dtfFwnt6GELVu3varQoys/WHuF4kQXQcfzU01i/GpF 4cBgS06KmLXJGxF1DyZ/ElpuvVjgwAdknM7oD5/flgQ= Original-Received: from mail.jurta.org (m91-129-105-154.cust.tele2.ee [91.129.105.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id 9F8A57F7B7; Sun, 28 Oct 2018 15:40:42 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a9 In-Reply-To: <988284b2-58af-428d-9c6f-da56db0c6565@default> (Drew Adams's message of "Sat, 27 Oct 2018 20:35:26 -0700 (PDT)") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrheeigdduieekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdehrdduheegnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddthedrudehgedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegurhgvfidrrggurghmshesohhrrggtlhgvrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151760 Archived-At: --=-=-= Content-Type: text/plain > First, when I hit `C-s ea' I see 1248/2520, but then another > `C-s' shows 1249/2530 - the total has jumped by 10. > > I continue searching forward, and the numbering seems normal: > 1250/2530, 1251/2530. OK, so the initial total was off by 10. > > But at match #1251 I switch to `C-r', and the match number is > 1241/2520: both the match number and the total are off by 10. > > On a small buffer I don't notice this problem. > > Do you see this too? If not, maybe I patched mistakenly. I see this too. The problem was in too frequent updating of the Isearch prompt - the loop updated it after every max-at-a-time (default 20) matches, thus causing flickering (that didn't update the final number). Now changed to show only the final number without showing intermediate numbers (that are invalid during counting anyway). Please try a new patch, it removes flickering: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=isearch-lazy-count.2.diff diff --git a/lisp/isearch.el b/lisp/isearch.el index 580b3ac40a..9127c4561a 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -316,6 +316,15 @@ isearch-lazy-highlight :group 'lazy-highlight :group 'isearch) +(defcustom isearch-lazy-count nil + "Show match number in the Isearch prompt. +When both this option and `isearch-lazy-highlight' are non-nil, show +CURRENT/TOTAL, where CURRENT is the current match number and TOTAL is +the total number of matches in the buffer (or its restriction)." + :type 'boolean + :group 'isearch + :version "27.1") + ;;; Lazy highlight customization. (defgroup lazy-highlight nil @@ -2802,7 +2811,16 @@ isearch-message-suffix (if isearch-error (concat " [" isearch-error "]") "") - (or isearch-message-suffix-add "")) + (or isearch-message-suffix-add "") + (if (and isearch-lazy-count isearch-lazy-count-current) + (format " (%d of %d)" + (if isearch-forward + isearch-lazy-count-current + (- isearch-lazy-count-total + isearch-lazy-count-current + -1)) + (or isearch-lazy-count-total "?")) + "")) 'face 'minibuffer-prompt)) @@ -3212,6 +3230,10 @@ 'isearch-lazy-highlight-word (defvar isearch-lazy-highlight-regexp-function nil) (defvar isearch-lazy-highlight-forward nil) (defvar isearch-lazy-highlight-error nil) +(defvar isearch-lazy-count-current nil) +(defvar isearch-lazy-count-total nil) +(defvar isearch-lazy-count-start nil) +(defvar isearch-lazy-count-hash (make-hash-table)) (defun lazy-highlight-cleanup (&optional force procrastinate) "Stop lazy highlighting and remove extra highlighting from current buffer. @@ -3235,33 +3257,35 @@ isearch-lazy-highlight-new-loop This is called when `isearch-update' is invoked (which can cause the search string to change or the window to scroll). It is also used by other Emacs features." + (setq isearch-lazy-count-start + (or (not (equal isearch-string + isearch-lazy-highlight-last-string)) + (not (memq (selected-window) + isearch-lazy-highlight-window-group)) + (not (eq isearch-lazy-highlight-case-fold-search + isearch-case-fold-search)) + (not (eq isearch-lazy-highlight-regexp + isearch-regexp)) + (not (eq isearch-lazy-highlight-regexp-function + isearch-regexp-function)) + (not (eq isearch-lazy-highlight-lax-whitespace + isearch-lax-whitespace)) + (not (eq isearch-lazy-highlight-regexp-lax-whitespace + isearch-regexp-lax-whitespace)) + (not (eq isearch-forward + isearch-lazy-highlight-forward)) + ;; In case we are recovering from an error. + (not (equal isearch-error + isearch-lazy-highlight-error)))) (when (and (null executing-kbd-macro) (sit-for 0) ;make sure (window-start) is credible - (or (not (equal isearch-string - isearch-lazy-highlight-last-string)) - (not (memq (selected-window) - isearch-lazy-highlight-window-group)) - (not (eq isearch-lazy-highlight-case-fold-search - isearch-case-fold-search)) - (not (eq isearch-lazy-highlight-regexp - isearch-regexp)) - (not (eq isearch-lazy-highlight-regexp-function - isearch-regexp-function)) - (not (eq isearch-lazy-highlight-lax-whitespace - isearch-lax-whitespace)) - (not (eq isearch-lazy-highlight-regexp-lax-whitespace - isearch-regexp-lax-whitespace)) - (not (or lazy-highlight-buffer - (= (window-group-start) + (or isearch-lazy-count-start + (not (or lazy-highlight-buffer + (= (window-group-start) isearch-lazy-highlight-window-start))) - (not (or lazy-highlight-buffer - (= (window-group-end) ; Window may have been split/joined. - isearch-lazy-highlight-window-end))) - (not (eq isearch-forward - isearch-lazy-highlight-forward)) - ;; In case we are recovering from an error. - (not (equal isearch-error - isearch-lazy-highlight-error)))) + (not (or lazy-highlight-buffer + (= (window-group-end) ; Window may have been split/joined. + isearch-lazy-highlight-window-end))))) ;; something important did indeed change (lazy-highlight-cleanup t (not (equal isearch-string ""))) ;stop old timer (setq isearch-lazy-highlight-error isearch-error) @@ -3303,9 +3327,22 @@ isearch-lazy-highlight-new-loop (1- (length isearch-lazy-highlight-last-string))) (point-min)))) (unless (equal isearch-string "") + (when (and isearch-lazy-count isearch-mode) + (when isearch-lazy-count-start + (clrhash isearch-lazy-count-hash) + (setq isearch-lazy-count-current nil + isearch-lazy-count-total nil) + (funcall (or isearch-message-function #'isearch-message) nil t))) (setq isearch-lazy-highlight-timer (run-with-idle-timer lazy-highlight-initial-delay nil - 'isearch-lazy-highlight-start))))) + 'isearch-lazy-highlight-start)))) + (when (and isearch-lazy-count isearch-mode) + ;; Update isearch-lazy-count-current only when it was already set + ;; at the end of isearch-lazy-highlight-buffer-update + (when isearch-lazy-count-current + (setq isearch-lazy-count-current + (gethash isearch-other-end isearch-lazy-count-hash)) + (funcall (or isearch-message-function #'isearch-message) nil t)))) (defun isearch-lazy-highlight-search (string bound) "Search ahead for the next or previous match, for lazy highlighting. @@ -3426,7 +3463,8 @@ isearch-lazy-highlight-update (goto-char (min (or isearch-lazy-highlight-end-limit (point-max)) window-end))))))) (if nomore - (when isearch-lazy-highlight-buffer + (when (or isearch-lazy-highlight-buffer + isearch-lazy-count-start) (if isearch-lazy-highlight-forward (setq isearch-lazy-highlight-end (point-min)) (setq isearch-lazy-highlight-start (point-max))) @@ -3475,8 +3513,13 @@ isearch-lazy-highlight-buffer-update (if (= mb (point-min)) (setq found nil) (forward-char -1))) + (setq isearch-lazy-count-total (1+ (or isearch-lazy-count-total 0))) + (puthash (if isearch-lazy-highlight-forward mb me) + isearch-lazy-count-total + isearch-lazy-count-hash) ;; Already highlighted by isearch-lazy-highlight-update - (unless (and (>= mb window-start) (<= me window-end)) + (unless (or (and (>= mb window-start) (<= me window-end)) + (not isearch-lazy-highlight-buffer)) ;; non-zero-length match (isearch-lazy-highlight-match mb me))) ;; Remember the current position of point for @@ -3490,7 +3533,11 @@ isearch-lazy-highlight-buffer-update (if (not found) (setq looping nil nomore t)))) - (unless nomore + (if nomore + (when (and isearch-lazy-count isearch-mode) + (setq isearch-lazy-count-current + (gethash isearch-other-end isearch-lazy-count-hash)) + (funcall (or isearch-message-function #'isearch-message) nil t)) (setq isearch-lazy-highlight-timer (run-at-time lazy-highlight-interval nil 'isearch-lazy-highlight-buffer-update))))))))) --=-=-=--