emacs-devel
[Top][All Lists]
Advanced

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

Re: Consistent face for keys in *Help* and `substitute-command-keys'


From: Stefan Kangas
Subject: Re: Consistent face for keys in *Help* and `substitute-command-keys'
Date: Fri, 5 Mar 2021 10:18:25 -0600

Eli Zaretskii <eliz@gnu.org> writes:

>> Could we just use `add-face-text-property' here, perhaps?
>>
>> It seems to do what we want:
>>
>>     (let ((foo "x") bar)
>>       (add-face-text-property 0 (length foo) 'bold nil foo)
>>       (setq bar (concat "y" foo "y"))
>>       (add-face-text-property 0 (length bar) 'italic nil bar)
>>       bar)
>>
>>     => #("yxy" 0 1 (face italic) 1 2 (face (italic bold)) 2 3 (face italic))
>
> That's because you add a property which was unspecified by the
> original face.  But in the tooltip case, the function tooltip-show
> propertizes the entire text it receives with the 'tooltip' face, so
> any face attributes in the text that are also specified by the
> 'tooltip' face will be overwritten.  So, for example, if the tooltip
> text had a :background attribute, that attribute would be overwritten
> by the background color of the 'tooltip' face.  Isn't that what you
> see?

But that just comes down to which face takes priority, right?  So if we
we would need to set the APPEND argument of `add-face-text-property' to
t.

See the attached latest version of the patch, which seems to work as
you'd expect: the `help-key-binding' face overrides any attributes in
the `tooltip' face (tested using --with-x-toolkit={no,lucid}).

The interesting part for tooltips is:

modified   lisp/tooltip.el
@@ -248,7 +248,8 @@ tooltip-show
            (setf (alist-get 'border-color params) fg))
          (when (stringp bg)
            (setf (alist-get 'background-color params) bg))
-         (x-show-tip (propertize text 'face 'tooltip)
+          (add-face-text-property 0 (length text) 'tooltip t text)
+          (x-show-tip text
                      (selected-frame)
                      params

Unless I am missing something, I think this is what we want here.

Attachment: 0001-Colorize-keybindings-in-help.patch
Description: Text Data


reply via email to

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