From dcb9246ce948ce5d409c4f1e6d3e0ab53ed2ff4d Mon Sep 17 00:00:00 2001 From: stardiviner Date: Fri, 14 Aug 2020 12:33:51 +0800 Subject: [PATCH] ol-man.el: Add occur searching in man page buffer * contrib/lisp/ol-man.el (org-man-open): Support auto searching man page buffer with occur. --- contrib/lisp/ol-man.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/ol-man.el b/contrib/lisp/ol-man.el index 5cb7e0155..8ad1fabb2 100644 --- a/contrib/lisp/ol-man.el +++ b/contrib/lisp/ol-man.el @@ -37,8 +37,15 @@ (defcustom org-man-command 'man (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) + (with-current-buffer (concat "*Man " command "*") + (occur search)))) (defun org-man-store-link () "Store a link to a README file." -- 2.27.0