Function: so-long-menu

so-long-menu is a byte-compiled function defined in so-long.el.gz.

Signature

(so-long-menu)

Documentation

Dynamically generate the "So Long" menu.

Source Code

;; Defined in /usr/src/emacs/lisp/so-long.el.gz
(defun so-long-menu ()
  "Dynamically generate the \"So Long\" menu."
  ;; (info "(elisp) Menu Example")
  (let ((map (make-sparse-keymap "So Long"))
        (help-map (make-sparse-keymap "Help")))
    ;; `so-long-revert'.
    (define-key-after map [so-long-revert]
      '(menu-item "Revert to normal" so-long-revert
                  :enable (and so-long-revert-function
                               so-long--active)))
    ;; `so-long-menu-item-replace-action' over `so-long-action-alist'.
    (define-key-after map [so-long-actions-separator]
      '(menu-item "--"))
    (dolist (item so-long-action-alist)
      (cl-destructuring-bind (key label actionfunc revertfunc)
          item
        (define-key-after map (vector key)
          `(menu-item
            ,label
            ,(let ((sym (make-symbol "so-long-menu-item-replace-action")))
               ;; We make a symbol so that `describe-key' on the menu item
               ;; produces something more descriptive than byte code.  There is
               ;; no interned `so-long-menu-item-replace-action' which might
               ;; make this slightly confusing -- but only in the rare situation
               ;; when someone uses `describe-key' on one of these menu items,
               ;; and then wants to find more information.  We mitigate this by
               ;; making the following docstring very clear.
               (defalias sym (lambda () (interactive "@") (so-long key))
                 ;; We use "@" as commands in the mode-line menu may be
                 ;; triggered by mouse when some other window is selected.
                 "Revert the current action and invoke the chosen replacement.

This command calls `so-long' with the selected action as an argument.")
               sym)
            :enable (not (and so-long--active
                              (eq ',actionfunc so-long-function)
                              (eq ',revertfunc so-long-revert-function)))))))
    ;; "Help" sub-menu.
    (define-key-after map [so-long-help-separator]
      '(menu-item "--"))
    (define-key-after map [so-long-help]
      `(menu-item "Help" ,help-map))
    (define-key-after help-map [so-long-commentary]
      '(menu-item "Commentary" so-long-commentary))
    (define-key-after help-map [so-long-customize]
      '(menu-item "Customize" so-long-customize))
    map))