]> git.eshelyaron.com Git - emacs.git/commitdiff
Insert describe-map-tree header into original buffer
authorStefan Kangas <stefan@marxist.se>
Sun, 1 Nov 2020 14:27:17 +0000 (15:27 +0100)
committerStefan Kangas <stefan@marxist.se>
Sun, 1 Nov 2020 14:53:43 +0000 (15:53 +0100)
* 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

lisp/help.el
test/src/keymap-tests.el

index 6ae2664cf41008716139c9b061dfcb9968ede12d..795f7e74d8b29f1db94e9bc7815f7205afb258a8 100644 (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.
index 75f8c0f092ed4192d5f46084e0735b7b2209511a..1a30a7d3a0b4d476f74a84f3686a9a06fd0496c2 100644 (file)
 
 (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."