Use a widget for the face link in Customize buffers

* doc/lispref/customize.texi (Common Keywords): Document it.

* lisp/cus-edit.el (custom-face-value-create): Use a widget
instead of a button so that TAB works (bug#20664).

* lisp/wid-edit.el (face-link): New widget.
(widget-face-link-action): New action.
This commit is contained in:
Lars Ingebrigtsen 2020-09-18 13:28:12 +02:00
parent b23beef3f2
commit 635666e7bf
3 changed files with 22 additions and 3 deletions

View file

@ -124,6 +124,11 @@ Link to the documentation of a variable; @var{variable} is a string
which specifies the name of the variable to describe with
@code{describe-variable} when the user invokes this link.
@item (face-link @var{face})
Link to the documentation of a face; @var{face} is a string which
specifies the name of the face to describe with @code{describe-face}
when the user invokes this link.
@item (custom-group-link @var{group})
Link to another customization group. Invoking it creates a new
customization buffer for @var{group}.

View file

@ -3571,9 +3571,13 @@ the present value is saved to its :shown-value property instead."
buttons)
;; Face name (tag).
(insert " ")
(insert-text-button tag
'action (lambda (&rest _x)
(find-face-definition symbol)))
(push (widget-create-child-and-convert
widget 'face-link
:button-face 'link
:tag tag
:action (lambda (&rest _x)
(find-face-definition symbol)))
buttons)
(insert
(cond ((eq custom-buffer-style 'face) " ")
((string-match-p "face\\'" tag) ":")

View file

@ -1917,6 +1917,16 @@ If END is omitted, it defaults to the length of LIST."
"Show the variable specified by WIDGET."
(describe-variable (widget-value widget)))
;;; The `face-link' Widget.
(define-widget 'face-link 'link
"A link to an Emacs face."
:action 'widget-face-link-action)
(defun widget-face-link-action (widget &optional _event)
"Show the variable specified by WIDGET."
(describe-face (widget-value widget)))
;;; The `file-link' Widget.
(define-widget 'file-link 'link