emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ce1856e: Insert describe-map-tree header into original buffer


From: Stefan Kangas
Subject: master ce1856e: Insert describe-map-tree header into original buffer
Date: Sun, 1 Nov 2020 09:55:26 -0500 (EST)

branch: master
commit ce1856ec09dd312667d8f7cf9ffc908b473d27b8
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    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
---
 lisp/help.el             | 18 +++++++++---------
 test/src/keymap-tests.el | 13 +++++++++++++
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/lisp/help.el b/lisp/help.el
index 6ae2664..795f7e7 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 75f8c0f..1a30a7d 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]