From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Live System User Newsgroups: gmane.emacs.bugs Subject: bug#29321: Isearch hit count Date: Thu, 15 Nov 2018 03:02:51 -0500 Message-ID: <87y39u7opg.fsf@aol.com> References: <87va4zmglm.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1542268935 31061 195.159.176.226 (15 Nov 2018 08:02:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Nov 2018 08:02:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 29321@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 15 09:02:11 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 1gNCbH-0007uB-P7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Nov 2018 09:02:07 +0100 Original-Received: from localhost ([::1]:37325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNCdN-0006Iu-Uv for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Nov 2018 03:04:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNCdF-0006ID-BQ for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:04:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNCd9-0001nd-Hx for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:04:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48692) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNCd7-0001md-R1 for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gNCd7-0006Fu-Lp for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:04:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Live System User Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Nov 2018 08:04: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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.154226901824015 (code B ref -1); Thu, 15 Nov 2018 08:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Nov 2018 08:03:38 +0000 Original-Received: from localhost ([127.0.0.1]:52950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNCck-0006FH-13 for submit@debbugs.gnu.org; Thu, 15 Nov 2018 03:03:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gNCci-0006F5-73 for submit@debbugs.gnu.org; Thu, 15 Nov 2018 03:03:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNCcZ-0001Jn-0x for submit@debbugs.gnu.org; Thu, 15 Nov 2018 03:03:31 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:45191) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNCcO-0001G0-0v for submit@debbugs.gnu.org; Thu, 15 Nov 2018 03:03:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNCcH-000641-QH for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:03:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNCcD-000156-Hy for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:03:09 -0500 Original-Received: from [195.159.176.226] (port=33590 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNCcD-00012S-8L for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 03:03:05 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gNCa0-0006Jg-JA for bug-gnu-emacs@gnu.org; Thu, 15 Nov 2018 09:00:48 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 148 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:CUeH99BWu9/tik4e58Ky42QAJLw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:152404 Archived-At: Juri Linkov writes: >> Isearch could show in the mode line how many matches follow or precede >> the currently highlighted one (or we could write "3 of 4 matches", as, >> e.g., Firefox does). For big files, it could be helpful to calculate >> this information either lazily or in another thread. > > Lazy-counting is now pushed to master. > >> If we had this, it would also be convenient to say "go forward n >> matches", so that typing "M-3 C-s" during a search would be the >> equivalent of typing C-s three times. To do this we could add numeric >> prefix arg handling to C-s/C-r/C-M-s/C-M-r, if that isn't already >> taken for some other behavior. > > Adding a numeric prefix arg to C-s/C-r is implemented in > https://debbugs.gnu.org/29321#86 Thanks! > > But this implementation causes flicker because it updates > isearch highlighting on every search hit while traversing > all found matches COUNT times until it reaches COUNT-th match. > > Attached is a better approach that adds the COUNT arg to > isearch functions down to the lowest-level isearch function, > thus making it compatible with the COUNT arg of re-search-forward: Unfortunately, this patch (below) had errrs for me: 0. emacs -Q & 1. M-: (setq isearch-lazy-count t) 2. M-x load-file RET isearch-new.el RET 3. C-x C-r isearch-new.el I then search for the string "-count" ... 4. C-s -c ...and in the echo area I see: 0/0 I-search: -c [(void-variable +)] The cursor doesn't move and no matches are not highlighted nor is there a "Failing I-search" " meassage. Thanks. > > diff --git a/lisp/isearch.el b/lisp/isearch.el > index 035ff69327..3e6e696a74 100644 > --- a/lisp/isearch.el > +++ b/lisp/isearch.el > @@ -1547,7 +1547,7 @@ isearch-abort > (isearch-pop-state)) > (isearch-update))) > > -(defun isearch-repeat (direction) > +(defun isearch-repeat (direction &optional count) > ;; Utility for isearch-repeat-forward and -backward. > (if (eq isearch-forward (eq direction 'forward)) > ;; C-s in forward or C-r in reverse. > @@ -1590,21 +1590,29 @@ isearch-repeat > (setq isearch-success nil) > (ding)) > (forward-char (if isearch-forward 1 -1)) > - (isearch-search)) > - (isearch-search))) > + (isearch-search count)) > + (isearch-search count))) > > (isearch-push-state) > (isearch-update)) > > -(defun isearch-repeat-forward () > - "Repeat incremental search forwards." > - (interactive) > - (isearch-repeat 'forward)) > - > -(defun isearch-repeat-backward () > - "Repeat incremental search backwards." > - (interactive) > - (isearch-repeat 'backward)) > +(defun isearch-repeat-forward (&optional arg) > + "Repeat incremental search forwards. > +With a prefix argument, repeat a search ARG times." > + (interactive "P") > + (let ((count (and arg (abs (prefix-numeric-value arg))))) > + ;; Take into account one search iteration to reverse direction. > + (when (and count (not isearch-forward)) (setq count (1+ count))) > + (isearch-repeat 'forward count))) > + > +(defun isearch-repeat-backward (&optional arg) > + "Repeat incremental search backwards. > +With a prefix argument, repeat a search ARG times." > + (interactive "P") > + (let ((count (and arg (abs (prefix-numeric-value arg))))) > + ;; Take into account one search iteration to reverse direction. > + (when (and count isearch-forward) (setq count (1+ count))) > + (isearch-repeat 'backward count))) > > > ;;; Toggles for `isearch-regexp-function' and `search-default-mode'. > @@ -2910,7 +2918,7 @@ isearch-search-fun-default > (t (regexp-quote string))) > bound noerror count)))) > > -(defun isearch-search-string (string bound noerror) > +(defun isearch-search-string (string bound noerror &optional count) > "Search for the first occurrence of STRING or its translation. > STRING's characters are translated using `translation-table-for-input' > if that is non-nil. > @@ -2921,7 +2929,10 @@ isearch-search-string > Optional third argument, if t, means if fail just return nil (no error). > If not nil and not t, move to limit of search and return nil." > (let* ((func (isearch-search-fun)) > - (pos1 (save-excursion (funcall func string bound noerror))) > + (pos1 (save-excursion (if count > + (funcall func string bound noerror count) > + ;; Backward-compatibility for functions that don't support count arg > + (funcall func string bound noerror)))) > pos2) > (when (and > ;; Avoid "obsolete" warnings for translation-table-for-input. > @@ -2960,7 +2971,7 @@ isearch-search-string > (goto-char pos1) > pos1))) > > -(defun isearch-search () > +(defun isearch-search (&optional count) > ;; Do the search with the current search string. > (if (and (eq isearch-case-fold-search t) search-upper-case) > (setq isearch-case-fold-search > @@ -2974,7 +2985,7 @@ isearch-search > (setq isearch-error nil) > (while retry > (setq isearch-success > - (isearch-search-string isearch-string nil t)) > + (isearch-search-string isearch-string nil t count)) > ;; Clear RETRY unless the search predicate says > ;; to skip this search hit. > (if (or (not isearch-success)