From: Mark Oteiza <mvoteiza@udel.edu>
To: emacs-devel@gnu.org
Subject: [PATCH] teach browse-url about man pages
Date: Fri, 14 Oct 2016 21:14:21 -0400 [thread overview]
Message-ID: <87y41qxvki.fsf@udel.edu> (raw)
We should be able to browse to man page urls within emacs.
Not sure about a couple things:
- whether something like browse-url-man-viewer should be added. Are
there some other commonly used man page reader? I don't know.
- the :version
but otherwise, pretty straightforward, mostly derived from the mailto:
bits.
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index c0b3591..91f6f2f 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -184,6 +184,22 @@ browse-url-mailto-function
:version "24.1"
:group 'browse-url)
+(defcustom browse-url-man-function 'browse-url-man
+ "Function to display man: links."
+ :type '(choice
+ (function-item :tag "Emacs Man" :value browse-url-man)
+ (function-item :tag "None" nil))
+ :version "26.1"
+ :group 'browse-url)
+
+(defcustom browse-url-man-viewer 'man
+ "Function to display Un*x man pages."
+ :type '(radio (function-item man)
+ (function-item woman)
+ (function :tag "Other function"))
+ :version "26.1"
+ :group 'browse-url)
+
(defcustom browse-url-netscape-program "netscape"
;; Info about netscape-remote from Karl Berry.
"The name by which to invoke Netscape.
@@ -801,6 +817,8 @@ browse-url
(let ((process-environment (copy-sequence process-environment))
(function (or (and (string-match "\\`mailto:" url)
browse-url-mailto-function)
+ (and (string-match "\\`man:" url)
+ browse-url-man-function)
browse-url-browser-function))
;; Ensure that `default-directory' exists and is readable (b#6077).
(default-directory (or (unhandled-file-name-directory default-directory)
@@ -1588,6 +1606,20 @@ browse-url-mail
(unless (bolp)
(insert "\n"))))))))
+;; --- man ---
+
+(defvar manual-program)
+
+(defun browse-url-man (url &optional _new-window)
+ "Open a man page."
+ (interactive (browse-url-interactive-arg "Man page URL: "))
+ (require 'man)
+ (setq url (replace-regexp-in-string "\\`man:" "" url))
+ (pcase browse-url-man-viewer
+ (`man (man url))
+ (`woman (woman (replace-regexp-in-string "([[:alnum:]]+)" "" url)))
+ (_ (apply 'browse-url-man-viewer url))))
+
;; --- Random browser ---
;;;###autoload
next reply other threads:[~2016-10-15 1:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-15 1:14 Mark Oteiza [this message]
2016-10-15 1:50 ` [PATCH] teach browse-url about man pages Clément Pit--Claudel
2016-10-15 6:01 ` Eli Zaretskii
2016-10-16 14:59 ` Mark Oteiza
2016-10-16 17:54 ` Eli Zaretskii
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y41qxvki.fsf@udel.edu \
--to=mvoteiza@udel.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.