Function: add-log-current-defun
add-log-current-defun is an autoloaded and byte-compiled function
defined in add-log.el.gz.
Signature
(add-log-current-defun)
Documentation
Return name of function definition point is in, or nil.
Understands C, Lisp, LaTeX ("functions" are chapters, sections, ...), Texinfo (@node titles) and Perl.
Other modes are handled by a heuristic that looks in the 10K before
point for uppercase headings starting in the first column or
identifiers followed by : or =. See variables
add-log-current-defun-header-regexp and
add-log-current-defun-function.
Has a preference of looking backwards.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/add-log.el.gz
;;;###autoload
(defun add-log-current-defun ()
"Return name of function definition point is in, or nil.
Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
Texinfo (@node titles) and Perl.
Other modes are handled by a heuristic that looks in the 10K before
point for uppercase headings starting in the first column or
identifiers followed by `:' or `='. See variables
`add-log-current-defun-header-regexp' and
`add-log-current-defun-function'.
Has a preference of looking backwards."
(condition-case nil
(save-excursion
(if add-log-current-defun-function
(funcall add-log-current-defun-function)
;; If all else fails, try heuristics
(let (case-fold-search
result)
(end-of-line)
(when (re-search-backward add-log-current-defun-header-regexp
(- (point) 10000) t)
(setq result (or (match-string-no-properties 1)
(match-string-no-properties 0)))
;; Strip whitespace away
(when (string-match "\\([^ \t\n\r\f].*[^ \t\n\r\f]\\)"
result)
(setq result (match-string-no-properties 1 result)))
result))))
(error nil)))