Function: gmm-tool-bar-from-list
gmm-tool-bar-from-list is an autoloaded and byte-compiled function
defined in gmm-utils.el.gz.
Signature
(gmm-tool-bar-from-list ICON-LIST ZAP-LIST DEFAULT-MAP)
Documentation
Make a tool bar from ICON-LIST.
Within each entry of ICON-LIST, the first element is a menu
command, the second element is an icon file name and the third
element is a test function. You can use C-h k (describe-key)
<menu-entry> to find out the name of a menu command. The fourth
and all following elements are passed as the PROPS argument to the
function tool-bar-local-item.
If ZAP-LIST is a list, remove those item from the default
tool-bar-map. If it is t, start with a new sparse map. You
can use C-h k (describe-key) <icon> to find out the name of an icon
item. When C-h k (describe-key) <icon> shows "<tool-bar> <new-file>
runs the command find-file", then use new-file in ZAP-LIST.
DEFAULT-MAP specifies the default key map for ICON-LIST.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gmm-utils.el.gz
;;;###autoload
(defun gmm-tool-bar-from-list (icon-list zap-list default-map)
"Make a tool bar from ICON-LIST.
Within each entry of ICON-LIST, the first element is a menu
command, the second element is an icon file name and the third
element is a test function. You can use \\[describe-key]
<menu-entry> to find out the name of a menu command. The fourth
and all following elements are passed as the PROPS argument to the
function `tool-bar-local-item'.
If ZAP-LIST is a list, remove those item from the default
`tool-bar-map'. If it is t, start with a new sparse map. You
can use \\[describe-key] <icon> to find out the name of an icon
item. When \\[describe-key] <icon> shows \"<tool-bar> <new-file>
runs the command find-file\", then use `new-file' in ZAP-LIST.
DEFAULT-MAP specifies the default key map for ICON-LIST."
(let ((map (if (eq zap-list t)
(make-sparse-keymap)
(copy-keymap tool-bar-map))))
(when (listp zap-list)
;; Zap some items which aren't relevant for this mode and take up space.
(dolist (key zap-list)
(define-key map (vector key) nil)))
(mapc (lambda (el)
(let ((command (car el))
(icon (nth 1 el))
(fmap (or (nth 2 el) default-map))
(props (cdr (cdr (cdr el)))) )
;; command may stem from different from-maps:
(cond ((eq command 'gmm-ignore)
;; The dummy `gmm-ignore', see `gmm-tool-bar-item'
;; widget. Suppress tooltip by adding `:enable nil'.
(if (fboundp 'tool-bar-local-item)
(apply #'tool-bar-local-item icon nil nil
map :enable nil props)
;; (tool-bar-local-item ICON DEF KEY MAP &rest PROPS)
;; (tool-bar-add-item ICON DEF KEY &rest PROPS)
(apply #'tool-bar-add-item icon nil nil :enable nil props)))
((equal fmap t) ;; Not a menu command
(apply #'tool-bar-local-item
icon command
(intern icon) ;; reuse icon or fmap here?
map props))
(t ;; A menu command
(apply #'tool-bar-local-item-from-menu
;; (apply 'tool-bar-local-item icon def key
;; tool-bar-map props)
command icon map (symbol-value fmap)
props)))
t))
(if (symbolp icon-list)
(symbol-value icon-list)
icon-list))
map))