Function: org-man-open
org-man-open is a byte-compiled function defined in ol-man.el.gz.
Signature
(org-man-open PATH _)
Documentation
Visit the manpage on PATH.
PATH should be a topic that can be thrown at the man command.
If PATH contains extra ::STRING which will use occur to search
matched strings in man buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ol-man.el.gz
(defun org-man-open (path _)
"Visit the manpage on PATH.
PATH should be a topic that can be thrown at the man command.
If PATH contains extra ::STRING which will use `occur' to search
matched strings in man buffer."
(require 'man) ; For `Man-translate-references'
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
(let* ((command (match-string 1 path))
;; FIXME: Remove after we drop Emacs 29 support.
;; Working around security bug #66390.
(command (if (not (equal (Man-translate-references ";id") ";id"))
;; We are on Emacs that escapes man command args
;; (see Emacs commit 820f0793f0b).
command
;; Older Emacs without the fix - escape the
;; arguments ourselves.
(mapconcat 'identity
(mapcar #'shell-quote-argument
(split-string command "\\s-+"))
" ")))
(search (match-string 2 path))
(buffer (funcall org-man-command command)))
(when search
(with-current-buffer buffer
(goto-char (point-min))
(unless (search-forward search nil t)
(let ((process (get-buffer-process buffer)))
(while (process-live-p process)
(accept-process-output process)))
(goto-char (point-min))
(search-forward search))
(forward-line -1)
(let ((point (point)))
(let ((window (get-buffer-window buffer)))
(set-window-point window point)
(set-window-start window point)))))))