Function: toolbarx-emacs-mount-popup-menu
toolbarx-emacs-mount-popup-menu is a byte-compiled function defined in
toolbar-x.el.
Signature
(toolbarx-emacs-mount-popup-menu STRINGS VAR TYPE &optional TITLE SAVE)
Documentation
Return an interactive lambda-expression that shows a popup menu.
This function is the action of toolbarx-mount-popup-menu if
inside Emacs. See documentation of that function for more.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/toolbar-x.el
(defun toolbarx-emacs-mount-popup-menu
(strings var type &optional title save)
"Return an interactive `lambda'-expression that shows a popup menu.
This function is the action of `toolbarx-mount-popup-menu' if
inside Emacs. See documentation of that function for more."
;; making the menu keymap by adding each menu-item definition
;; see (info "(elisp)Menu keymaps")
(let* ((keymap (make-sparse-keymap title))
(count 1)
(used-symbols '(nil))
(key)
(real-type
(pcase type
((or `toggle `radio) type)
;; Warn if type is not `radio' or `toggle'.
(_ (display-warning 'toolbarx
(format "TYPE should be symbols `radio' or `toggle', but %s found; using `radio'"
type))
;; Use `radio' if incorrect.
'radio)))
(real-save
(pcase save
((or `nil `offer `always) save)
;; Warn if save is not `nil', `offer' or ;; `always'.
(_ (display-warning 'toolbarx
(format "SAVE should be symbols `nil', `offer' or `always', but %s found; using `nil'"
save))
;; Use nil when incorrect.
nil))))
(dolist (i strings)
;; finding a new symbol
(let* ((aux-count 0)
(i-symb (toolbarx-make-symbol-from-string i)))
(setq key i-symb)
(while (memq key used-symbols)
(setq aux-count (1+ aux-count))
(setq key (intern (format "%s-%d" i-symb aux-count))))
(setq used-symbols (cons key used-symbols)))
(define-key-after keymap (vector key)
`(menu-item ,i
,(let ((count count))
(lambda () (interactive)
(set var
(if (eq real-type 'radio)
count
(if (memq count (symbol-value var))
(delete count (symbol-value var))
(sort (cons count (symbol-value var)) #'<))))
(toolbarx-refresh)
(when (eq real-save 'always)
(customize-save-variable var (symbol-value var)))
(symbol-value var)))
:button ,(if (eq real-type 'radio)
`(:radio eq ,var ,count)
`(:toggle memq ,count ,var))))
(setq count (1+ count)))
(when (eq real-save 'offer)
(define-key-after keymap [sep] '(menu-item "--shadow-etched-in-dash"))
(let* ((aux-count 0)
(i-symb 'custom-save))
(setq key i-symb)
(while (memq key used-symbols)
(setq aux-count (1+ aux-count))
(setq key (intern (format "%s-%d" i-symb aux-count))))
(setq used-symbols (cons key used-symbols)))
(define-key-after keymap (vector key)
`(menu-item "Save state of this menu"
(lambda nil (interactive)
(customize-save-variable (quote ,var) ,var)))))
;; returns a `lambda'-expression
(lambda () (interactive) (popup-menu keymap))))