Function: hyrolo--pre-display-buffer

hyrolo--pre-display-buffer is a byte-compiled function defined in hyrolo.el.

Signature

(hyrolo--pre-display-buffer &optional SRC-BUF)

Documentation

Setup the HyRolo display buffer before modifications are made.

Set its major-mode to be the same as optional SRC-BUF or if null, look up the major-mode from a cache. Add hyrolo-hdr-regexp to hyrolo-hdr-and-entry-regexp and outline-regexp. When major-mode is markdown-mode, set outline-level(var)/outline-level(fun) and hyrolo-entry-regexp.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hyrolo.el
(defun hyrolo--pre-display-buffer (&optional src-buf)
  "Setup the HyRolo display buffer before modifications are made.
Set its `major-mode' to be the same as optional SRC-BUF or if null, look up
the `major-mode' from a cache.  Add `hyrolo-hdr-regexp' to
`hyrolo-hdr-and-entry-regexp' and `outline-regexp'.  When `major-mode' is
`markdown-mode', set `outline-level' and `hyrolo-entry-regexp'."
  (with-current-buffer (get-buffer-create hyrolo-display-buffer)
    (let ((display-buf hyrolo-display-buffer))
      (unwind-protect
          (progn ;; Set `major-mode' to match `src-buf'
            (if src-buf
                (progn (delay-mode-hooks
                         (funcall (buffer-local-value 'major-mode src-buf)))
                       ;; Set local `hyrolo-source-buffer' to be the source of
                       ;; entries to add
                       (setq-local hyrolo-source-buffer src-buf))
              ;; Point may have moved, so `hyrolo-source-buffer' may not be set
              ;; properly, so set the `major-mode' via a cache lookup based on
              ;; (point).
              (delay-mode-hooks
                (funcall (hyrolo-cache-get-major-mode-from-pos (point)))))

            (unless (string-prefix-p hyrolo-hdr-regexp hyrolo-hdr-and-entry-regexp)
              (setq-local hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-hdr-and-entry-regexp)))
            (unless (string-prefix-p hyrolo-hdr-regexp outline-regexp)
              (setq-local outline-regexp (concat hyrolo-hdr-prefix-regexp outline-regexp)))
            (when (eq outline-level #'markdown-outline-level)
              (setq-local outline-level #'hyrolo-outline-level
                          hyrolo-entry-regexp "^\\([#\^L]+\\)\\([ \t\n\r]+\\)")))
        ;; unwind form
        (setq-local hyrolo-display-buffer display-buf)))))