[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 76b08a3: Teach browse-url to open man page urls
From: |
Mark Oteiza |
Subject: |
[Emacs-diffs] master 76b08a3: Teach browse-url to open man page urls |
Date: |
Fri, 21 Oct 2016 15:33:18 +0000 (UTC) |
branch: master
commit 76b08a35bb6b3b32e5e5fda53e374769ceae6ed8
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>
Teach browse-url to open man page urls
* lisp/net/browse-url.el (browse-url-man-function): New custom option.
(browse-url): Add a condition to catch links matching "^man:".
(browse-url-man): New function.
---
etc/NEWS | 4 ++++
lisp/net/browse-url.el | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 3b3164c..4e41dbb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -275,6 +275,10 @@ whose content matches a regexp; bound to '% g'.
'ibuffer-never-search-content-mode' used by
'ibuffer-mark-by-content-regexp'.
+** Browse-URL
+
+*** Support for opening links to man pages in Man or WoMan mode.
+
** Compilation mode
---
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index c0b3591..1bb4831 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -184,6 +184,15 @@ be used instead."
:version "24.1"
:group 'browse-url)
+(defcustom browse-url-man-function 'browse-url-man
+ "Function to display man: links."
+ :type '(radio
+ (function-item :tag "Emacs Man" :value browse-url-man)
+ (const :tag "None" nil)
+ (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 +810,8 @@ as ARGS."
(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 +1599,19 @@ used instead of `browse-url-new-window-flag'."
(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))
+ (cond
+ ((executable-find manual-program) (man url))
+ (t (woman (replace-regexp-in-string "([[:alnum:]]+)" "" url)))))
+
;; --- Random browser ---
;;;###autoload
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 76b08a3: Teach browse-url to open man page urls,
Mark Oteiza <=