emacs-diffs
[Top][All Lists]
Advanced

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

master dd5ca0eaf2: Make new menu *Help* output be more resilient


From: Lars Ingebrigtsen
Subject: master dd5ca0eaf2: Make new menu *Help* output be more resilient
Date: Tue, 26 Apr 2022 07:24:06 -0400 (EDT)

branch: master
commit dd5ca0eaf2604bcf712c91e43bde723687a64e29
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make new menu *Help* output be more resilient
    
    * lisp/help-fns.el (help-fns--insert-menu-bindings): Only insert
    the heading if it turns out that we actually find the menu.
    (help-fns--insert-bindings): Tweak calling convention.
---
 etc/NEWS         |  2 +-
 lisp/help-fns.el | 26 ++++++++++++++------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index e97f545dda..dc2e7c616a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -434,7 +434,7 @@ following bindings:
 This has been changed to:
 
   It is bound to <open> and C-x C-f.
-  It can also be invoked from the menu: File → Visit New File....
+  It can also be invoked from the menu: File → Visit New File...
 
 +++
 *** The 'C-h .' command now accepts a prefix argument.
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 4599980166..67045bb4d6 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -565,11 +565,10 @@ the C sources, too."
               (insert "\n"))
             (when menus
               (let ((start (point)))
-                (insert (concat "It can "
-                                (and keys "also ")
-                                "be invoked from the menu: "))
-                (help-fns--insert-menu-bindings menus)
-                (insert ".")
+                (help-fns--insert-menu-bindings
+                 menus
+                 (concat "It can " (and keys "also ")
+                         "be invoked from the menu: "))
                 (fill-region-as-paragraph start (point))))
             (ensure-empty-lines)))))))
 
@@ -582,7 +581,7 @@ the C sources, too."
                     (insert (help--key-description-fontified key)))
                   keys))
 
-(defun help-fns--insert-menu-bindings (menus)
+(defun help-fns--insert-menu-bindings (menus heading)
   (seq-do-indexed
    (lambda (menu i)
      (insert
@@ -593,12 +592,15 @@ the C sources, too."
            (start (point)))
        (seq-do-indexed
         (lambda (entry level)
-          (when (> level 0)
-            (insert
-             (if (char-displayable-p ?→)
-                 " → "
-               " => ")))
-          (let ((elem (assq entry (cdr map))))
+          (when-let ((elem (assq entry (cdr map))))
+            (when heading
+              (insert heading)
+              (setq heading nil))
+            (when (> level 0)
+              (insert
+               (if (char-displayable-p ?→)
+                   " → "
+                 " => ")))
             (if (eq (nth 1 elem) 'menu-item)
                 (progn
                   (insert (nth 2 elem))



reply via email to

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