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: Wed, 21 Nov 2018 01:52:17 +0200 Organization: LINKOV.NET Message-ID: <87r2ff2tou.fsf@mail.linkov.net> 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 1542757927 21341 195.159.176.226 (20 Nov 2018 23:52:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 20 Nov 2018 23:52:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 29321@debbugs.gnu.org To: charles@aurox.ch (Charles A. Roelli) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 21 00:52:03 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 1gPFoJ-0005SX-8T for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Nov 2018 00:52:03 +0100 Original-Received: from localhost ([::1]:36561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPFqP-0004id-M7 for geb-bug-gnu-emacs@m.gmane.org; Tue, 20 Nov 2018 18:54:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPFqJ-0004iX-9d for bug-gnu-emacs@gnu.org; Tue, 20 Nov 2018 18:54:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPFqE-0001pf-Vl for bug-gnu-emacs@gnu.org; Tue, 20 Nov 2018 18:54:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPFqE-0001oP-9b for bug-gnu-emacs@gnu.org; Tue, 20 Nov 2018 18:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPFqE-0004lN-53 for bug-gnu-emacs@gnu.org; Tue, 20 Nov 2018 18:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Nov 2018 23:54:02 +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.154275803218286 (code B ref 29321); Tue, 20 Nov 2018 23:54:02 +0000 Original-Received: (at 29321) by debbugs.gnu.org; 20 Nov 2018 23:53:52 +0000 Original-Received: from localhost ([127.0.0.1]:37582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPFq3-0004ks-Kp for submit@debbugs.gnu.org; Tue, 20 Nov 2018 18:53:51 -0500 Original-Received: from ostrich.birch.relay.mailchannels.net ([23.83.209.138]:43430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gPFq1-0004kj-LR for 29321@debbugs.gnu.org; Tue, 20 Nov 2018 18:53:50 -0500 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 8E7401247F7; Tue, 20 Nov 2018 23:53:48 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a37.g.dreamhost.com (unknown [100.96.35.77]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 44AC0124794; Tue, 20 Nov 2018 23:53:48 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a37.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); Tue, 20 Nov 2018 23:53:48 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Abaft-Relation: 42b263a36fb47a4d_1542758028419_2677993770 X-MC-Loop-Signature: 1542758028419:3586129168 X-MC-Ingress-Time: 1542758028418 Original-Received: from pdx1-sub0-mail-a37.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a37.g.dreamhost.com (Postfix) with ESMTP id 0A4A3808CA; Tue, 20 Nov 2018 15:53:48 -0800 (PST) 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=M8ITLdo+bjJI1nOR+vANWyvSVzg=; b= oIt0mmjVRxa+J7akpLp8iuZ6vba7R1leFtWKiPR954TpqjGSH7erNvTXceuADYlj uKWmp3qPYUFFwhSznCaYi8n+gzAEr2LBU++dG6BCQgRhSffgL6qZ2WmAip9hqt9s ubeXJHgJ5mg/Q1WPeeaH49UUPuDbvYGrGr4ulaub+FQ= Original-Received: from mail.jurta.org (m91-129-105-252.cust.tele2.ee [91.129.105.252]) (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-a37.g.dreamhost.com (Postfix) with ESMTPSA id ED39A808C4; Tue, 20 Nov 2018 15:53:45 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a37 In-Reply-To: (Charles A. Roelli's message of "Thu, 15 Nov 2018 22:15:31 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedruddtiedgudeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdehrddvhedvnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddthedrvdehvddprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegthhgrrhhlvghssegruhhrohigrdgthhenucevlhhushhtvghrufhiiigvpedt 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:152604 Archived-At: > Do you think adding similar behavior to > "isearch-forward"/"isearch-backward" would be feasible? For example, > C-6 C-s foo could move point forward to the sixth next occurrence of > "foo". Now that isearch-repeat-forward supports a prefix arg, it's easy to do this for isearch-forward-symbol-at-point with a small patch below. This allows a trivial implementation of corresponding Vi-like keybindings. I don't like Vi-keybindings, but here's the implementation for anyone who likes Vi-keybindings: (defun isearch-forward-search-symbol-at-point (&optional count) (interactive "p") (isearch-forward-symbol-at-point (or count 1))) (define-key search-map "*" 'isearch-forward-search-symbol-at-point) (defun isearch-backward-search-symbol-at-point (&optional count) (interactive "p") (isearch-forward-symbol-at-point (- (or count 1)))) (define-key search-map "#" 'isearch-backward-search-symbol-at-point) Here's the patch that adds a prefix arg: diff --git a/lisp/isearch.el b/lisp/isearch.el index 6d94ef6693..78c4d7b275 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -887,21 +887,26 @@ isearch-backward-regexp (interactive "P\np") (isearch-mode nil (null not-regexp) nil (not no-recursive-edit))) -(defun isearch-forward-symbol-at-point () +(defun isearch-forward-symbol-at-point (&optional arg) "Do incremental search forward for a symbol found near point. Like ordinary incremental search except that the symbol found at point is added to the search string initially as a regexp surrounded by symbol boundary constructs \\_< and \\_>. -See the command `isearch-forward-symbol' for more information." - (interactive) +See the command `isearch-forward-symbol' for more information. +With a prefix argument, search for ARGth symbol forward if ARG is +positive, or search for ARGth symbol backward if ARG is negative." + (interactive "P") (isearch-forward-symbol nil 1) - (let ((bounds (find-tag-default-bounds))) + (let ((bounds (find-tag-default-bounds)) + (count (and arg (prefix-numeric-value arg)))) (cond (bounds (when (< (car bounds) (point)) (goto-char (car bounds))) (isearch-yank-string - (buffer-substring-no-properties (car bounds) (cdr bounds)))) + (buffer-substring-no-properties (car bounds) (cdr bounds))) + (when count + (isearch-repeat-forward count))) (t (setq isearch-error "No symbol at point") (isearch-push-state)