emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3f999c0 2/3: Add support for customization group hyperlinks in do


From: Lars Ingebrigtsen
Subject: master 3f999c0 2/3: Add support for customization group hyperlinks in doc strings
Date: Sat, 4 Sep 2021 04:20:26 -0400 (EDT)

branch: master
commit 3f999c03c2842c72b832b7f59ba4c45c0ec725be
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add support for customization group hyperlinks in doc strings
    
    * lisp/help-mode.el (help-customization-group): New button.
    (help-xref-customization-group-regexp): New const.
    (help-make-xrefs): Use them to allow making customization group
    buttons.
---
 doc/lispref/tips.texi |  8 ++++++++
 etc/NEWS              |  6 ++++++
 lisp/help-mode.el     | 15 +++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index 8aa225a..f0eb107 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -755,6 +755,14 @@ anchor}.  The Info file name defaults to @samp{emacs}.  
For example,
 See Info node `Font Lock' and Info node `(elisp)Font Lock Basics'.
 @end smallexample
 
+To link to a customization group, write the single-quoted name of the
+group, preceded by @samp{customization group} (the first character in
+each word is case-insensitive).  For example,
+
+@smallexample
+See the customization group `whitespace' for details.
+@end smallexample
+
 Finally, to create a hyperlink to URLs, write the single-quoted URL,
 preceded by @samp{URL}.  For example,
 
diff --git a/etc/NEWS b/etc/NEWS
index a7b6d90..ec81541 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3443,6 +3443,12 @@ The former is now declared obsolete.
 * Lisp Changes in Emacs 28.1
 
 +++
+*** Doc strings can now link to customization groups.
+Text like "customization group 'whitespace'" will be made into a
+button.  When clicked, it'll take the user to a Custom buffer
+displaying that customization group.
+
++++
 *** New macro 'with-existing-directory'.
 This macro binds 'default-directory' to some other existing directory
 if 'default-directory' doesn't exist, and then executes the body forms.
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 87f2665..08182b7 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -228,6 +228,11 @@ The format is (FUNCTION ARGS...).")
   'help-function #'info
   'help-echo (purecopy "mouse-2, RET: read this Info node"))
 
+(define-button-type 'help-customization-group
+  :supertype 'help-xref
+  'help-function #'customize-group
+  'help-echo (purecopy "mouse-2, RET: display this customization group"))
+
 (define-button-type 'help-url
   :supertype 'help-xref
   'help-function #'browse-url
@@ -437,6 +442,10 @@ when help commands related to multilingual environment 
(e.g.,
    "\\<[Ii]nfo[ \t\n]+\\(node\\|anchor\\)[ \t\n]+['`‘]\\([^'’]+\\)['’]")
   "Regexp matching doc string references to an Info node.")
 
+(defconst help-xref-customization-group-regexp
+  (purecopy "\\<[Cc]ustomization[ \t\n]+[Gg]roup[ \t\n]+['`‘]\\([^'’]+\\)['’]")
+  "Regexp matching doc string references to a customization group.")
+
 (defconst help-xref-url-regexp
   (purecopy "\\<[Uu][Rr][Ll][ \t\n]+['`‘]\\([^'’]+\\)['’]")
   "Regexp matching doc string references to a URL.")
@@ -543,6 +552,12 @@ that."
                        (setq data ;; possible newlines if para filled
                              (replace-regexp-in-string "[ \t\n]+" " " data t 
t)))
                       (help-xref-button 2 'help-info data))))
+                ;; Customization groups.
+                (save-excursion
+                  (while (re-search-forward
+                          help-xref-customization-group-regexp nil t)
+                    (help-xref-button 1 'help-customization-group
+                                      (intern (match-string 1)))))
                 ;; URLs
                 (save-excursion
                   (while (re-search-forward help-xref-url-regexp nil t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]