From 754f8953d24734a8a71bc6705f156f9981ed067d Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Tue, 6 Apr 2021 20:59:46 +0000 Subject: [PATCH] Add options when exiting isearch * lisp/isearch.el (isearch-exit): Add two options when exiting isearch. --- lisp/isearch.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 943e24aa56..0f66110493 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1523,12 +1523,20 @@ REGEXP if non-nil says use the regexp search ring." "Exit search normally. However, if this is the first command after starting incremental search and `search-nonincremental-instead' is non-nil, do a -nonincremental search instead via `isearch-edit-string'." - (interactive) +nonincremental search instead via `isearch-edit-string'. +With a single prefix argument, move point to the beginning of the +search string, unless the region is active. +With two prefix arguments, activate the region around the match, +unless the region is already active." + (interactive "p") (if (and search-nonincremental-instead (= 0 (length isearch-string))) (let ((isearch-nonincremental t)) (isearch-edit-string)) ;; this calls isearch-done as well + (if (and (> arg 1) isearch-other-end (not (use-region-p))) + (if (> arg 4) + (push-mark isearch-other-end t 'activate) + (goto-char isearch-other-end))) (isearch-done)) (isearch-clean-overlays)) -- 2.30.2