From b374d99ae7e9d16a99ce6a178ab06ab3d5634044 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 13 Mar 2018 17:03:11 +0100 Subject: [PATCH] Hide URL and Info node markup in help buffers * lisp/help-mode.el (help-mode-hide-markup): New custom variable. (help-make-xrefs): Make URL and Info node markup invisible. * etc/NEWS: Describe help markup hiding changes. * doc/lispref/tips.texi (Documentation Tips): Document 'help-mode-hide-markup' --- doc/lispref/tips.texi | 7 +++++++ etc/NEWS | 5 +++++ lisp/help-mode.el | 22 +++++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi index c62cfcfa8f..3a623541e5 100644 --- a/doc/lispref/tips.texi +++ b/doc/lispref/tips.texi @@ -756,6 +756,13 @@ Documentation Tips `https://www.gnu.org/'). @end smallexample +@vindex help-mode-hide-markup +By default, the prefixes that are used to indicate Info and URL +hyperlinks (such as @samp{Info node} and @samp{URL}) are hidden when +the documentation string is displayed. This behavior can be changed +by customizing @code{help-mode-hide-markup} to +@code{nil}. + @item Don't write key sequences directly in documentation strings. Instead, use the @samp{\\[@dots{}]} construct to stand for them. For example, diff --git a/etc/NEWS b/etc/NEWS index 57236b52f0..bdefc0970c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -202,6 +202,11 @@ and commands in the same format as the edit buffer of the buffer generated by 'view-lossage' to the "*Edit Macro*" buffer created by 'edit-last-kbd-macro', and to save the macro by 'C-c C-c'. ++++ +*** New variable 'help-mode-hide-markup'. +When non-nil, help-mode buffers will not display the 'Info node' and +'URL' prefixes to hyperlinks. Default is t. + ** Ibuffer --- diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 4fb3fb85c9..bca160a7d2 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -98,6 +98,14 @@ help-mode-hook "Hook run by `help-mode'." :type 'hook :group 'help) + +(defcustom help-mode-hide-markup t + "If non-nil, hide markup used for Info and URL links. +Otherwise, show explicit 'Info node' and 'URL' markup in help +buffers." + :version "27.1" + :type 'boolean + :group 'help) ;; Button types used by help @@ -470,17 +478,25 @@ help-make-xrefs ;; Info references (save-excursion (while (re-search-forward help-xref-info-regexp nil t) - (let ((data (match-string 2))) + (let ((data (match-string 2)) + (beg (match-beginning 0)) + (end (match-beginning 2))) (save-match-data (unless (string-match "^([^)]+)" data) (setq data (concat "(emacs)" data))) (setq data ;; possible newlines if para filled - (replace-regexp-in-string "[ \t\n]+" " " data t t))) + (replace-regexp-in-string "[ \t\n]+" " " data t t)) + (when help-mode-hide-markup + (put-text-property beg end 'invisible t))) (help-xref-button 2 'help-info data)))) ;; URLs (save-excursion (while (re-search-forward help-xref-url-regexp nil t) - (let ((data (match-string 1))) + (let ((data (match-string 1)) + (beg (match-beginning 0)) + (end (match-beginning 1))) + (when help-mode-hide-markup + (put-text-property beg end 'invisible t)) (help-xref-button 1 'help-url data)))) ;; Mule related keywords. Do this before trying ;; `help-xref-symbol-regexp' because some of Mule -- 2.16.1.72.g5be1f00a9