From cdb0d080f1bb2239ccb828d989d6bb73409d5f59 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 21 Nov 2018 23:33:22 +0200 Subject: [PATCH] Add prefix arg to isearch-forward-symbol-at-point (bug#29321) * lisp/isearch.el (isearch-forward-symbol-at-point): Add optional arg. --- etc/NEWS | 2 ++ lisp/isearch.el | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 13d660812d6..dc08e1caf25 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -644,6 +644,8 @@ can now be searched via 'C-s'. and 'C-r' ('isearch-repeat-backward'). With a prefix argument, these commands repeat the search for the specified occurrence of the search string. A negative argument repeats the search in the opposite direction. +This makes possible also to use a prefix argument for 'M-s .' +('isearch-forward-symbol-at-point') to find the next Nth symbol. *** 'isearch-lazy-count' shows the current match number and total number of matches in the Isearch prompt. Customizable variables diff --git a/lisp/isearch.el b/lisp/isearch.el index 6d94ef66931..b05805ccd6d 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -887,21 +887,26 @@ as a regexp. See the command `isearch-forward-regexp' for more information." (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) -- 2.39.2