summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-11-22 06:44:10 +0100
committerStefan Kangas <stefan@marxist.se>2021-11-22 06:44:10 +0100
commit1aef1a6673bc29784effe10d2e01e62b49c0112c (patch)
treef8c0e96c0d36d4a1606740aadb2d427901423424 /lisp
parent5fcff0d2cbe33faef8bbb753a5f02fb26b1d7e5c (diff)
downloademacs-1aef1a6673bc29784effe10d2e01e62b49c0112c.tar.gz
emacs-1aef1a6673bc29784effe10d2e01e62b49c0112c.tar.bz2
emacs-1aef1a6673bc29784effe10d2e01e62b49c0112c.zip
Add new format for literal key sequences to substitute-command-keys
* lisp/help.el (substitute-command-keys): Add new format "\\`f'" for literal key sequences. (Bug#50804) * doc/lispref/help.texi (Keys in Documentation): Document the above new substitution. * test/lisp/help-tests.el (help-tests-substitute-command-keys/literal-key-sequence): (help-tests-substitute-command-keys/literal-key-sequence-errors): New tests. (help-tests-substitute-key-bindings/face-help-key-binding): Extend test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/help.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/help.el b/lisp/help.el
index bc3d4773dad..9122d96271d 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1078,6 +1078,9 @@ 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'.
+Each substring of the form \\\\=`KEYBINDING' will be replaced by
+KEYBINDING and use the `help-key-binding' face.
+
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
produced by ‘describe-bindings’. The summary ends in two newlines
@@ -1130,6 +1133,23 @@ Otherwise, return a new string."
(delete-char 2)
(ignore-errors
(forward-char 1)))
+ ((and (= (following-char) ?`)
+ (save-excursion
+ (prog1 (search-forward "'" nil t)
+ (setq end-point (- (point) 2)))))
+ (goto-char orig-point)
+ (delete-char 2)
+ (goto-char (1- end-point))
+ (delete-char 1)
+ ;; (backward-char 1)
+ (let ((k (buffer-substring-no-properties orig-point (point))))
+ (cond ((= (length k) 0)
+ (error "Empty key sequence in substitution"))
+ ((not (key-valid-p k))
+ (error "Invalid key sequence in substitution: `%s'" k))))
+ (add-text-properties orig-point (point)
+ '( face help-key-binding
+ font-lock-face help-key-binding)))
;; 1C. \[foo] is replaced with the keybinding.
((and (= (following-char) ?\[)
(save-excursion