master e13fb667a21: Support OSC 8 hyperlinks in man pages
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit e13fb667a2179548a1b57bf1e345b5a1dc00bb24 Author: Zhengyi Fu <[email protected]> Commit: Eli Zaretskii <[email protected]> Support OSC 8 hyperlinks in man pages * lisp/man.el: Require `ansi-osc'. (Man-ansi-osc-handlers): New variable. (Man-fontify-manpage): Call ansi-osc-apply-on-region to buttonize OSC 8 hyperlinks. (Bug#81240) * etc/NEWS: Announce the new feature. --- etc/NEWS | 7 +++++++ lisp/man.el | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 60f4327d4eb..a13e556fa47 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -101,6 +101,13 @@ check out the repository to prepare a patch for the package maintainer. --- *** Messages from Ansible are now recognized. +** Man + +--- +*** OSC 8 hyperlinks in man pages are now buttonized. +When a man page contains OSC 8 hyperlink escape sequences, they +are now buttonized, allowing using mouse or 'RET' to follow them. + ** VC +++ diff --git a/lisp/man.el b/lisp/man.el index 3b59efa0a44..c49c4da8f04 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -88,6 +88,7 @@ ;;; Code: (require 'ansi-color) +(require 'ansi-osc) (require 'cl-lib) (defgroup man nil @@ -155,6 +156,9 @@ set `Man-ansi-color-basic-faces-vector'.") (make-obsolete-variable 'Man-ansi-color-map 'Man-ansi-color-basic-faces-vector "28.1") +(defvar Man-ansi-osc-handlers '(("8" . ansi-osc-hyperlink-handler)) + "The value used here for `ansi-osc-handlers'.") + (defcustom Man-notify-method 'friendly "Selects the behavior when manpage is ready. This variable may have one of the following values, where (sf) means @@ -1377,6 +1381,8 @@ Same for the ANSI bold and normal escape sequences." (let ((ansi-color-apply-face-function #'ansi-color-apply-text-property-face) (ansi-color-basic-faces-vector Man-ansi-color-basic-faces-vector)) (ansi-color-apply-on-region (point-min) (point-max))) + (let ((ansi-osc-handlers Man-ansi-osc-handlers)) + (ansi-osc-apply-on-region (point-min) (point-max))) ;; Other highlighting. (let ((buffer-undo-list t)) (if (< (buffer-size) (position-bytes (point-max)))