* 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
(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)
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.
(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."