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
*** 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.
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)))
result))
\f
-(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
(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].