Fix mode-line display in Calendar mode
* lisp/help.el (substitute-command-keys): New optional argument NO-FACE, to avoid putting the 'help-key-binding' face on the key bindings. * lisp/calendar/calendar.el (calendar-mode-line-entry): Call 'substitute-command-keys' with the new optional argument non-nil. (Bug#52366) * doc/lispref/help.texi (Keys in Documentation): Document the new optional argument of 'substitute-command-keys'. * etc/NEWS: Announce the addition of a new argument to 'substitute-command-keys'.
This commit is contained in:
parent
c8c7822c51
commit
538fc1d0e0
4 changed files with 22 additions and 10 deletions
|
@ -372,11 +372,15 @@ quotes. You can customize it freely according to your personal
|
|||
preference.
|
||||
@end defopt
|
||||
|
||||
@defun substitute-command-keys string
|
||||
@defun substitute-command-keys string &optional no-face
|
||||
@vindex help-key-binding@r{ (face)}
|
||||
This function scans @var{string} for the above special sequences and
|
||||
replaces them by what they stand for, returning the result as a string.
|
||||
This permits display of documentation that refers accurately to the
|
||||
user's own customized key bindings.
|
||||
user's own customized key bindings. By default, the key bindings are
|
||||
given a special face @code{help-key-binding}, but if the optional
|
||||
argument @var{no-face} is non-@code{nil}, the function doesn't add
|
||||
this face to the produced string.
|
||||
|
||||
@cindex advertised binding
|
||||
If a command has multiple bindings, this function normally uses the
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -635,7 +635,9 @@ This works like 'C-u M-x apropos-command' but is more discoverable.
|
|||
*** Keybindings in 'help-mode' use the new 'help-key-binding' face.
|
||||
This face is added by 'substitute-command-keys' to any "\[command]"
|
||||
substitution. The return value of that function should consequently
|
||||
be assumed to be a propertized string.
|
||||
be assumed to be a propertized string. To prevent the function from
|
||||
adding the 'help-key-binding' face, call 'substitute-command-keys'
|
||||
with the new optional argument NO-FACE non-nil.
|
||||
|
||||
Note that the new face will also be used in tooltips. When using the
|
||||
GTK toolkit, this is only true if 'x-gtk-use-system-tooltips' is t.
|
||||
|
|
|
@ -1723,7 +1723,8 @@ COMMAND is a command to run, ECHO is the help-echo text, KEY
|
|||
is COMMAND's keybinding, STRING describes the binding."
|
||||
(propertize (or key
|
||||
(substitute-command-keys
|
||||
(format "\\<calendar-mode-map>\\[%s] %s" command string)))
|
||||
(format "\\<calendar-mode-map>\\[%s] %s" command string)
|
||||
'hands-off-my-face))
|
||||
'help-echo (format "mouse-1: %s" echo)
|
||||
'mouse-face 'mode-line-highlight
|
||||
'keymap (make-mode-line-mouse-map 'mouse-1 command)))
|
||||
|
|
17
lisp/help.el
17
lisp/help.el
|
@ -1060,11 +1060,12 @@ is currently activated with completion."
|
|||
result))
|
||||
|
||||
|
||||
(defun substitute-command-keys (string)
|
||||
(defun substitute-command-keys (string &optional no-face)
|
||||
"Substitute key descriptions for command names in STRING.
|
||||
Each substring of the form \\\\=[COMMAND] is replaced by either a
|
||||
keystroke sequence that invokes COMMAND, or \"M-x COMMAND\" if COMMAND
|
||||
is not on any keys. Keybindings will use the face `help-key-binding'.
|
||||
is not on any keys. Keybindings will use the face `help-key-binding',
|
||||
unless the optional argument NO-FACE is non-nil.
|
||||
|
||||
Each substring of the form \\\\={MAPVAR} is replaced by a summary of
|
||||
the value of MAPVAR as a keymap. This summary is similar to the one
|
||||
|
@ -1141,13 +1142,17 @@ Otherwise, return a new string."
|
|||
(let ((op (point)))
|
||||
(insert "M-x ")
|
||||
(goto-char (+ end-point 3))
|
||||
(add-text-properties op (point)
|
||||
'( face help-key-binding
|
||||
font-lock-face help-key-binding))
|
||||
(or no-face
|
||||
(add-text-properties
|
||||
op (point)
|
||||
'( face help-key-binding
|
||||
font-lock-face help-key-binding)))
|
||||
(delete-char 1))
|
||||
;; Function is on a key.
|
||||
(delete-char (- end-point (point)))
|
||||
(insert (help--key-description-fontified key)))))
|
||||
(insert (if no-face
|
||||
(key-description key)
|
||||
(help--key-description-fontified key))))))
|
||||
;; 1D. \{foo} is replaced with a summary of the keymap
|
||||
;; (symbol-value foo).
|
||||
;; \<foo> just sets the keymap used for \[cmd].
|
||||
|
|
Loading…
Add table
Reference in a new issue