Function: outline--setup-from-comment-regexp

outline--setup-from-comment-regexp is a byte-compiled function defined in outline.el.gz.

Signature

(outline--setup-from-comment-regexp)

Documentation

Configure outline heading recognition for comment-prefixed headings.

Called from outline-minor-mode(var)/outline-minor-mode(fun) on activation. Do nothing unless outline-use-comment-regexp is non-nil. Use outline-comment-regexp when it is set buffer-locally, and otherwise a default from outline--default-comment-regexp; do nothing when no comment-heading regexp is available.

Set outline-regexp and the variable outline-level(var)/outline-level(fun) from that regexp, and clear outline-search-function (which many modes set, and which would otherwise override outline-regexp). Save the previous values in outline--saved-outline-regexp, outline--saved-outline-level, and outline--saved-outline-search-function, so that outline--comment-level can defer to them and outline--restore-from-comment-regexp can restore them.

Source Code

;; Defined in /usr/src/emacs/lisp/outline.el.gz
(defun outline--setup-from-comment-regexp ()
  "Configure outline heading recognition for comment-prefixed headings.
Called from `outline-minor-mode' on activation.  Do nothing unless
`outline-use-comment-regexp' is non-nil.  Use `outline-comment-regexp'
when it is set buffer-locally, and otherwise a default from
`outline--default-comment-regexp'; do nothing when no comment-heading
regexp is available.

Set `outline-regexp' and the variable `outline-level' from that regexp,
and clear `outline-search-function' (which many modes set, and which
would otherwise override `outline-regexp').  Save the previous values in
`outline--saved-outline-regexp', `outline--saved-outline-level', and
`outline--saved-outline-search-function', so that `outline--comment-level'
can defer to them and `outline--restore-from-comment-regexp' can restore
them."
  (when outline-use-comment-regexp
    (when-let* ((regexp (or outline-comment-regexp
                            (outline--default-comment-regexp))))
      (unless outline--saved-outline-level
        (setq outline--saved-outline-regexp outline-regexp
              outline--saved-outline-level outline-level
              outline--saved-outline-search-function outline-search-function))
      (setq outline--comment-regexp regexp)
      (setq-local outline-regexp regexp)
      (setq-local outline-level #'outline--comment-level)
      (setq-local outline-search-function nil))))