result))
amaps))
(maps orig-maps)
- (print-title (or maps always-title)))
- ;; Print title.
- (when print-title
- (insert (concat (if title
- (concat title
- (if prefix
- (concat " Starting With "
- (help--key-description-fontified prefix)))
- ":\n"))
- "key binding\n"
- "--- -------\n")))
+ (print-title (or maps always-title))
+ (start-point (point)))
;; Describe key bindings.
(setq help--keymaps-seen nil)
(while (consp maps)
(describe-map (cdr elt) elt-prefix transl partial
sub-shadows no-menu mention-shadow)))
(setq maps (cdr maps)))
- (when print-title
- (insert "\n"))))
+ ;; Print title...
+ (when (and print-title
+ ;; ... unless the keymap was empty.
+ (/= (point) start-point))
+ (save-excursion
+ (goto-char start-point)
+ (when (eolp)
+ (delete-region (point) (1+ (point))))
+ (insert
+ (concat
+ (if title
+ (concat title
+ (if prefix
+ (concat " Starting With "
+ (help--key-description-fontified prefix)))
+ ":\n"))
+ "\nkey binding\n"
+ (make-separator-line)))))))
(defun help--shadow-lookup (keymap key accept-default remap)
"Like `lookup-key', but with command remapping.
(ert-deftest help-tests-substitute-command-keys/keymaps ()
(with-substitute-command-keys-test
(test "\\{minibuffer-local-must-match-map}"
- "\
+ "
key binding
---- -------
-
+-------------------------------------------------------------------------------
C-g abort-minibuffers
TAB minibuffer-complete
C-j minibuffer-complete-and-exit
M-s next-matching-history-element
M-g M-c switch-to-completions
-
")))
(ert-deftest help-tests-substitute-command-keys/keymap-change ()
(with-temp-buffer
(help-tests-major-mode)
(test "\\{help-tests-major-mode-map}"
- "\
+ "
key binding
---- -------
-
+-------------------------------------------------------------------------------
( .. ) short-range
1 .. 4 foo-range
a .. c foo-other-range
C-e foo-something
x foo-original
<F1> foo-function-key1
-
"))))
(ert-deftest help-tests-substitute-command-keys/shadow ()
(help-tests-major-mode)
(help-tests-minor-mode)
(test "\\{help-tests-major-mode-map}"
- "\
+ "
key binding
---- -------
-
+-------------------------------------------------------------------------------
( .. ) short-range
1 .. 4 foo-range
a .. c foo-other-range
x foo-original
(this binding is currently shadowed)
<F1> foo-function-key1
-
"))))
(ert-deftest help-tests-substitute-command-keys/command-remap ()
(help-tests-major-mode)
(define-key help-tests-major-mode-map [remap foo] 'bar)
(test "\\{help-tests-major-mode-map}"
- "\
+ "
key binding
---- -------
-
+-------------------------------------------------------------------------------
<remap> Prefix Command
<remap> <foo> bar
-
")))))
(ert-deftest help-tests-describe-map-tree/no-menu-t ()
:enable mark-active
:help "Help text"))))))
(describe-map-tree map nil nil nil nil t nil nil nil)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-a foo
-
")))))
(ert-deftest help-tests-describe-map-tree/no-menu-nil ()
:enable mark-active
:help "Help text"))))))
(describe-map-tree map nil nil nil nil nil nil nil nil)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-a foo
<menu-bar> Prefix Command
<menu-bar> <foo> foo
-
")))))
(ert-deftest help-tests-describe-map-tree/mention-shadow-t ()
(2 . bar))))
(shadow-maps '((keymap . ((1 . baz))))))
(describe-map-tree map t shadow-maps nil nil t nil nil t)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-a foo
(this binding is currently shadowed)
C-b bar
-
")))))
(ert-deftest help-tests-describe-map-tree/mention-shadow-nil ()
(2 . bar))))
(shadow-maps '((keymap . ((1 . baz))))))
(describe-map-tree map t shadow-maps nil nil t nil nil nil)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-b bar
-
")))))
(ert-deftest help-tests-describe-map-tree/partial-t ()
(map '(keymap . ((1 . foo)
(2 . undefined)))))
(describe-map-tree map t nil nil nil nil nil nil nil)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-a foo
-
")))))
(ert-deftest help-tests-describe-map-tree/partial-nil ()
(map '(keymap . ((1 . foo)
(2 . undefined)))))
(describe-map-tree map nil nil nil nil nil nil nil nil)
- (should (equal (buffer-string) "key binding
---- -------
-
+ (should (equal (buffer-string) "
+key binding
+-------------------------------------------------------------------------------
C-a foo
C-b undefined
-
")))))
(defvar help-tests--was-in-buffer nil)