Function: hui:menu-get-help-string

hui:menu-get-help-string is a byte-compiled function defined in hui-mini.el.

Signature

(hui:menu-get-help-string &optional MENU MENU-ALIST)

Documentation

Return key and short doc for items in optional MENU symbol and MENU-ALIST.

MENU and MENU-ALIST are Hyperbole minibuffer menu internal constructs. If not given, the top level Hyperbole menu is used.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260822.1645/hui-mini.el
(defun hui:menu-get-help-string (&optional menu menu-alist)
  "Return key and short doc for items in optional MENU symbol and MENU-ALIST.
MENU and MENU-ALIST are Hyperbole minibuffer menu internal constructs.
If not given, the top level Hyperbole menu is used."
  (unless menu-alist
    (setq menu-alist (or (cdr (assq (if (and menu (symbolp menu)) menu 'hyperbole)
				    hui:menus))
			 (hypb:error "(hui:menu-item): Invalid menu symbol arg: `%s'"
				     menu))))
  ;; Remove the first menu name element
  (setq menu-alist (cdr menu-alist))
  (let* ((name-max (apply #'max (mapcar #'length (delq nil (mapcar #'car menu-alist)))))

         (action-max (apply #'max (mapcar #'length (delq nil (mapcar (lambda (item)
                                                                       (prin1-to-string
                                                                        (cadr item)))
                                                                     menu-alist)))))
         (doc-lines  (mapcar
                      (lambda (item)
                        (or (seq-take-while (lambda (c) (/= c ?\n)) (caddr item))
                            ""))
                      menu-alist))
         (doc-max    (apply #'max (mapcar #'length doc-lines)))
         ;; Produce a tabular output format based on the max length of each
         ;; column, left aligned (right padded) with 2 spaces separating
         ;; each column
         (line-format (format "%%c %%-%ds %%-%ds %%-%ds"
                              (1+ name-max) (1+ action-max) (1+ doc-max)))
         key
	 name
	 action
	 doc-line)
    (mapconcat (lambda (menu-item)
		 (setq name (nth 0 menu-item)
		       key (downcase (hui:menu-item-key name))
		       action (nth 1 menu-item)
		       doc-line (car doc-lines)
                       doc-lines (cdr doc-lines))
		 (string-trim (format line-format key name action doc-line)
			      nil))
	       menu-alist "\n")))