Function: tool-bar-make-keymap

tool-bar-make-keymap is a byte-compiled function defined in tool-bar.el.gz.

Signature

(tool-bar-make-keymap &optional IGNORE)

Documentation

Generate an actual keymap from tool-bar-map.

If secondary-tool-bar-map is non-nil, take it into account as well. Its main job is to figure out which images to use based on the display's color capability and based on the available image libraries.

Source Code

;; Defined in /usr/src/emacs/lisp/tool-bar.el.gz
(defun tool-bar-make-keymap (&optional _ignore)
  "Generate an actual keymap from `tool-bar-map'.
If `secondary-tool-bar-map' is non-nil, take it into account as well.
Its main job is to figure out which images to use based on the display's
color capability and based on the available image libraries."
  (let* ((key (tool-bar--cache-key))
         (base-keymap
          (or (gethash key tool-bar-keymap-cache)
              (setf (gethash key tool-bar-keymap-cache)
                    (tool-bar-make-keymap-1))))
        (secondary-keymap
         (and secondary-tool-bar-map
              (or (gethash (tool-bar--secondary-cache-key)
                           tool-bar-keymap-cache)
                  (setf (gethash (tool-bar--secondary-cache-key)
                                 tool-bar-keymap-cache)
                        (tool-bar-make-keymap-1
                         secondary-tool-bar-map))))))
    (if secondary-keymap
        (or (ignore-errors
              (progn
                ;; Determine the value of the `tool-bar-position' frame
                ;; parameter.
                (let ((position (frame-parameter nil 'tool-bar-position)))
                  (cond ((eq position 'top)
                         ;; Place `base-keymap' above `secondary-keymap'.
                         (append base-keymap (list (list (gensym)
                                                         'menu-item
                                                         "" 'ignore
                                                         :wrap t))
                                 (cdr secondary-keymap)))
                        ((eq position 'bottom)
                         ;; Place `secondary-keymap' above `base-keymap'.
                         (append secondary-keymap (list (list (gensym)
                                                              'menu-item
                                                              "" 'ignore
                                                              :wrap t))
                                 (cdr base-keymap)))
                        ;; If the tool bar position isn't known, don't
                        ;; display the secondary keymap at all.
                        (t base-keymap)))))
            ;; If combining both keymaps fails, return the base
            ;; keymap.
            base-keymap)
      base-keymap)))