[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 635666e 1/2: Use a widget for the face link in Customize buffers
From: |
Lars Ingebrigtsen |
Subject: |
master 635666e 1/2: Use a widget for the face link in Customize buffers |
Date: |
Fri, 18 Sep 2020 09:03:14 -0400 (EDT) |
branch: master
commit 635666e7bfca0117eeec6c769b02d71383607093
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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.
---
doc/lispref/customize.texi | 5 +++++
lisp/cus-edit.el | 10 +++++++---
lisp/wid-edit.el | 10 ++++++++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi
index c35444f..8591247 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -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}.
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 9626b3c..a62b623 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -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) ":")
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 5ac5277..13d850a 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -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