RepublicWorried · 2022-11-02 18:30
rather than the first matching phrase in the file below point (which may very well be outside of the currently visible file region)
​
Is there some setting for this?
globalcandyamnesia · 2022-11-02 21:23
By default, pressing C-g during an isearch will restore the buffer position, which is what I would recommend. You could also filter out any isearch results that are not within the range `(window-start)` to `(window-end)`:
(defun isearch-filter-within-window (beg end)
(and (< beg (window-end))
(>= end (window-start))))
(advice-add isearch-filter-predicate :before-while
#'isearch-filter-within-window)
1nc0ns1st3nt · 2022-11-03 10:38
Why don't you put together a small help function for that. Whilst I am not aware of any configuration that allows you to do what you have described, something of the following could work.
(defun <func-name> ()
(interactive)
(save-excursion
(goto-char(window-start))
(isearch-forward))