[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4f3c1eb4c5 2/3: Respect no-face argument in literal key substitut
From: |
Stefan Kangas |
Subject: |
master 4f3c1eb4c5 2/3: Respect no-face argument in literal key substitutions |
Date: |
Sat, 18 Jun 2022 13:59:29 -0400 (EDT) |
branch: master
commit 4f3c1eb4c5c1404c2f2726e36a4803f4fd6257b1
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>
Respect no-face argument in literal key substitutions
* lisp/help.el (substitute-command-keys): Respect 'no-face' argument
also in literal key substitutions.
* test/lisp/help-tests.el
(help-tests-substitute-key-bindings/help-key-binding-face): Rename
from help-tests-substitute-key-bindings/face-help-key-binding.
(help-tests-substitute-key-bindings/help-key-binding-no-face): New test.
---
lisp/help.el | 7 ++++---
test/lisp/help-tests.el | 18 +++++++++++++-----
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/lisp/help.el b/lisp/help.el
index 766bae0845..2d02b22e52 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1176,9 +1176,10 @@ Otherwise, return a new string."
((and (not (string-match-p "\\`M-x " k))
(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)))
+ (unless no-face
+ (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
diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el
index 9c9dddcd19..14a1fb49ae 100644
--- a/test/lisp/help-tests.el
+++ b/test/lisp/help-tests.el
@@ -100,11 +100,19 @@
(should-error (substitute-command-keys "\\`c-c'"))
(should-error (substitute-command-keys "\\`<foo bar baz>'")))
-(ert-deftest help-tests-substitute-key-bindings/face-help-key-binding ()
- (should (eq (get-text-property 0 'face (substitute-command-keys
"\\[next-line]"))
- 'help-key-binding))
- (should (eq (get-text-property 0 'face (substitute-command-keys "\\`f'"))
- 'help-key-binding)))
+(ert-deftest help-tests-substitute-key-bindings/help-key-binding-face ()
+ (let ((A (substitute-command-keys "\\[next-line]"))
+ (B (substitute-command-keys "\\`f'")))
+ (should (eq (get-text-property 0 'face A) 'help-key-binding))
+ (should (eq (get-text-property 0 'face B) 'help-key-binding))))
+
+(ert-deftest help-tests-substitute-key-bindings/help-key-binding-no-face ()
+ (let ((A (substitute-command-keys "\\[next-line]" t))
+ (B (substitute-command-keys "\\`f'" t)))
+ (should (eq (get-text-property 0 'face A) nil))
+ (should (eq (get-text-property 0 'face B) nil))
+ (should (equal A "C-n"))
+ (should (equal B "f"))))
(defvar-keymap help-tests--test-keymap
:doc "Just some keymap for testing."