From: Lars Ingebrigtsen Date: Sat, 4 Sep 2021 08:19:03 +0000 (+0200) Subject: Add support for customization group hyperlinks in doc strings X-Git-Tag: emacs-28.0.90~1187 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3f999c03c2842c72b832b7f59ba4c45c0ec725be;p=emacs.git 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. --- diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi index 8aa225a00c3..f0eb1079caf 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 a7b6d904922..ec81541e655 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -3442,6 +3442,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 diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 87f26651e01..08182b71be8 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)