emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "numbchild@gmail.com" <numbchild@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH] improve ol-man.el with occur searching
Date: Fri, 14 Aug 2020 12:41:00 +0800	[thread overview]
Message-ID: <CAL1eYu+71i6drtR4RjOaZSAeAp3n6Zx_mx5MuudfvDn8oDhdyw@mail.gmail.com> (raw)

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

With this patch, ol-man.el link type can be a link like this:
[[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."

             reply	other threads:[~2020-08-14  4:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14  4:41 numbchild [this message]
2020-08-16  9:54 ` [PATCH] improve ol-man.el with occur searching Nicolas Goaziou
2020-08-17  3:22   ` numbchild
2020-08-31 10:34     ` numbchild
2020-09-05  8:05     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL1eYu+71i6drtR4RjOaZSAeAp3n6Zx_mx5MuudfvDn8oDhdyw@mail.gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).