Function: help-fns--insert-menu-bindings

help-fns--insert-menu-bindings is a byte-compiled function defined in help-fns.el.gz.

Signature

(help-fns--insert-menu-bindings MENUS HEADING)

Source Code

;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
(defun help-fns--insert-menu-bindings (menus heading)
  (let ((strings nil))
    ;; First collect all the printed representations of menus.
    (dolist (menu menus)
      (let ((map (lookup-key global-map (seq-take menu 1)))
            (string nil)
            (sep (if (char-displayable-p ?→) " → " " => ")))
        (seq-do-indexed
         (lambda (entry level)
           (when (symbolp map)
             (setq map (symbol-function map)))
           (when-let* ((elem (assq entry (cdr map)))
                       (_ (proper-list-p elem)))
             (when (> level 0)
               (push sep string))
             (if (eq (nth 1 elem) 'menu-item)
                 (progn
                   (push (propertize (nth 2 elem) 'face 'help-key-binding)
                         string)
                   (setq map (cadddr elem)))
               (push (propertize (nth 1 elem) 'face 'help-key-binding)
                     string)
               (setq map (cddr elem)))))
         (cdr (seq-into menu 'list)))
        (when string
          (push string strings))))
    ;; Then output them.
    (when strings
      (when heading
        (insert heading))
      (seq-do-indexed
       (lambda (string i)
         (insert
          (cond ((zerop i) "")
                ((= i (1- (length menus))) " and ")
                (t ", "))
          (string-join (nreverse string))))
       strings))))