all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [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

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.