Function: lisp--local-defform-body-p
lisp--local-defform-body-p is a byte-compiled function defined in
lisp-mode.el.gz.
Signature
(lisp--local-defform-body-p STATE)
Documentation
Return non-nil when at local definition body according to STATE.
STATE is the parse-partial-sexp state for current position.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mode.el.gz
(defun lisp--local-defform-body-p (state)
"Return non-nil when at local definition body according to STATE.
STATE is the `parse-partial-sexp' state for current position."
(when-let ((start-of-innermost-containing-list (nth 1 state)))
(let* ((parents (nth 9 state))
(first-cons-after (cdr parents))
(second-cons-after (cdr first-cons-after))
first-order-parent second-order-parent)
(while second-cons-after
(when (= start-of-innermost-containing-list
(car second-cons-after))
(setq second-order-parent (pop parents)
first-order-parent (pop parents)
;; Leave the loop.
second-cons-after nil))
(pop second-cons-after)
(pop parents))
(when second-order-parent
(let (local-definitions-starting-point)
(and (save-excursion
(goto-char (1+ second-order-parent))
(when-let ((head (ignore-errors
;; FIXME: This does not distinguish
;; between reading nil and a read error.
;; We don't care but still, better fix this.
(read (current-buffer)))))
(when (memq head '( cl-flet cl-labels cl-macrolet cl-flet*
cl-symbol-macrolet))
;; In what follows, we rely on (point) returning non-nil.
(setq local-definitions-starting-point
(progn
(parse-partial-sexp
(point) first-order-parent nil
;; From docstring of `parse-partial-sexp':
;; Fourth arg non-nil means stop
;; when we come to any character
;; that starts a sexp.
t)
(point))))))
(save-excursion
(when (ignore-errors
;; We rely on `backward-up-list' working
;; even when sexp is incomplete “to the right”.
(backward-up-list 2)
t)
(= local-definitions-starting-point (point))))))))))