emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] improve ol-man.el with occur searching
@ 2020-08-14  4:41 numbchild
  2020-08-16  9:54 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: numbchild @ 2020-08-14  4:41 UTC (permalink / raw)
  To: Org-mode


[-- Attachment #1.1: Type: text/plain, Size: 443 bytes --]

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.

[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/

[-- Attachment #1.2: Type: text/html, Size: 1208 bytes --]

[-- Attachment #2: 0001-ol-man.el-Add-occur-searching-in-man-page-buffer.patch --]
[-- Type: text/x-patch, Size: 1263 bytes --]

From dcb9246ce948ce5d409c4f1e6d3e0ab53ed2ff4d Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] improve ol-man.el with occur searching
  2020-08-14  4:41 [PATCH] improve ol-man.el with occur searching numbchild
@ 2020-08-16  9:54 ` Nicolas Goaziou
  2020-08-17  3:22   ` numbchild
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2020-08-16  9:54 UTC (permalink / raw)
  To: numbchild@gmail.com; +Cc: Org-mode

Hello,

"numbchild@gmail.com" <numbchild@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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] improve ol-man.el with occur searching
  2020-08-16  9:54 ` Nicolas Goaziou
@ 2020-08-17  3:22   ` numbchild
  2020-08-31 10:34     ` numbchild
  2020-09-05  8:05     ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: numbchild @ 2020-08-17  3:22 UTC (permalink / raw)
  To: numbchild@gmail.com, Org-mode


[-- Attachment #1.1: Type: text/plain, Size: 1446 bytes --]

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 <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> "numbchild@gmail.com" <numbchild@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
>

[-- Attachment #1.2: Type: text/html, Size: 2596 bytes --]

[-- Attachment #2: 0001-ol-man.el-Add-searching-support-in-man-page-buffer.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]

From 73b9e6d8e229f46b9d95f666f0bfb1c2a7e3c0af Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] improve ol-man.el with occur searching
  2020-08-17  3:22   ` numbchild
@ 2020-08-31 10:34     ` numbchild
  2020-09-05  8:05     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: numbchild @ 2020-08-31 10:34 UTC (permalink / raw)
  To: numbchild@gmail.com, Org-mode

[-- Attachment #1: Type: text/plain, Size: 1875 bytes --]

Hi, Nicolas, gentle ping about this 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 Mon, Aug 17, 2020 at 11:22 AM numbchild@gmail.com <numbchild@gmail.com>
wrote:

> 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 <mail@nicolasgoaziou.fr>
> wrote:
>
>> Hello,
>>
>> "numbchild@gmail.com" <numbchild@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
>>
>

[-- Attachment #2: Type: text/html, Size: 3634 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] improve ol-man.el with occur searching
  2020-08-17  3:22   ` numbchild
  2020-08-31 10:34     ` numbchild
@ 2020-09-05  8:05     ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2020-09-05  8:05 UTC (permalink / raw)
  To: numbchild; +Cc: Org-mode

Hi,

"numbchild@gmail.com" <numbchild@gmail.com> writes:

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

Applied in master, thanks.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-05  8:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-14  4:41 [PATCH] improve ol-man.el with occur searching numbchild
2020-08-16  9:54 ` Nicolas Goaziou
2020-08-17  3:22   ` numbchild
2020-08-31 10:34     ` numbchild
2020-09-05  8:05     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).