diff options
author | Juri Linkov <juri@linkov.net> | 2018-11-21 23:33:22 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2018-11-21 23:33:22 +0200 |
commit | cdb0d080f1bb2239ccb828d989d6bb73409d5f59 (patch) | |
tree | b305910f183b21e2f0e0c40d8a782547a4924f89 | |
parent | 8f49cb00d06e06c2db67305433e743e706645bb2 (diff) | |
download | emacs-cdb0d080f1bb2239ccb828d989d6bb73409d5f59.tar.gz |
Add prefix arg to isearch-forward-symbol-at-point (bug#29321)
* lisp/isearch.el (isearch-forward-symbol-at-point): Add optional arg.
-rw-r--r-- | etc/NEWS | 2 | ||||
-rw-r--r-- | lisp/isearch.el | 15 |
2 files changed, 12 insertions, 5 deletions
@@ -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) |