From: Stefan Kangas Date: Sun, 1 Nov 2020 14:27:17 +0000 (+0100) Subject: Insert describe-map-tree header into original buffer X-Git-Tag: emacs-28.0.90~5289 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ce1856ec09dd312667d8f7cf9ffc908b473d27b8;p=emacs.git 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 --- diff --git a/lisp/help.el b/lisp/help.el index 6ae2664cf41..795f7e74d8b 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -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. diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el index 75f8c0f092e..1a30a7d3a0b 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el @@ -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."