branch: externals/transient commit c2a75880ae7cc9f11963cc8b4f9b7ff63b7f5883 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
transient-suffix: Add FACE slot --- docs/transient.org | 4 ++++ docs/transient.texi | 5 +++++ lisp/transient.el | 13 +++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/transient.org b/docs/transient.org index e034e0fb33..8351af28bd 100644 --- a/docs/transient.org +++ b/docs/transient.org @@ -1819,6 +1819,10 @@ Also see [[*Suffix Classes]]. - ~description~ The description, either a string or a function that is called with no argument and returns a string. +- ~face~ Face used for the description. In simple cases it is easier + to use this instead of using a function as ~description~ and adding + the styling there. ~face~ is appended using ~add-face-text-property~. + - ~show-help~ A function used to display help for the suffix. If unspecified, the prefix controls how help is displayed for its suffixes. diff --git a/docs/transient.texi b/docs/transient.texi index f2dcb14c91..c20f56d799 100644 --- a/docs/transient.texi +++ b/docs/transient.texi @@ -2081,6 +2081,11 @@ It must contain the following %-placeholders: @code{description} The description, either a string or a function that is called with no argument and returns a string. +@item +@code{face} Face used for the description. In simple cases it is easier +to use this instead of using a function as @code{description} and adding +the styling there. @code{face} is appended using @code{add-face-text-property}. + @item @code{show-help} A function used to display help for the suffix. If unspecified, the prefix controls how help is displayed for its diff --git a/lisp/transient.el b/lisp/transient.el index d446b43551..dfb738f7ad 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -700,6 +700,7 @@ slot is non-nil." (transient :initarg :transient) (format :initarg :format :initform " %k %d") (description :initarg :description :initform nil) + (face :initarg :face :initform nil) (show-help :initarg :show-help :initform nil) (inapt :initform nil) (inapt-if @@ -3605,10 +3606,14 @@ Optional support for popup buttons is also implemented here." "The `description' slot may be a function, in which case that is called inside the correct buffer (see `transient--insert-group') and its value is returned to the caller." - (and-let* ((desc (oref obj description))) - (if (functionp desc) - (with-current-buffer transient--original-buffer - (funcall desc)) + (and-let* ((desc (oref obj description)) + (desc (if (functionp desc) + (with-current-buffer transient--original-buffer + (funcall desc)) + desc))) + (progn ; work around debbugs#31840 + (when-let ((face (and (slot-exists-p obj 'face) (oref obj face)))) + (add-face-text-property 0 (length desc) face t desc)) desc))) (cl-defmethod transient-format-description ((obj transient-group))