Function: meson-lookup-doc

meson-lookup-doc is an interactive and natively compiled function defined in meson-mode.el.

Signature

(meson-lookup-doc IDENTIFIER)

Documentation

Open Meson reference manual and find IDENTIFIER.

Return the buffer containing the reference manual. IDENTIFIER is the name of a Meson function or object as a string. Signal a user-error if the manual could not be found or does not contain IDENTIFIER.

Key Bindings

meson-mode-map <f1>

Aliases

meson-lookup-doc-at-point

Source Code

;; Defined in /nix/store/57kn62wrv0z1jads9j9blmagdm8rh132-emacs-packages-deps/share/emacs/site-lisp/elpa/meson-mode-20240601.1647/meson-mode.el
(defun meson-lookup-doc (identifier)
  "Open Meson reference manual and find IDENTIFIER.
Return the buffer containing the reference manual.
IDENTIFIER is the name of a Meson function or object as a string.
Signal a `user-error' if the manual could not be found
or does not contain IDENTIFIER."
  (interactive (list (or (thing-at-point 'symbol)
                         (meson-function-at-point)
                         (user-error "No identifier at point"))))
  (let ((buf (find-file-noselect
              (or (meson--find-reference-manual)
                  (user-error "Meson reference manual not found")))))
    (with-current-buffer buf
      ;; Set up buffer only once after creation.
      (unless (string= (buffer-name) "*Meson Reference Manual*")
        (rename-buffer "*Meson Reference Manual*" 'unique)
        (read-only-mode)
        (when (and (require 'markdown-mode nil t)
                   (fboundp 'markdown-view-mode)
                   (not (eq major-mode 'markdown-view-mode)))
          (markdown-view-mode))
        (local-set-key (kbd "q") 'bury-buffer)
        (when (bound-and-true-p evil-mode)
          (declare-function evil-local-set-key nil) ;; suppress "undeclared" warning
          (evil-local-set-key 'normal (kbd "q") 'bury-buffer)))
      (let* ((position
	      (or (meson--search-in-reference-manual identifier)
		  (user-error "%s not found in Meson reference manual" identifier)))
	     (window (display-buffer buf meson-doc-display-buffer-action)))
	(with-selected-window window
	  (goto-char position)
	  (recenter 0))))
    buf))