ol-man.el: Add searching support in man page buffer

* contrib/lisp/ol-man.el (org-man-open): Support auto searching man page
buffer with search-forward.
This commit is contained in:
stardiviner 2020-08-14 12:37:42 +08:00 committed by Bastien
parent 4710541365
commit 3b10ffc362
1 changed files with 11 additions and 2 deletions

View File

@ -37,8 +37,17 @@
(defun org-man-open (path _)
"Visit the manpage on PATH.
PATH should be a topic that can be thrown at the man command."
(funcall org-man-command 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."
(string-match "\\(.*?\\)\\(?:::\\(.*\\)\\)?$" path)
(let* ((command (match-string 1 path))
(search (match-string 2 path)))
(funcall org-man-command command)
(when search
(with-current-buffer (concat "*Man " command "*")
(goto-char (point-min))
(search-forward search)))))
(defun org-man-store-link ()
"Store a link to a README file."