[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple isearch concerns

From: Juri Linkov
Subject: Re: Simple isearch concerns
Date: Mon, 05 Apr 2021 01:48:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> 1) Are there any option to move the cursor to the start of the candidate
> after the search? I see that there is an isearch-other-end. But it is
> not a custom but an internal variable. Now I am using a hook but it
> seems a bit hacky.

I agree that isearch-mode-end-hook should be customizable.
Then initially we could provide at least one choice -
a hook to move to isearch-other-end on exit:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 943e24aa56..c924b73607 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -178,10 +178,13 @@ isearch-mode-hook
 (defvar isearch-update-post-hook nil
   "Function(s) to call after isearch has found matches in the buffer.")
-(defvar isearch-mode-end-hook nil
+(defcustom isearch-mode-end-hook nil
   "Function(s) to call after terminating an incremental search.
 When these functions are called, `isearch-mode-end-hook-quit'
-is non-nil if the user quits the search.")
+is non-nil if the user quits the search."
+  :type 'hook
+  :options '(isearch-exit-other-end)
+  :version "28.1")
 (defvar isearch-mode-end-hook-quit nil
   "Non-nil while running `isearch-mode-end-hook' if the user quits the 
@@ -1417,6 +1420,15 @@ isearch-done
   (and (not edit) isearch-recursive-edit (exit-recursive-edit)))
+(defun isearch-exit-other-end ()
+  "Move point to the beginning of the found search string.
+Can be used in `isearch-mode-end-hook' or interactively to exit isearch."
+  (interactive)
+  (when isearch-mode
+    (isearch-exit))
+  (when isearch-other-end
+    (goto-char isearch-other-end)))
 (defvar isearch-mouse-commands '(mouse-minor-mode-menu)
   "List of mouse commands that are allowed during Isearch.")
> 2) I want to disable wrapping and I see that there is an
> `isearch-wrap-function` but it is a variable not a custom and it is not
> documented in detail what is expected to be there.

isearch-wrap-function could be customizable in the same way with 3 options:
pause before wrapping (default), no pause, no warp at all.

> 3) In general many of the customizable variables in isearch are defined
> with defvar so it is difficult to distinguish between internal and user
> exposed ones. Just to mention some examples:
> isearch-push-state-function, isearch-filter-predicate, the hooks,

And these as well.

> Are there any WIP related?

There is no WIP until you create a feature request.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]