* [PATCH] teach browse-url about man pages
@ 2016-10-15 1:14 Mark Oteiza
2016-10-15 1:50 ` Clément Pit--Claudel
2016-10-15 6:01 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: Mark Oteiza @ 2016-10-15 1:14 UTC (permalink / raw)
To: emacs-devel
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] teach browse-url about man pages
2016-10-15 1:14 [PATCH] teach browse-url about man pages Mark Oteiza
@ 2016-10-15 1:50 ` Clément Pit--Claudel
2016-10-15 6:01 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Clément Pit--Claudel @ 2016-10-15 1:50 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 148 bytes --]
Neat :)
On 2016-10-14 21:14, Mark Oteiza wrote:
> + (_ (apply 'browse-url-man-viewer url))))
Do you need the quote there?
Clément.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] teach browse-url about man pages
2016-10-15 1:14 [PATCH] teach browse-url about man pages Mark Oteiza
2016-10-15 1:50 ` Clément Pit--Claudel
@ 2016-10-15 6:01 ` Eli Zaretskii
2016-10-16 14:59 ` Mark Oteiza
1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2016-10-15 6:01 UTC (permalink / raw)
To: Mark Oteiza; +Cc: emacs-devel
> From: Mark Oteiza <mvoteiza@udel.edu>
> Date: Fri, 14 Oct 2016 21:14:21 -0400
>
> We should be able to browse to man page urls within emacs.
I think it would be a nice feature, yes.
> 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.
You mean, except man.el and woman.el? I think these two should be
enough. (Actually, woman.el doesn't support many modern man pages, so
it's only a distant second.)
If you mean something else, please tell.
> - the :version
This will go to master, so the version is 26.1.
> but otherwise, pretty straightforward, mostly derived from the mailto:
> bits.
If no one objects, please push to master in a week or so.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] teach browse-url about man pages
2016-10-15 6:01 ` Eli Zaretskii
@ 2016-10-16 14:59 ` Mark Oteiza
2016-10-16 17:54 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Mark Oteiza @ 2016-10-16 14:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
On 15/10/16 at 09:01am, Eli Zaretskii wrote:
> > From: Mark Oteiza <mvoteiza@udel.edu>
> > Date: Fri, 14 Oct 2016 21:14:21 -0400
> >
> > 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.
>
> You mean, except man.el and woman.el? I think these two should be
> enough. (Actually, woman.el doesn't support many modern man pages, so
> it's only a distant second.)
>
> If you mean something else, please tell.
I meant instead of man(1). I'm aware of xorg-xman, but that looks quite
crusty. I'm not going to worry about it--the other variable can be
added later, if ever needed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] teach browse-url about man pages
2016-10-16 14:59 ` Mark Oteiza
@ 2016-10-16 17:54 ` Eli Zaretskii
0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2016-10-16 17:54 UTC (permalink / raw)
To: Mark Oteiza; +Cc: emacs-devel
> Date: Sun, 16 Oct 2016 10:59:04 -0400
> From: Mark Oteiza <mvoteiza@udel.edu>
> Cc: emacs-devel@gnu.org
>
> > > - whether something like browse-url-man-viewer should be added. Are
> > > there some other commonly used man page reader? I don't know.
> >
> > You mean, except man.el and woman.el? I think these two should be
> > enough. (Actually, woman.el doesn't support many modern man pages, so
> > it's only a distant second.)
> >
> > If you mean something else, please tell.
>
> I meant instead of man(1).
The stand-alone Info reader can display man pages, but it calls 'man'
for that and displays what 'man' outputs.
I'm not aware of any others.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-16 17:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-15 1:14 [PATCH] teach browse-url about man pages Mark Oteiza
2016-10-15 1:50 ` 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
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.