2001-07-16 12:23:00 +00:00
|
|
|
;;; tool-bar.el --- setting up the tool bar
|
2011-01-16 02:21:30 +00:00
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
|
2011-01-16 02:21:30 +00:00
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
;; Author: Dave Love <fx@gnu.org>
|
|
|
|
;; Keywords: mouse frames
|
2010-08-29 16:17:13 +00:00
|
|
|
;; Package: emacs
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2000-09-19 17:36:49 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2002-06-20 21:35:38 +00:00
|
|
|
;; Provides `tool-bar-mode' to control display of the tool-bar and
|
2000-09-19 17:36:49 +00:00
|
|
|
;; bindings for the global tool bar with convenience functions
|
|
|
|
;; `tool-bar-add-item' and `tool-bar-add-item-from-menu'.
|
|
|
|
|
2000-10-08 15:29:52 +00:00
|
|
|
;; The normal global binding for [tool-bar] (below) uses the value of
|
2000-11-17 17:50:48 +00:00
|
|
|
;; `tool-bar-map' as the actual keymap to define the tool bar. Modes
|
|
|
|
;; may either bind items under the [tool-bar] prefix key of the local
|
|
|
|
;; map to add to the global bar or may set `tool-bar-map'
|
2000-10-11 14:11:47 +00:00
|
|
|
;; buffer-locally to override it. (Some items are removed from the
|
2000-10-08 15:29:52 +00:00
|
|
|
;; global bar in modes which have `special' as their `mode-class'
|
2002-03-26 08:48:51 +00:00
|
|
|
;; property.)
|
2000-10-08 15:29:52 +00:00
|
|
|
|
2000-10-09 11:12:06 +00:00
|
|
|
;; Todo: Somehow make tool bars easily customizable by the naive?
|
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
;;; Code:
|
|
|
|
|
2005-10-28 16:22:08 +00:00
|
|
|
;; The autoload cookie doesn't work when preloading.
|
|
|
|
;; Deleting it means invoking this command won't work
|
|
|
|
;; when you are on a tty. I hope that won't cause too much trouble -- rms.
|
2000-09-19 17:36:49 +00:00
|
|
|
(define-minor-mode tool-bar-mode
|
Fix minor mode docstrings for the new meaning of a nil ARG.
* abbrev.el (abbrev-mode):
* allout.el (allout-mode):
* autoinsert.el (auto-insert-mode):
* autoarg.el (autoarg-mode, autoarg-kp-mode):
* autorevert.el (auto-revert-mode, auto-revert-tail-mode)
(global-auto-revert-mode):
* battery.el (display-battery-mode):
* composite.el (global-auto-composition-mode)
(auto-composition-mode):
* delsel.el (delete-selection-mode):
* desktop.el (desktop-save-mode):
* dired-x.el (dired-omit-mode):
* dirtrack.el (dirtrack-mode):
* doc-view.el (doc-view-minor-mode):
* double.el (double-mode):
* electric.el (electric-indent-mode, electric-pair-mode):
* emacs-lock.el (emacs-lock-mode):
* epa-hook.el (auto-encryption-mode):
* follow.el (follow-mode):
* font-core.el (font-lock-mode):
* frame.el (auto-raise-mode, auto-lower-mode, blink-cursor-mode):
* help.el (temp-buffer-resize-mode):
* hilit-chg.el (highlight-changes-mode)
(highlight-changes-visible-mode):
* hi-lock.el (hi-lock-mode):
* hl-line.el (hl-line-mode, global-hl-line-mode):
* icomplete.el (icomplete-mode):
* ido.el (ido-everywhere):
* image-file.el (auto-image-file-mode):
* image-mode.el (image-minor-mode):
* iswitchb.el (iswitchb-mode):
* jka-cmpr-hook.el (auto-compression-mode):
* linum.el (linum-mode):
* longlines.el (longlines-mode):
* master.el (master-mode):
* mb-depth.el (minibuffer-depth-indicate-mode):
* menu-bar.el (menu-bar-mode):
* minibuf-eldef.el (minibuffer-electric-default-mode):
* mouse-sel.el (mouse-sel-mode):
* msb.el (msb-mode):
* mwheel.el (mouse-wheel-mode):
* outline.el (outline-minor-mode):
* paren.el (show-paren-mode):
* recentf.el (recentf-mode):
* reveal.el (reveal-mode, global-reveal-mode):
* rfn-eshadow.el (file-name-shadow-mode):
* ruler-mode.el (ruler-mode):
* savehist.el (savehist-mode):
* scroll-all.el (scroll-all-mode):
* scroll-bar.el (scroll-bar-mode):
* server.el (server-mode):
* shell.el (shell-dirtrack-mode):
* simple.el (auto-fill-mode, transient-mark-mode)
(visual-line-mode, overwrite-mode, binary-overwrite-mode)
(line-number-mode, column-number-mode, size-indication-mode)
(auto-save-mode, normal-erase-is-backspace-mode, visible-mode):
* strokes.el (strokes-mode):
* time.el (display-time-mode):
* t-mouse.el (gpm-mouse-mode):
* tool-bar.el (tool-bar-mode):
* tooltip.el (tooltip-mode):
* type-break.el (type-break-mode-line-message-mode)
(type-break-query-mode):
* view.el (view-mode):
* whitespace.el (whitespace-mode, whitespace-newline-mode)
(global-whitespace-mode, global-whitespace-newline-mode):
* xt-mouse.el (xterm-mouse-mode): Doc fix.
* emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Fix
autogenerated docstring.
2011-10-19 12:54:24 +00:00
|
|
|
"Toggle the tool bar in all graphical frames (Tool Bar mode).
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
|
|
See `tool-bar-add-item' and `tool-bar-add-item-from-menu' for
|
|
|
|
conveniently adding tool bar items."
|
2010-06-27 00:30:52 +00:00
|
|
|
:init-value t
|
2000-09-19 17:36:49 +00:00
|
|
|
:global t
|
2010-10-29 03:29:29 +00:00
|
|
|
;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
|
|
|
|
:variable tool-bar-mode
|
2010-06-27 00:30:52 +00:00
|
|
|
(let ((val (if tool-bar-mode 1 0)))
|
|
|
|
(dolist (frame (frame-list))
|
2010-07-05 17:54:13 +00:00
|
|
|
(set-frame-parameter frame 'tool-bar-lines val))
|
|
|
|
;; If the user has given `default-frame-alist' a `tool-bar-lines'
|
|
|
|
;; parameter, replace it.
|
|
|
|
(if (assq 'tool-bar-lines default-frame-alist)
|
|
|
|
(setq default-frame-alist
|
|
|
|
(cons (cons 'tool-bar-lines val)
|
|
|
|
(assq-delete-all 'tool-bar-lines
|
|
|
|
default-frame-alist)))))
|
|
|
|
(and tool-bar-mode
|
|
|
|
(= 1 (length (default-value 'tool-bar-map))) ; not yet setup
|
|
|
|
(tool-bar-setup)))
|
2000-09-19 17:36:49 +00:00
|
|
|
|
2002-02-21 09:39:39 +00:00
|
|
|
;;;###autoload
|
2006-03-26 14:20:01 +00:00
|
|
|
;; Used in the Show/Hide menu, to have the toggle reflect the current frame.
|
|
|
|
(defun toggle-tool-bar-mode-from-frame (&optional arg)
|
|
|
|
"Toggle tool bar on or off, based on the status of the current frame.
|
|
|
|
See `tool-bar-mode' for more information."
|
|
|
|
(interactive (list (or current-prefix-arg 'toggle)))
|
|
|
|
(if (eq arg 'toggle)
|
|
|
|
(tool-bar-mode (if (> (frame-parameter nil 'tool-bar-lines) 0) 0 1))
|
|
|
|
(tool-bar-mode arg)))
|
|
|
|
|
2000-10-08 15:29:52 +00:00
|
|
|
(defvar tool-bar-map (make-sparse-keymap)
|
|
|
|
"Keymap for the tool bar.
|
|
|
|
Define this locally to override the global tool bar.")
|
|
|
|
|
|
|
|
(global-set-key [tool-bar]
|
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
(tex-dvi-print-command, tex-bibtex-command, tex-start-commands)
(tex-start-options, slitex-run-command, latex-run-command)
(tex-run-command, tex-directory):
* textmodes/ispell.el (ispell-html-skip-alists)
(ispell-tex-skip-alists, ispell-tex-skip-alists):
* textmodes/fill.el (adaptive-fill-first-line-regexp):
(adaptive-fill-regexp):
* textmodes/dns-mode.el (auto-mode-alist):
* progmodes/python.el (interpreter-mode-alist):
* progmodes/etags.el (tags-compression-info-list):
* progmodes/etags.el (tags-file-name):
* net/browse-url.el (browse-url-galeon-program)
(browse-url-firefox-program):
* mail/sendmail.el (mail-signature-file)
(mail-citation-prefix-regexp):
* international/mule-conf.el (eight-bit):
* international/latexenc.el (latex-inputenc-coding-alist):
* international/fontset.el (x-pixel-size-width-font-regexp):
* emacs-lisp/warnings.el (warning-type-format):
* emacs-lisp/trace.el (trace-buffer):
* emacs-lisp/lisp-mode.el (lisp-interaction-mode-map)
(emacs-lisp-mode-map):
* calendar/holidays.el (holiday-solar-holidays)
(holiday-bahai-holidays, holiday-islamic-holidays)
(holiday-christian-holidays, holiday-hebrew-holidays)
(hebrew-holidays-4, hebrew-holidays-3, hebrew-holidays-2)
(hebrew-holidays-1, holiday-oriental-holidays)
(holiday-general-holidays):
* x-dnd.el (x-dnd-known-types):
* tool-bar.el (tool-bar):
* startup.el (site-run-file):
* shell.el (shell-dumb-shell-regexp):
* rfn-eshadow.el (file-name-shadow-tty-properties)
(file-name-shadow-properties):
* paths.el (remote-shell-program, news-directory):
* mouse.el ([C-down-mouse-3]):
* menu-bar.el (menu-bar-tools-menu):
* jka-cmpr-hook.el (jka-compr-load-suffixes)
(jka-compr-mode-alist-additions, jka-compr-compression-info-list)
(jka-compr-compression-info-list):
* isearch.el (search-whitespace-regexp):
* image-file.el (image-file-name-extensions):
* find-dired.el (find-ls-option):
* files.el (directory-listing-before-filename-regexp)
(directory-free-space-args, insert-directory-program)
(list-directory-brief-switches, magic-fallback-mode-alist)
(magic-fallback-mode-alist, auto-mode-interpreter-regexp)
(automount-dir-prefix):
* faces.el (face-x-resources, x-font-regexp, x-font-regexp-head)
(x-font-regexp-slant, x-font-regexp-weight, face-x-resources)
(face-font-registry-alternatives, face-font-registry-alternatives)
(face-font-family-alternatives):
* facemenu.el (facemenu-add-new-face, facemenu-background-menu)
(facemenu-foreground-menu, facemenu-face-menu):
* epa-hook.el (epa-file-name-regexp):
* dnd.el (dnd-protocol-alist):
* textmodes/rst.el (auto-mode-alist):
* button.el (default-button): Purecopy strings.
2009-11-06 05:16:23 +00:00
|
|
|
`(menu-item ,(purecopy "tool bar") ignore
|
2008-05-07 18:16:28 +00:00
|
|
|
:filter tool-bar-make-keymap))
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
(declare-function image-mask-p "image.c" (spec &optional frame))
|
|
|
|
|
2008-11-27 03:29:37 +00:00
|
|
|
(defconst tool-bar-keymap-cache (make-hash-table :weakness t :test 'equal))
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
(defun tool-bar-make-keymap (&optional _ignore)
|
2008-05-07 18:16:28 +00:00
|
|
|
"Generate an actual keymap from `tool-bar-map'.
|
|
|
|
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."
|
2008-11-27 03:29:37 +00:00
|
|
|
(let ((key (cons (frame-terminal) tool-bar-map)))
|
|
|
|
(or (gethash key tool-bar-keymap-cache)
|
|
|
|
(puthash key (tool-bar-make-keymap-1) tool-bar-keymap-cache))))
|
|
|
|
|
|
|
|
(defun tool-bar-make-keymap-1 ()
|
|
|
|
"Generate an actual keymap from `tool-bar-map', without caching."
|
2008-05-07 18:16:28 +00:00
|
|
|
(mapcar (lambda (bind)
|
2008-05-13 17:52:31 +00:00
|
|
|
(let (image-exp plist)
|
2008-05-07 18:16:28 +00:00
|
|
|
(when (and (eq (car-safe (cdr-safe bind)) 'menu-item)
|
2008-05-13 17:52:31 +00:00
|
|
|
;; For the format of menu-items, see node
|
|
|
|
;; `Extended Menu Items' in the Elisp manual.
|
|
|
|
(setq plist (nthcdr (if (consp (nth 4 bind)) 5 4)
|
|
|
|
bind))
|
|
|
|
(setq image-exp (plist-get plist :image))
|
|
|
|
(consp image-exp)
|
|
|
|
(not (eq (car image-exp) 'image))
|
|
|
|
(fboundp (car image-exp)))
|
|
|
|
(if (not (display-images-p))
|
|
|
|
(setq bind nil)
|
|
|
|
(let ((image (eval image-exp)))
|
2008-05-13 18:02:44 +00:00
|
|
|
(unless (and image (image-mask-p image))
|
2008-05-13 17:52:31 +00:00
|
|
|
(setq image (append image '(:mask heuristic))))
|
|
|
|
(setq bind (copy-sequence bind)
|
|
|
|
plist (nthcdr (if (consp (nth 4 bind)) 5 4)
|
|
|
|
bind))
|
|
|
|
(plist-put plist :image image))))
|
|
|
|
bind))
|
2008-05-07 18:16:28 +00:00
|
|
|
tool-bar-map))
|
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
;;;###autoload
|
2000-10-08 15:29:52 +00:00
|
|
|
(defun tool-bar-add-item (icon def key &rest props)
|
2000-09-19 17:36:49 +00:00
|
|
|
"Add an item to the tool bar.
|
|
|
|
ICON names the image, DEF is the key definition and KEY is a symbol
|
2000-10-08 15:29:52 +00:00
|
|
|
for the fake function key in the menu keymap. Remaining arguments
|
|
|
|
PROPS are additional items to add to the menu item specification. See
|
|
|
|
Info node `(elisp)Tool Bar'. Items are added from left to right.
|
2000-09-19 17:36:49 +00:00
|
|
|
|
2001-01-31 13:23:12 +00:00
|
|
|
ICON is the base name of a file containing the image to use. The
|
Fix typos (sync from the trunk).
* facemenu.el (facemenu-unlisted-faces): Fix obsolescence declaration.
* hi-lock.el (hi-lock-mode): Fix typo in docstring.
* icomplete.el (icomplete-compute-delay, icomplete-get-keys): Doc fixes.
(icomplete-delay-completions-threshold): Fix typo in docstring.
* speedbar.el (speedbar-stealthy-function-list)
(speedbar-verbosity-level, speedbar-supported-extension-expressions)
(speedbar-update-current-file, speedbar-add-indicator)
(speedbar-tag-expand): Reflow docstrings.
(speedbar-use-imenu-flag, speedbar-use-tool-tips-flag)
(speedbar-ignored-directory-regexp, speedbar-file-unshown-regexp)
(speedbar-file-regexp, speedbar-message, speedbar-item-info)
(speedbar-files-item-info, speedbar-fetch-replacement-function)
(speedbar-maybe-add-localized-support)
(speedbar-generic-list-positioned-group-p, speedbar-insert-generic-list)
(speedbar-extract-one-symbol, speedbar-recenter-to-top)
(speedbar-recenter, speedbar-separator-face): Fix typos in docstrings.
(speedbar-ignored-directory-expressions, speedbar-handle-delete-frame)
(speedbar-show-info-under-mouse, speedbar-directory-buttons)
(speedbar-check-vc-this-line, speedbar-files-line-directory)
(speedbar-buffer-buttons, speedbar-buffer-buttons-temp)
(speedbar-buffers-line-directory): Doc fixes.
* tool-bar.el (tool-bar-add-item): Fix typo in docstring.
* emacs-lisp/edebug.el (edebug-unwrap*, edebug-signal)
(edebug-restore-status): Doc fixes.
(edebug-gensym, edebug-top-level-nonstop, edebug-eval-display)
(edebug-eval-result-list, edebug-eval-redisplay, edebug)
(edebug-trace): Fix typos in docstrings.
* emulation/tpu-edt.el (tpu-match-beginning, tpu-match-end)
(tpu-check-match, tpu-goto-breadcrumb, tpu-reset-screen-size)
(tpu-toggle-overwrite-mode, tpu-include, tpu-get, tpu-what-line)
(tpu-insert-escape, tpu-insert-formfeed, tpu-end-define-macro-key)
(tpu-check-search-case, tpu-select, tpu-unselect, tpu-trim-line-ends)
(tpu-toggle-control-keys): Fix typos in docstrings.
(tpu-kill-buffer): Doc fix.
(tpu-make-file-buffer-list, tpu-toggle-regexp, tpu-cut)
(tpu-append-region, tpu-delete-current-char, tpu-emacs-replace):
Reflow docstrings.
* eshell/em-smart.el (eshell-review-quick-commands): Doc fix.
* eshell/esh-arg.el (eshell-quote-backslash): Fix typo in docstring.
* play/solitaire.el (solitaire, solitaire-mode-map, solitaire-mode-hook)
(solitaire-mode, solitaire, solitaire-solve): Fix typos in docstrings.
* progmodes/gdb-ui.el (gdb-source-info): Fix typo in docstring.
* progmodes/python.el (python-comment-line-p, python-blank-line-p)
(python-skip-out): Doc fixes.
2008-08-26 11:02:51 +00:00
|
|
|
function will first try to use low-color/ICON.xpm if `display-color-cells'
|
2004-06-08 17:53:11 +00:00
|
|
|
is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally
|
2001-01-31 13:23:12 +00:00
|
|
|
ICON.xbm, using `find-image'.
|
2000-10-08 15:29:52 +00:00
|
|
|
|
2002-04-01 16:28:16 +00:00
|
|
|
Use this function only to make bindings in the global value of `tool-bar-map'.
|
|
|
|
To define items in any other map, use `tool-bar-local-item'."
|
|
|
|
(apply 'tool-bar-local-item icon def key tool-bar-map props))
|
|
|
|
|
2010-12-20 00:17:26 +00:00
|
|
|
(defun tool-bar--image-expression (icon)
|
|
|
|
"Return an expression that evaluates to an image spec for ICON."
|
|
|
|
(let* ((fg (face-attribute 'tool-bar :foreground))
|
|
|
|
(bg (face-attribute 'tool-bar :background))
|
|
|
|
(colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
|
|
|
|
(if (eq bg 'unspecified) nil (list :background bg))))
|
|
|
|
(xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
|
|
|
|
(xpm-lo-spec (list :type 'xpm :file
|
|
|
|
(concat "low-color/" icon ".xpm")))
|
|
|
|
(pbm-spec (append (list :type 'pbm :file
|
|
|
|
(concat icon ".pbm")) colors))
|
|
|
|
(xbm-spec (append (list :type 'xbm :file
|
|
|
|
(concat icon ".xbm")) colors)))
|
|
|
|
`(find-image (cond ((not (display-color-p))
|
|
|
|
',(list pbm-spec xbm-spec xpm-lo-spec xpm-spec))
|
|
|
|
((< (display-color-cells) 256)
|
|
|
|
',(list xpm-lo-spec xpm-spec pbm-spec xbm-spec))
|
|
|
|
(t
|
|
|
|
',(list xpm-spec pbm-spec xbm-spec))))))
|
|
|
|
|
2002-04-01 16:28:16 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun tool-bar-local-item (icon def key map &rest props)
|
|
|
|
"Add an item to the tool bar in map MAP.
|
|
|
|
ICON names the image, DEF is the key definition and KEY is a symbol
|
|
|
|
for the fake function key in the menu keymap. Remaining arguments
|
|
|
|
PROPS are additional items to add to the menu item specification. See
|
|
|
|
Info node `(elisp)Tool Bar'. Items are added from left to right.
|
|
|
|
|
|
|
|
ICON is the base name of a file containing the image to use. The
|
2008-05-07 18:16:28 +00:00
|
|
|
function will first try to use low-color/ICON.xpm if `display-color-cells'
|
2004-06-08 17:53:11 +00:00
|
|
|
is less or equal to 256, then ICON.xpm, then ICON.pbm, and finally
|
2002-04-01 16:28:16 +00:00
|
|
|
ICON.xbm, using `find-image'."
|
2010-12-20 00:17:26 +00:00
|
|
|
(let* ((image-exp (tool-bar--image-expression icon)))
|
2008-05-07 18:16:28 +00:00
|
|
|
(define-key-after map (vector key)
|
2015-01-01 15:29:51 +00:00
|
|
|
`(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))
|
|
|
|
(force-mode-line-update)))
|
2000-09-19 17:36:49 +00:00
|
|
|
|
2000-10-09 17:56:11 +00:00
|
|
|
;;;###autoload
|
2000-09-19 17:36:49 +00:00
|
|
|
(defun tool-bar-add-item-from-menu (command icon &optional map &rest props)
|
2005-10-28 21:03:35 +00:00
|
|
|
"Define tool bar binding for COMMAND in keymap MAP using the given ICON.
|
2002-04-01 16:28:16 +00:00
|
|
|
This makes a binding for COMMAND in `tool-bar-map', copying its
|
|
|
|
binding from the menu bar in MAP (which defaults to `global-map'), but
|
|
|
|
modifies the binding by adding an image specification for ICON. It
|
|
|
|
finds ICON just like `tool-bar-add-item'. PROPS are additional
|
|
|
|
properties to add to the binding.
|
|
|
|
|
|
|
|
MAP must contain appropriate binding for `[menu-bar]' which holds a keymap.
|
|
|
|
|
|
|
|
Use this function only to make bindings in the global value of `tool-bar-map'.
|
2005-10-28 21:03:35 +00:00
|
|
|
To define items in any other map, use `tool-bar-local-item-from-menu'."
|
2002-07-16 22:46:09 +00:00
|
|
|
(apply 'tool-bar-local-item-from-menu command icon
|
|
|
|
(default-value 'tool-bar-map) map props))
|
2002-04-01 16:28:16 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun tool-bar-local-item-from-menu (command icon in-map &optional from-map &rest props)
|
2005-10-28 21:03:35 +00:00
|
|
|
"Define local tool bar binding for COMMAND using the given ICON.
|
2002-04-01 16:28:16 +00:00
|
|
|
This makes a binding for COMMAND in IN-MAP, copying its binding from
|
|
|
|
the menu bar in FROM-MAP (which defaults to `global-map'), but
|
|
|
|
modifies the binding by adding an image specification for ICON. It
|
|
|
|
finds ICON just like `tool-bar-add-item'. PROPS are additional
|
|
|
|
properties to add to the binding.
|
|
|
|
|
2005-10-28 21:03:35 +00:00
|
|
|
FROM-MAP must contain appropriate binding for `[menu-bar]' which
|
|
|
|
holds a keymap."
|
2002-04-01 16:28:16 +00:00
|
|
|
(unless from-map
|
|
|
|
(setq from-map global-map))
|
|
|
|
(let* ((menu-bar-map (lookup-key from-map [menu-bar]))
|
2000-09-19 17:36:49 +00:00
|
|
|
(keys (where-is-internal command menu-bar-map))
|
2010-12-20 00:17:26 +00:00
|
|
|
(image-exp (tool-bar--image-expression icon))
|
2000-09-19 17:36:49 +00:00
|
|
|
submap key)
|
2008-05-07 18:16:28 +00:00
|
|
|
;; We'll pick up the last valid entry in the list of keys if
|
|
|
|
;; there's more than one.
|
2010-04-23 16:26:11 +00:00
|
|
|
;; FIXME: Aren't they *all* "valid"?? --Stef
|
2008-05-07 18:16:28 +00:00
|
|
|
(dolist (k keys)
|
|
|
|
;; We're looking for a binding of the command in a submap of
|
|
|
|
;; the menu bar map, so the key sequence must be two or more
|
|
|
|
;; long.
|
|
|
|
(if (and (vectorp k)
|
|
|
|
(> (length k) 1))
|
|
|
|
(let ((m (lookup-key menu-bar-map (substring k 0 -1)))
|
|
|
|
;; Last element in the bound key sequence:
|
|
|
|
(kk (aref k (1- (length k)))))
|
|
|
|
(if (and (keymapp m)
|
2010-04-25 07:23:01 +00:00
|
|
|
(symbolp kk))
|
2008-05-07 18:16:28 +00:00
|
|
|
(setq submap m
|
|
|
|
key kk)))))
|
2010-04-25 07:23:01 +00:00
|
|
|
(when (and (symbolp submap) (boundp submap))
|
|
|
|
(setq submap (eval submap)))
|
|
|
|
(let ((defn (assq key (cdr submap))))
|
|
|
|
(if (eq (cadr defn) 'menu-item)
|
|
|
|
(define-key-after in-map (vector key)
|
|
|
|
(append (cdr defn) (list :image image-exp) props))
|
|
|
|
(setq defn (cdr defn))
|
2008-05-07 18:16:28 +00:00
|
|
|
(define-key-after in-map (vector key)
|
2010-04-25 07:23:01 +00:00
|
|
|
(let ((rest (cdr defn)))
|
|
|
|
;; If the rest of the definition starts
|
|
|
|
;; with a list of menu cache info, get rid of that.
|
|
|
|
(if (and (consp rest) (consp (car rest)))
|
|
|
|
(setq rest (cdr rest)))
|
|
|
|
(append `(menu-item ,(car defn) ,rest)
|
2015-01-01 15:29:51 +00:00
|
|
|
(list :image image-exp) props))))
|
|
|
|
(force-mode-line-update))))
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
|
|
;;; Set up some global items. Additions/deletions up for grabs.
|
|
|
|
|
2008-10-12 13:45:46 +00:00
|
|
|
(defun tool-bar-setup ()
|
2010-12-20 00:17:26 +00:00
|
|
|
(setq tool-bar-separator-image-expression
|
|
|
|
(tool-bar--image-expression "separator"))
|
2010-11-20 14:51:25 +00:00
|
|
|
(tool-bar-add-item-from-menu 'find-file "new" nil :label "New File"
|
|
|
|
:vert-only t)
|
|
|
|
(tool-bar-add-item-from-menu 'menu-find-file-existing "open" nil
|
2010-12-17 04:04:06 +00:00
|
|
|
:label "Open" :vert-only t)
|
2010-11-20 14:51:25 +00:00
|
|
|
(tool-bar-add-item-from-menu 'dired "diropen" nil :vert-only t)
|
|
|
|
(tool-bar-add-item-from-menu 'kill-this-buffer "close" nil :vert-only t)
|
2010-12-20 00:17:26 +00:00
|
|
|
(tool-bar-add-item-from-menu 'save-buffer "save" nil
|
2010-12-28 09:39:25 +00:00
|
|
|
:label "Save")
|
2010-12-17 04:04:06 +00:00
|
|
|
(define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator)
|
2011-01-09 04:13:47 +00:00
|
|
|
(tool-bar-add-item-from-menu 'undo "undo" nil)
|
2010-12-17 04:04:06 +00:00
|
|
|
(define-key-after (default-value 'tool-bar-map) [separator-2] menu-bar-separator)
|
2008-10-12 13:45:46 +00:00
|
|
|
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
|
2010-12-28 09:39:25 +00:00
|
|
|
"cut" nil :vert-only t)
|
2008-10-12 13:45:46 +00:00
|
|
|
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
|
2010-11-20 14:51:25 +00:00
|
|
|
"copy" nil :vert-only t)
|
2008-10-12 13:45:46 +00:00
|
|
|
(tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
|
2010-12-28 09:39:25 +00:00
|
|
|
"paste" nil :vert-only t)
|
2010-12-17 04:04:06 +00:00
|
|
|
(define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator)
|
2011-01-09 04:13:47 +00:00
|
|
|
(tool-bar-add-item-from-menu 'isearch-forward "search"
|
|
|
|
nil :label "Search" :vert-only t)
|
2008-10-12 13:45:46 +00:00
|
|
|
;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
|
|
|
|
|
|
|
|
;; There's no icon appropriate for News and we need a command rather
|
|
|
|
;; than a lambda for Read Mail.
|
|
|
|
;;(tool-bar-add-item-from-menu 'compose-mail "mail/compose")
|
|
|
|
|
2011-01-09 04:13:47 +00:00
|
|
|
;; Help button on a tool bar is rather non-standard...
|
|
|
|
;; (let ((tool-bar-map (default-value 'tool-bar-map)))
|
|
|
|
;; (tool-bar-add-item "help" (lambda ()
|
|
|
|
;; (interactive)
|
|
|
|
;; (popup-menu menu-bar-help-menu))
|
|
|
|
;; 'help
|
|
|
|
;; :help "Pop up the Help menu"))
|
|
|
|
)
|
2000-09-19 17:36:49 +00:00
|
|
|
|
2010-09-21 07:01:22 +00:00
|
|
|
(if (featurep 'move-toolbar)
|
|
|
|
(defcustom tool-bar-position 'top
|
|
|
|
"Specify on which side the tool bar shall be.
|
|
|
|
Possible values are `top' (tool bar on top), `bottom' (tool bar at bottom),
|
|
|
|
`left' (tool bar on left) and `right' (tool bar on right).
|
|
|
|
Customize `tool-bar-mode' if you want to show or hide the tool bar."
|
Add missing :version tags to new defgroups and defcustoms
* window.el (window-sides-slots):
* tool-bar.el (tool-bar-position):
* term/xterm.el (xterm-extra-capabilities):
* ses.el (ses-self-reference-early-detection):
* progmodes/verilog-mode.el (verilog-auto-declare-nettype)
(verilog-auto-wire-type)
(verilog-auto-delete-trailing-whitespace)
(verilog-auto-reset-blocking-in-non, verilog-auto-inst-sort)
(verilog-auto-tieoff-declaration):
* progmodes/sql.el (sql-login-hook, sql-ansi-statement-starters)
(sql-oracle-statement-starters, sql-oracle-scan-on):
* progmodes/prolog.el (prolog-align-comments-flag)
(prolog-indent-mline-comments-flag, prolog-object-end-to-0-flag)
(prolog-left-indent-regexp, prolog-paren-indent-p)
(prolog-paren-indent, prolog-parse-mode, prolog-keywords)
(prolog-types, prolog-mode-specificators)
(prolog-determinism-specificators, prolog-directives)
(prolog-electric-newline-flag, prolog-hungry-delete-key-flag)
(prolog-electric-dot-flag)
(prolog-electric-dot-full-predicate-template)
(prolog-electric-underscore-flag, prolog-electric-tab-flag)
(prolog-electric-if-then-else-flag, prolog-electric-colon-flag)
(prolog-electric-dash-flag, prolog-old-sicstus-keys-flag)
(prolog-program-switches, prolog-prompt-regexp)
(prolog-debug-on-string, prolog-debug-off-string)
(prolog-trace-on-string, prolog-trace-off-string)
(prolog-zip-on-string, prolog-zip-off-string)
(prolog-use-standard-consult-compile-method-flag)
(prolog-use-prolog-tokenizer-flag, prolog-imenu-flag)
(prolog-imenu-max-lines, prolog-info-predicate-index)
(prolog-underscore-wordchar-flag, prolog-use-sicstus-sd)
(prolog-char-quote-workaround):
* progmodes/cc-vars.el (c-defun-tactic):
* net/tramp.el (tramp-encoding-command-interactive)
(tramp-local-end-of-line):
* net/soap-client.el (soap-client):
* net/netrc.el (netrc-file):
* net/gnutls.el (gnutls):
* minibuffer.el (completion-category-overrides)
(completion-cycle-threshold)
(completion-pcm-complete-word-inserts-delimiters):
* man.el (Man-name-local-regexp):
* mail/feedmail.el (feedmail-display-full-frame):
* international/characters.el (glyphless-char-display-control):
* eshell/em-ls.el (eshell-ls-date-format):
* emacs-lisp/cl-indent.el (lisp-lambda-list-keyword-alignment)
(lisp-lambda-list-keyword-parameter-indentation)
(lisp-lambda-list-keyword-parameter-alignment):
* doc-view.el (doc-view-image-width, doc-view-unoconv-program):
* dired-x.el (dired-omit-verbose):
* cus-theme.el (custom-theme-allow-multiple-selections):
* calc/calc.el (calc-highlight-selections-with-faces)
(calc-lu-field-reference, calc-lu-power-reference)
(calc-note-threshold):
* battery.el (battery-mode-line-limit):
* arc-mode.el (archive-7z-extract, archive-7z-expunge)
(archive-7z-update):
* allout.el (allout-prefixed-keybindings)
(allout-unprefixed-keybindings)
(allout-inhibit-auto-fill-on-headline)
(allout-flattened-numbering-abbreviation):
* allout-widgets.el (allout-widgets-auto-activation)
(allout-widgets-icons-dark-subdir)
(allout-widgets-icons-light-subdir, allout-widgets-icon-types)
(allout-widgets-theme-dark-background)
(allout-widgets-theme-light-background)
(allout-widgets-item-image-properties-emacs)
(allout-widgets-item-image-properties-xemacs)
(allout-widgets-run-unit-tests-on-load)
(allout-widgets-time-decoration-activity)
(allout-widgets-hook-error-post-time)
(allout-widgets-track-decoration):
* gnus/sieve-manage.el (sieve-manage-default-stream):
* gnus/shr.el (shr):
* gnus/nnir.el (nnir-ignored-newsgroups, nnir-summary-line-format)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-notmuch-program)
(nnir-notmuch-additional-switches, nnir-notmuch-remove-prefix)
(nnir-method-default-engines):
* gnus/message.el (message-cite-reply-position):
* gnus/gssapi.el (gssapi-program):
* gnus/gravatar.el (gravatar):
* gnus/gnus-sum.el (gnus-refer-thread-use-nnir):
* gnus/gnus-registry.el (gnus-registry-unfollowed-addresses)
(gnus-registry-max-pruned-entries):
* gnus/gnus-picon.el (gnus-picon-inhibit-top-level-domains):
* gnus/gnus-int.el (gnus-after-set-mark-hook)
(gnus-before-update-mark-hook):
* gnus/gnus-async.el (gnus-async-post-fetch-function):
* gnus/auth-source.el (auth-source-cache-expiry):
Add missing :version tags to new defcustoms and defgroups.
2012-02-11 22:13:29 +00:00
|
|
|
:version "24.1"
|
2010-09-21 07:01:22 +00:00
|
|
|
:type '(choice (const top)
|
|
|
|
(const bottom)
|
|
|
|
(const left)
|
|
|
|
(const right))
|
|
|
|
:group 'frames
|
|
|
|
:initialize 'custom-initialize-default
|
|
|
|
:set (lambda (sym val)
|
|
|
|
(set-default sym val)
|
2010-10-29 03:29:29 +00:00
|
|
|
(modify-all-frames-parameters
|
2010-09-21 07:01:22 +00:00
|
|
|
(list (cons 'tool-bar-position val))))))
|
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
|
2006-05-03 11:56:53 +00:00
|
|
|
(provide 'tool-bar)
|
2010-10-29 03:29:29 +00:00
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
;;; tool-bar.el ends here
|