Function: expreg--list
expreg--list is a natively compiled function defined in expreg.el.
Signature
(expreg--list &optional INHIBIT-RECURSE)
Documentation
Return a list of regions determined by sexp level.
This routine returns the following regions:
1. The list before/after point
2. The inside of the innermost enclosing list
3. The outside of every layer of enclosing list
Note that the inside of outer layer lists are not captured.
If INHIBIT-RECURSE is non-nil, it doesn’t try to narrow to the current string/comment and get lists inside.
Source Code
;; Defined in /nix/store/29cdhkmkqv2bgp3p30khhf35kkbgx1ya-emacs-packages-deps/share/emacs/site-lisp/elpa/expreg-1.4.1/expreg.el
(defun expreg--list (&optional inhibit-recurse)
"Return a list of regions determined by sexp level.
This routine returns the following regions:
1. The list before/after point
2. The inside of the innermost enclosing list
3. The outside of every layer of enclosing list
Note that the inside of outer layer lists are not captured.
If INHIBIT-RECURSE is non-nil, it doesn’t try to narrow to the
current string/comment and get lists inside."
(condition-case nil
(let (inside-results inside-string)
(when (and (not inhibit-recurse)
(or (setq inside-string (expreg--inside-string-p))
(expreg--inside-comment-p)))
;; If point is inside a string, we narrow to the inside of
;; that string and compute again.
(save-restriction
(let ((orig (point))
(string-start (expreg--start-of-comment-or-string)))
;; Narrow to inside list.
(goto-char string-start)
;; (forward-sexp)
(if inside-string
;; We could use ‘forward-sexp’, but narrowing plus
;; ‘forward-sexp’ with a treesit backend would cause
;; tree-sitter re-parse on the narrowed region and
;; then re-parse on the widened region.
(goto-char (or (scan-sexps (point) 1)
(buffer-end 1)))
(forward-comment (buffer-size)))
(if inside-string
(narrow-to-region (1+ string-start) (1- (point)))
(narrow-to-region string-start (point)))
(goto-char orig)
(setq inside-results (expreg--list t)))))
;; Normal computation.
(let ((inside-list (expreg--inside-list))
(list-at-point (expreg--list-at-point))
outside-list lst)
;; Compute outer-list.
(while (setq lst (expreg--outside-list))
(setq outside-list
(nconc lst outside-list)))
(nconc inside-results inside-list list-at-point outside-list)))
(scan-error nil)))