Insert describe-map-tree header into original buffer

* lisp/help.el (describe-map-tree): Insert header into the original
buffer, not in standard-output.
* test/src/keymap-tests.el
(describe-buffer-bindings/header-in-current-buffer)
(describe-buffer-bindings/returns-nil): New tests.
Ref: https://debbugs.gnu.org/39149#31
This commit is contained in:
Stefan Kangas 2020-11-01 15:27:17 +01:00
parent 5ce37da355
commit ce1856ec09
2 changed files with 22 additions and 9 deletions

View file

@ -1169,14 +1169,14 @@ Any inserted text ends in two newlines (used by
(print-title (or maps always-title)))
;; Print title.
(when print-title
(princ (concat (if title
(concat title
(if prefix
(concat " Starting With "
(key-description prefix)))
":\n"))
"key binding\n"
"--- -------\n")))
(insert (concat (if title
(concat title
(if prefix
(concat " Starting With "
(key-description prefix)))
":\n"))
"key binding\n"
"--- -------\n")))
;; Describe key bindings.
(setq help--keymaps-seen nil)
(while (consp maps)
@ -1202,7 +1202,7 @@ Any inserted text ends in two newlines (used by
sub-shadows no-menu mention-shadow)))
(setq maps (cdr maps)))
(when print-title
(princ "\n"))))
(insert "\n"))))
(defun help--shadow-lookup (keymap key accept-default remap)
"Like `lookup-key', but with command remapping.

View file

@ -23,6 +23,19 @@
(require 'ert)
(ert-deftest describe-buffer-bindings/header-in-current-buffer ()
"Header should be inserted into the current buffer.
https://debbugs.gnu.org/39149#31"
(with-temp-buffer
(describe-buffer-bindings (current-buffer))
(should (string-match (rx bol "key" (+ space) "binding" eol)
(buffer-string)))))
(ert-deftest describe-buffer-bindings/returns-nil ()
"Should return nil."
(with-temp-buffer
(should (eq (describe-buffer-bindings (current-buffer)) nil))))
(ert-deftest keymap-store_in_keymap-XFASTINT-on-non-characters ()
"Check for bug fixed in \"Fix assertion violation in define-key\",
commit 86c19714b097aa477d339ed99ffb5136c755a046."