Function: beginning-of-defun
beginning-of-defun is an interactive and byte-compiled function
defined in lisp.el.gz.
Signature
(beginning-of-defun &optional ARG)
Documentation
Move backward to the beginning of a defun.
With ARG, do it that many times. Negative ARG means move forward to the ARGth following beginning of defun.
If search is successful, return t; point ends up at the beginning of the line where the search succeeded. Otherwise, return nil.
When open-paren-in-column-0-is-defun-start is non-nil, a defun
is assumed to start where there is a char with open-parenthesis
syntax at the beginning of a line. If defun-prompt-regexp is
non-nil, then a string which matches that regexp may also precede
the open-parenthesis. If defun-prompt-regexp and
open-paren-in-column-0-is-defun-start are both nil, this
function instead finds an open-paren at the outermost level.
If the variable beginning-of-defun-function is non-nil, its
value is called as a function, with argument ARG, to find the
defun's beginning.
Regardless of the values of defun-prompt-regexp and
beginning-of-defun-function, point always moves to the
beginning of the line whenever the search is successful.
Probably introduced at or before Emacs version 22.1.
Key Bindings
Aliases
tcl-beginning-of-defun (obsolete since 28.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp.el.gz
(defun beginning-of-defun (&optional arg)
"Move backward to the beginning of a defun.
With ARG, do it that many times. Negative ARG means move forward
to the ARGth following beginning of defun.
If search is successful, return t; point ends up at the beginning
of the line where the search succeeded. Otherwise, return nil.
When `open-paren-in-column-0-is-defun-start' is non-nil, a defun
is assumed to start where there is a char with open-parenthesis
syntax at the beginning of a line. If `defun-prompt-regexp' is
non-nil, then a string which matches that regexp may also precede
the open-parenthesis. If `defun-prompt-regexp' and
`open-paren-in-column-0-is-defun-start' are both nil, this
function instead finds an open-paren at the outermost level.
If the variable `beginning-of-defun-function' is non-nil, its
value is called as a function, with argument ARG, to find the
defun's beginning.
Regardless of the values of `defun-prompt-regexp' and
`beginning-of-defun-function', point always moves to the
beginning of the line whenever the search is successful."
(interactive "^p")
(or (not (eq this-command 'beginning-of-defun))
(eq last-command 'beginning-of-defun)
(and transient-mark-mode mark-active)
(push-mark))
(and (beginning-of-defun-raw arg)
(progn (beginning-of-line) t)))