summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstardiviner <numbchild@gmail.com>2020-08-14 12:37:42 +0800
committerBastien <bzg@gnu.org>2020-09-05 10:05:01 +0200
commit3b10ffc3624d740a4ef71021c286fac11214b8b7 (patch)
treebe3f2e5bc45bae929b91d8dfe523fd4c13f1b5e0
parent47105413657dd4986c2402b6250f06e56530b644 (diff)
downloadorg-mode-3b10ffc3624d740a4ef71021c286fac11214b8b7.tar.gz
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.
-rw-r--r--contrib/lisp/ol-man.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/contrib/lisp/ol-man.el b/contrib/lisp/ol-man.el
index 5cb7e01..b21ed9e 100644
--- a/contrib/lisp/ol-man.el
+++ b/contrib/lisp/ol-man.el
@@ -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."