Function: isearch-beginning-of-buffer
isearch-beginning-of-buffer is an interactive and byte-compiled
function defined in isearch.el.gz.
Signature
(isearch-beginning-of-buffer &optional ARG)
Documentation
Go to the first occurrence of the current search string.
Move point to the beginning of the buffer and search forwards from the top.
With a numeric argument, go to the ARGth absolute occurrence counting from
the beginning of the buffer. To find the next relative occurrence forwards,
type C-s (isearch-repeat-forward) with a numeric argument.
You might want to use isearch-allow-motion instead of this command.
Probably introduced at or before Emacs version 27.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-beginning-of-buffer (&optional arg)
"Go to the first occurrence of the current search string.
Move point to the beginning of the buffer and search forwards from the top.
\\<isearch-mode-map>
With a numeric argument, go to the ARGth absolute occurrence counting from
the beginning of the buffer. To find the next relative occurrence forwards,
type \\[isearch-repeat-forward] with a numeric argument.
You might want to use `isearch-allow-motion' instead of this command."
(interactive "p")
(if (and arg (< arg 0))
(isearch-end-of-buffer (abs arg))
;; For the case when the match is at bobp,
;; don't forward char in isearch-repeat
(setq isearch-just-started t)
(goto-char (point-min))
(let ((current-direction (if isearch-forward 'forward 'backward))
(isearch-repeat-on-direction-change nil))
(isearch-repeat 'forward arg)
(unless (eq current-direction (if isearch-forward 'forward 'backward))
(isearch-repeat current-direction)))))