Преглед на файлове

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.
stardiviner преди 4 години
родител
ревизия
3b10ffc362
променени са 1 файла, в които са добавени 11 реда и са изтрити 2 реда
  1. 11 2
      contrib/lisp/ol-man.el

+ 11 - 2
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."