Thanks for reviewing my code and points. :)
Fixed in this attached patch.

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/


On Sun, Aug 16, 2020 at 5:54 PM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> "numbch...@gmail.com" <numbch...@gmail.com> writes:
>
> > With this patch, ol-man.el link type can be a link like this:
> > ```org
> > [[man:grep::--extended-regexp][grep --extended-regexp]]
> > ```
> > Occur will auto search "--extended-regexp" string in man page buffer.
>
> Thanks.
>
> > +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 "*")
>
> This should only be called if search is non-empty.
>
> > +      (occur search))))
>
> Why occur? Org uses `search-forward' for [[foo.org::text]] text links,
> and uses `occur' with [[foo.org::/text/]] links.
>
> Wouldn't it be more idiomatic to use a regular text search here?
>
> Regards,
> --
> Nicolas Goaziou
>
From 73b9e6d8e229f46b9d95f666f0bfb1c2a7e3c0af Mon Sep 17 00:00:00 2001
From: stardiviner <numbch...@gmail.com>
Date: Fri, 14 Aug 2020 12:37:42 +0800
Subject: [PATCH] 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.
---
 contrib/lisp/ol-man.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/contrib/lisp/ol-man.el b/contrib/lisp/ol-man.el
index 5cb7e0155..b21ed9eba 100644
--- a/contrib/lisp/ol-man.el
+++ b/contrib/lisp/ol-man.el
@@ -37,8 +37,17 @@ (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)
+    (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."
-- 
2.27.0

Reply via email to