2020-10-27 01:29:43 +01:00
|
|
|
|
;;; tool-bar.el --- setting up the tool bar -*- lexical-binding: t -*-
|
2011-01-15 18:21:30 -08:00
|
|
|
|
|
2025-01-01 07:39:17 +00:00
|
|
|
|
;; Copyright (C) 2000-2025 Free Software Foundation, Inc.
|
2011-01-15 18:21:30 -08:00
|
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
|
;; Author: Dave Love <fx@gnu.org>
|
|
|
|
|
;; Keywords: mouse frames
|
2010-08-29 12:17:13 -04: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 15:52:52 -07: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 08:54:24 -04: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-26 20:30:52 -04:00
|
|
|
|
:init-value t
|
2000-09-19 17:36:49 +00:00
|
|
|
|
:global t
|
2010-10-28 20:29:29 -07:00
|
|
|
|
;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
|
|
|
|
|
:variable tool-bar-mode
|
2010-06-26 20:30:52 -04:00
|
|
|
|
(let ((val (if tool-bar-mode 1 0)))
|
|
|
|
|
(dolist (frame (frame-list))
|
2010-07-05 13:54:13 -04: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)))
|
|
|
|
|
|
Prefer defvar-keymap in some trivial cases
* lisp/calendar/diary-lib.el (diary-fancy-overriding-map):
* lisp/emacs-lisp/chart.el (chart-mode-map):
* lisp/emulation/cua-base.el (cua-global-keymap)
(cua--cua-keys-keymap, cua--prefix-override-keymap)
(cua--prefix-repeat-keymap, cua--global-mark-keymap)
(cua--rectangle-keymap, cua--region-keymap):
* lisp/emulation/viper-keym.el (viper-vi-intercept-map)
(viper-insert-intercept-map, viper-emacs-intercept-map)
(viper-vi-global-user-map, viper-vi-basic-map, viper-vi-kbd-map)
(viper-vi-diehard-map, viper-insert-global-user-map)
(viper-insert-basic-map, viper-insert-diehard-map)
(viper-insert-kbd-map, viper-replace-map)
(viper-emacs-global-user-map, viper-emacs-kbd-map)
(viper-empty-keymap, viper-mode-map, viper-minibuffer-map)
(viper-ex-cmd-map, ex-read-filename-map)
(viper-slash-and-colon-map, viper-comint-mode-modifier-map)
(viper-dired-modifier-map, viper-gnus-modifier-map):
* lisp/gnus/gnus-sum.el (gnus-summary-generic-mark-map):
* lisp/menu-bar.el (global-buffers-menu-map)
(menu-bar-preferences-menu):
* lisp/mh-e/mh-e.el (mh-folder-mode-map, mh-inc-spool-map)
(mh-search-mode-map, mh-show-mode-map):
* lisp/play/dunnet.el (dungeon-batch-map):
* lisp/progmodes/autoconf.el (autoconf-mode-map):
* lisp/tool-bar.el (tool-bar-map):
* lisp/vc/ediff-help.el (ediff-help-region-map):
* lisp/vc/ediff-hook.el (menu-bar-epatch-menu)
(menu-bar-ediff-merge-menu, menu-bar-ediff-menu):
* lisp/windmove.el (windmove-mode-map):
* lisp/xwidget.el (xwidget-webkit-isearch-mode-map)
(xwidget-webkit-edit-mode-map): Prefer defvar-keymap.
2022-07-20 09:27:10 +02:00
|
|
|
|
(defvar-keymap tool-bar-map
|
|
|
|
|
:doc "Keymap for the tool bar.
|
2019-10-12 07:30:36 +02:00
|
|
|
|
|
|
|
|
|
To override the global tool bar, define this variable
|
|
|
|
|
buffer-locally and add the items you want to it with
|
|
|
|
|
`tool-bar-add-item', `tool-bar-add-item-from-menu' and related
|
|
|
|
|
functions.")
|
2000-10-08 15:29:52 +00:00
|
|
|
|
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(defvar secondary-tool-bar-map nil
|
|
|
|
|
"Optional secondary keymap for the tool bar.
|
|
|
|
|
|
|
|
|
|
If non-nil, tool bar items defined within this map are displayed
|
|
|
|
|
in a line below the tool bar if the `tool-bar-position' frame
|
|
|
|
|
parameter is set to `top', and above the tool bar it is set to
|
|
|
|
|
`bottom'.")
|
|
|
|
|
|
2000-10-08 15:29:52 +00:00
|
|
|
|
(global-set-key [tool-bar]
|
Delete remaining calls to purecopy
* lisp/button.el (default-button):
* lisp/calendar/holidays.el (holiday-solar-holidays)
(holiday-bahai-holidays, holiday-islamic-holidays)
(holiday-christian-holidays, holiday-hebrew-holidays)
(holiday-oriental-holidays, holiday-general-holidays):
* lisp/comint.el (comint-file-name-prefix):
* lisp/composite.el (unicode-category-table):
* lisp/cus-face.el (custom-declare-face):
* lisp/custom.el (custom-add-load, custom-add-package-version)
(custom-add-version, custom-add-link, custom-declare-group)
(custom-declare-variable):
* lisp/dired.el (dired-listing-switches):
* lisp/epa-hook.el (epa-file-name-regexp):
* lisp/faces.el (x-font-regexp, x-font-regexp-head)
(x-font-regexp-slant, x-font-regexp-weight, )
(set-face-attribute, set-face-documentation, face-x-resources)
(face-font-registry-alternatives, face-font-family-alternatives)
(term-file-prefix):
* lisp/find-file.el (ff-special-constructs):
* lisp/format.el (format-alist):
* lisp/help.el (help-for-help):
* lisp/image-file.el (image-file-name-extensions):
* lisp/info.el:
* lisp/isearch.el (isearch-help-for-help-internal)
(search-whitespace-regexp):
* lisp/jka-cmpr-hook.el (jka-compr-load-suffixes)
(jka-compr-mode-alist-additions)
(jka-compr-compression-info-list, jka-compr-build-file-regexp):
* lisp/language/ethiopic.el (font-ccl-encoder-alist):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/language/tibetan.el (tibetan-precomposition-rule-regexp)
(tibetan-precomposed-regexp):
* lisp/locate.el (locate-ls-subdir-switches):
* lisp/lpr.el (lpr-command):
* lisp/mail/rmail.el (rmail-secondary-file-regexp)
(rmail-secondary-file-directory, rmail-highlighted-headers)
(rmail-ignored-headers, rmail-spool-directory, rmail-file-name):
* lisp/mail/sendmail.el (mail-default-directory)
(mail-signature-file, mail-citation-prefix-regexp)
(mail-personal-alias-file, mail-header-separator):
* lisp/menu-bar.el (yank-menu):
* lisp/net/eudc.el (eudc-tools-menu):
* lisp/newcomment.el (comment-padding, comment-end):
* lisp/obsolete/autoload.el (autoload-generate-file-autoloads):
* lisp/progmodes/hideshow.el (hs-special-modes-alist):
* lisp/ps-print.el (ps-page-dimensions-database):
* lisp/rfn-eshadow.el (file-name-shadow-tty-properties):
* lisp/shell.el (shell-dumb-shell-regexp):
* lisp/simple.el (overwrite-mode-binary, overwrite-mode-textual)
(mark-inactive, shell-command-switch)
(next-error-overlay-arrow-position):
* lisp/subr.el (package--builtin-versions, eval-after-load):
* lisp/tab-bar.el ([tab-bar]):
* lisp/term/pgtk-win.el (x-gtk-stock-map):
* lisp/term/x-win.el (x-gtk-stock-map):
* lisp/tool-bar.el ([tool-bar]):
* lisp/widget.el (define-widget): Remove calls to purecopy.
2024-12-09 21:26:25 +01:00
|
|
|
|
'(menu-item "tool bar" ignore
|
|
|
|
|
:filter tool-bar-make-keymap))
|
2008-05-07 18:16:28 +00:00
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
|
(declare-function image-mask-p "image.c" (spec &optional frame))
|
|
|
|
|
|
2022-05-03 19:20:52 +02:00
|
|
|
|
(defconst tool-bar-keymap-cache (make-hash-table :test #'equal))
|
|
|
|
|
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(defsubst tool-bar--cache-key ()
|
2024-01-26 10:08:30 -08:00
|
|
|
|
(cons (frame-terminal)
|
|
|
|
|
(sxhash-eq (if tool-bar-always-show-default (default-value 'tool-bar-map)
|
|
|
|
|
tool-bar-map))))
|
2008-11-27 03:29:37 +00:00
|
|
|
|
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(defsubst tool-bar--secondary-cache-key ()
|
|
|
|
|
(cons (frame-terminal) (sxhash-eq secondary-tool-bar-map)))
|
|
|
|
|
|
2022-05-03 18:19:13 +02:00
|
|
|
|
(defun tool-bar--flush-cache ()
|
2022-05-04 09:34:56 +02:00
|
|
|
|
"Remove all cached entries that refer to the current `tool-bar-map'."
|
|
|
|
|
(let ((id (sxhash-eq tool-bar-map))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(secondary-id (and secondary-tool-bar-map
|
|
|
|
|
(sxhash-eq secondary-tool-bar-map)))
|
2022-05-04 09:34:56 +02:00
|
|
|
|
(entries nil))
|
|
|
|
|
(maphash (lambda (k _)
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(when (or (equal (cdr k) id)
|
|
|
|
|
(equal (cdr k) secondary-id))
|
2022-05-04 09:34:56 +02:00
|
|
|
|
(push k entries)))
|
|
|
|
|
tool-bar-keymap-cache)
|
|
|
|
|
(dolist (k entries)
|
|
|
|
|
(remhash k tool-bar-keymap-cache))))
|
2022-05-03 18:19:13 +02:00
|
|
|
|
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(defun tool-bar-make-keymap (&optional _ignore)
|
2008-05-07 18:16:28 +00:00
|
|
|
|
"Generate an actual keymap from `tool-bar-map'.
|
2023-07-04 16:40:20 +08:00
|
|
|
|
If `secondary-tool-bar-map' is non-nil, take it into account as well.
|
2008-05-07 18:16:28 +00:00
|
|
|
|
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."
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(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)))
|
|
|
|
|
|
2024-01-08 13:20:25 -08:00
|
|
|
|
;; This function should return binds even if images can not be
|
|
|
|
|
;; displayed so the tool bar can still be displayed on terminals.
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(defun tool-bar-make-keymap-1 (&optional map)
|
|
|
|
|
"Generate an actual keymap from `tool-bar-map', without caching.
|
|
|
|
|
MAP is either a keymap to use as a source for menu items, or nil,
|
|
|
|
|
in which case the value of `tool-bar-map' is used instead."
|
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)))
|
2024-01-08 13:20:25 -08:00
|
|
|
|
(let ((image (and (display-images-p)
|
|
|
|
|
(eval image-exp))))
|
|
|
|
|
(unless (and image (image-mask-p image))
|
|
|
|
|
(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)))
|
2008-05-13 17:52:31 +00:00
|
|
|
|
bind))
|
2024-01-26 10:08:30 -08:00
|
|
|
|
(or map
|
|
|
|
|
(if tool-bar-always-show-default (default-value 'tool-bar-map)
|
|
|
|
|
tool-bar-map))))
|
2008-05-07 18:16:28 +00:00
|
|
|
|
|
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'."
|
2022-05-03 18:19:13 +02:00
|
|
|
|
(apply #'tool-bar-local-item icon def key tool-bar-map props)
|
|
|
|
|
(tool-bar--flush-cache))
|
2002-04-01 16:28:16 +00:00
|
|
|
|
|
2010-12-20 08:17:26 +08: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))
|
2024-06-03 20:37:41 +08:00
|
|
|
|
(if (eq bg 'unspecified) nil (list :background bg))))
|
2010-12-20 08:17:26 +08:00
|
|
|
|
(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
|
2020-12-08 13:57:44 +01:00
|
|
|
|
',(list xpm-spec pbm-spec xbm-spec)))
|
|
|
|
|
t)))
|
2010-12-20 08:17:26 +08:00
|
|
|
|
|
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 08:17:26 +08: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 17:29:51 +02:00
|
|
|
|
`(menu-item ,(symbol-name key) ,def :image ,image-exp ,@props))
|
2022-05-03 18:46:05 +02:00
|
|
|
|
(tool-bar--flush-cache)
|
2015-01-01 17:29:51 +02:00
|
|
|
|
(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'."
|
2020-10-27 01:29:43 +01:00
|
|
|
|
(apply #'tool-bar-local-item-from-menu command icon
|
2002-07-16 22:46:09 +00:00
|
|
|
|
(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 08:17:26 +08: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 12:26:11 -04: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 09:23:01 +02:00
|
|
|
|
(symbolp kk))
|
2008-05-07 18:16:28 +00:00
|
|
|
|
(setq submap m
|
|
|
|
|
key kk)))))
|
2010-04-25 09:23:01 +02: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 09:23:01 +02: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 17:29:51 +02:00
|
|
|
|
(list :image image-exp) props))))
|
2022-05-03 18:46:05 +02:00
|
|
|
|
(tool-bar--flush-cache)
|
2015-01-01 17:29:51 +02:00
|
|
|
|
(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 08:17:26 +08:00
|
|
|
|
(setq tool-bar-separator-image-expression
|
|
|
|
|
(tool-bar--image-expression "separator"))
|
2010-11-20 15:51:25 +01: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 12:04:06 +08:00
|
|
|
|
:label "Open" :vert-only t)
|
2010-11-20 15:51:25 +01: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 08:17:26 +08:00
|
|
|
|
(tool-bar-add-item-from-menu 'save-buffer "save" nil
|
2010-12-28 17:39:25 +08:00
|
|
|
|
:label "Save")
|
2010-12-17 12:04:06 +08:00
|
|
|
|
(define-key-after (default-value 'tool-bar-map) [separator-1] menu-bar-separator)
|
2011-01-08 23:13:47 -05:00
|
|
|
|
(tool-bar-add-item-from-menu 'undo "undo" nil)
|
2010-12-17 12:04:06 +08: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 17:39:25 +08: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 15:51:25 +01: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 17:39:25 +08:00
|
|
|
|
"paste" nil :vert-only t)
|
2010-12-17 12:04:06 +08:00
|
|
|
|
(define-key-after (default-value 'tool-bar-map) [separator-3] menu-bar-separator)
|
2011-01-08 23:13:47 -05: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-08 23:13:47 -05: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 09:01:22 +02:00
|
|
|
|
(if (featurep 'move-toolbar)
|
|
|
|
|
(defcustom tool-bar-position 'top
|
|
|
|
|
"Specify on which side the tool bar shall be.
|
2024-05-08 20:25:47 +08:00
|
|
|
|
Possible values are `top' (tool bar on top), `bottom' (tool bar at
|
|
|
|
|
bottom), `left' (tool bar on left) and `right' (tool bar on right).
|
|
|
|
|
This option takes effect only on graphical frames, the values `left' and
|
|
|
|
|
`right' only if Emacs was built with GTK, and `bottom' only on systems
|
|
|
|
|
besides Nextstep. 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 14:13:29 -08:00
|
|
|
|
:version "24.1"
|
2010-09-21 09:01:22 +02: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-28 20:29:29 -07:00
|
|
|
|
(modify-all-frames-parameters
|
2010-09-21 09:01:22 +02:00
|
|
|
|
(list (cons 'tool-bar-position val))))))
|
|
|
|
|
|
2024-01-26 10:08:30 -08:00
|
|
|
|
(defcustom tool-bar-always-show-default nil
|
|
|
|
|
"If non-nil, `tool-bar-mode' only shows the default tool bar.
|
|
|
|
|
This works well when also using `global-window-tool-bar-mode' to
|
|
|
|
|
display buffer-specific tool bars."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'frames
|
|
|
|
|
:group 'mouse
|
|
|
|
|
:version "30.1")
|
|
|
|
|
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
|
2023-07-07 10:00:56 +08:00
|
|
|
|
;; Modifier bar mode.
|
2023-07-04 16:40:20 +08:00
|
|
|
|
;; This displays a small tool bar containing modifier keys
|
|
|
|
|
;; above or below the main tool bar itself.
|
|
|
|
|
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(defvar modifier-bar-modifier-list nil
|
|
|
|
|
"List of modifiers that are currently applied.
|
|
|
|
|
Each symbol in this list represents a modifier button that has
|
|
|
|
|
been pressed as part of decoding this key sequence.")
|
|
|
|
|
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(declare-function set-text-conversion-style "textconv.c")
|
|
|
|
|
|
|
|
|
|
;; These functions are very similar to their counterparts in
|
|
|
|
|
;; simple.el, but allow combining multiple modifier buttons together.
|
|
|
|
|
|
|
|
|
|
(defun tool-bar-apply-modifiers (event modifiers)
|
|
|
|
|
"Apply the specified list of MODIFIERS to EVENT.
|
|
|
|
|
MODIFIERS must be a list containing only the symbols `alt',
|
|
|
|
|
`super', `hyper', `shift', `control' and `meta'.
|
|
|
|
|
Return EVENT with the specified modifiers applied."
|
|
|
|
|
(dolist (modifier modifiers)
|
|
|
|
|
(cond
|
|
|
|
|
((eq modifier 'alt)
|
|
|
|
|
(setq event (event-apply-modifier event 'alt 22 "A-")))
|
|
|
|
|
((eq modifier 'super)
|
|
|
|
|
(setq event (event-apply-modifier event 'super 23 "s-")))
|
|
|
|
|
((eq modifier 'hyper)
|
|
|
|
|
(setq event (event-apply-modifier event 'hyper 24 "H-")))
|
|
|
|
|
((eq modifier 'shift)
|
|
|
|
|
(setq event (event-apply-modifier event 'shift 25 "S-")))
|
|
|
|
|
((eq modifier 'control)
|
|
|
|
|
(setq event (event-apply-modifier event 'control 26 "C-")))
|
|
|
|
|
((eq modifier 'meta)
|
|
|
|
|
(setq event (event-apply-modifier event 'meta 27 "M-")))))
|
|
|
|
|
event)
|
|
|
|
|
|
|
|
|
|
(defvar overriding-text-conversion-style)
|
|
|
|
|
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(defun modifier-bar-button (init-modifier-list)
|
|
|
|
|
"Decode the key sequence associated with a modifier bar button.
|
|
|
|
|
INIT-MODIFIER-LIST is a list of one symbol describing the button
|
|
|
|
|
being pressed.
|
|
|
|
|
|
|
|
|
|
Bind `modifier-bar-modifier-list' to INIT-MODIFIER-LIST. Read
|
|
|
|
|
events, adding each subsequent modifier bar event's associated
|
|
|
|
|
modifier to that list while updating the tool bar to disable
|
|
|
|
|
buttons that were pressed. Return any other event read with all
|
|
|
|
|
modifier keys read applied.
|
|
|
|
|
|
|
|
|
|
Temporarily disable text conversion and display the on screen
|
|
|
|
|
keyboard while doing so."
|
2023-07-04 16:40:20 +08:00
|
|
|
|
;; Save the previously used text conversion style.
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(let ((old-text-conversion-style text-conversion-style)
|
|
|
|
|
;; Clear the list of modifiers currently pressed.
|
|
|
|
|
(modifier-bar-modifier-list init-modifier-list))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
;; Disable text conversion.
|
|
|
|
|
(when (fboundp 'set-text-conversion-style)
|
|
|
|
|
(set-text-conversion-style nil))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
;; Display the on screen keyboard.
|
|
|
|
|
(frame-toggle-on-screen-keyboard nil nil)
|
2023-07-07 10:00:56 +08:00
|
|
|
|
;; Update the tool bar to disable this modifier key.
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(let* ((modifiers init-modifier-list) event1
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(overriding-text-conversion-style nil)
|
|
|
|
|
(event (read-event)))
|
|
|
|
|
;; Combine any more modifier key presses.
|
|
|
|
|
(while (eq event 'tool-bar)
|
|
|
|
|
(setq event1 (event-basic-type (read-event)))
|
|
|
|
|
;; Reject unknown tool bar events.
|
|
|
|
|
(unless (memq event1 '(alt super hyper shift control meta))
|
|
|
|
|
(user-error "Unknown tool-bar event %s" event1))
|
|
|
|
|
;; If `event' is the name of a modifier key, apply that
|
|
|
|
|
;; modifier key as well.
|
|
|
|
|
(unless (memq event1 modifiers)
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(push event1 modifiers)
|
|
|
|
|
;; This list is used to check which tool bar buttons
|
|
|
|
|
;; need to be enabled.
|
|
|
|
|
(push event1 modifier-bar-modifier-list))
|
|
|
|
|
;; Update the tool bar to disable the modifier button
|
|
|
|
|
;; that was read.
|
|
|
|
|
(force-mode-line-update)
|
|
|
|
|
(redisplay)
|
2023-07-04 16:40:20 +08:00
|
|
|
|
;; Read another event.
|
|
|
|
|
(setq event (read-event)))
|
|
|
|
|
;; EVENT is a keyboard event to which the specified list of
|
|
|
|
|
;; modifier keys should be applied.
|
|
|
|
|
(vector (tool-bar-apply-modifiers event modifiers))))
|
|
|
|
|
;; Re-enable text conversion if necessary.
|
|
|
|
|
(unless (or (not (fboundp 'set-text-conversion-style))
|
|
|
|
|
(eq old-text-conversion-style text-conversion-style))
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(set-text-conversion-style old-text-conversion-style t))
|
|
|
|
|
;; Re-enable all modifier bar buttons which may have been
|
|
|
|
|
;; disabled.
|
|
|
|
|
(force-mode-line-update))))
|
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-alt-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-alt-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
|
|
|
|
(modifier-bar-button '(alt)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-super-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-super-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(modifier-bar-button '(super)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-hyper-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-hyper-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(modifier-bar-button '(hyper)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-shift-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-shift-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(modifier-bar-button '(shift)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-control-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-control-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(modifier-bar-button '(control)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(defun tool-bar-event-apply-meta-modifier (_ignore-prompt)
|
|
|
|
|
"Like `event-apply-meta-modifier'.
|
|
|
|
|
However, take additional modifier tool bar items into account;
|
|
|
|
|
apply any extra modifiers bound to subsequent `tool-bar' events."
|
2023-07-07 10:00:56 +08:00
|
|
|
|
(modifier-bar-button '(meta)))
|
|
|
|
|
|
|
|
|
|
(defun modifier-bar-available-p (modifier)
|
|
|
|
|
"Return whether the modifier button for MODIFIER should be enabled.
|
|
|
|
|
Return t if MODIFIER has not yet been selected as part of
|
|
|
|
|
decoding the current key sequence, nil otherwise."
|
|
|
|
|
(not (memq modifier modifier-bar-modifier-list)))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
|
|
|
|
(define-minor-mode modifier-bar-mode
|
2025-04-24 12:32:02 +03:00
|
|
|
|
"Toggle display of the key-modifier tool bar.
|
2023-07-04 16:40:20 +08:00
|
|
|
|
|
2025-04-24 12:32:02 +03:00
|
|
|
|
When enabled, a small tool bar will be displayed in addition to the
|
|
|
|
|
regular tool bar, containing buttons for key modifiers such as
|
|
|
|
|
Ctrl, Shift, Alt, etc. This is useful on terminals whose keyboard
|
|
|
|
|
has no keys for these modifiers, such as smartphones and other
|
|
|
|
|
devices with small keyboards."
|
2023-07-04 16:40:20 +08:00
|
|
|
|
:init-value nil
|
|
|
|
|
:global t
|
|
|
|
|
:group 'tool-bar
|
|
|
|
|
(if modifier-bar-mode
|
|
|
|
|
(progn
|
|
|
|
|
(setq secondary-tool-bar-map
|
|
|
|
|
;; The commands specified in the menu items here are not
|
|
|
|
|
;; used. Instead, Emacs relies on each of the tool bar
|
|
|
|
|
;; events being specified in `input-decode-map'.
|
|
|
|
|
`(keymap (control menu-item "Control Key"
|
|
|
|
|
event-apply-control-modifier
|
|
|
|
|
:help "Add Control modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "ctrl")
|
|
|
|
|
:enable (modifier-bar-available-p 'control))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(shift menu-item "Shift Key"
|
|
|
|
|
event-apply-shift-modifier
|
|
|
|
|
:help "Add Shift modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "shift")
|
|
|
|
|
:enable (modifier-bar-available-p 'shift))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(meta menu-item "Meta Key"
|
|
|
|
|
event-apply-meta-modifier
|
|
|
|
|
:help "Add Meta modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "meta")
|
|
|
|
|
:enable (modifier-bar-available-p 'meta))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(alt menu-item "Alt Key"
|
|
|
|
|
event-apply-alt-modifier
|
|
|
|
|
:help "Add Alt modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "alt")
|
|
|
|
|
:enable (modifier-bar-available-p 'alt))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(super menu-item "Super Key"
|
|
|
|
|
event-apply-super-modifier
|
|
|
|
|
:help "Add Super modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "super")
|
|
|
|
|
:enable (modifier-bar-available-p 'super))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(hyper menu-item "Hyper Key"
|
|
|
|
|
event-apply-hyper-modifier
|
|
|
|
|
:help "Add Hyper modifier to the following event"
|
2023-07-07 10:00:56 +08:00
|
|
|
|
:image ,(tool-bar--image-expression "hyper")
|
|
|
|
|
:enable (modifier-bar-available-p 'hyper))))
|
2023-07-04 16:40:20 +08:00
|
|
|
|
(define-key input-decode-map [tool-bar control]
|
|
|
|
|
#'tool-bar-event-apply-control-modifier)
|
|
|
|
|
(define-key input-decode-map [tool-bar shift]
|
|
|
|
|
#'tool-bar-event-apply-shift-modifier)
|
|
|
|
|
(define-key input-decode-map [tool-bar meta]
|
|
|
|
|
#'tool-bar-event-apply-meta-modifier)
|
|
|
|
|
(define-key input-decode-map [tool-bar alt]
|
|
|
|
|
#'tool-bar-event-apply-alt-modifier)
|
|
|
|
|
(define-key input-decode-map [tool-bar super]
|
|
|
|
|
#'tool-bar-event-apply-super-modifier)
|
|
|
|
|
(define-key input-decode-map [tool-bar hyper]
|
|
|
|
|
#'tool-bar-event-apply-hyper-modifier))
|
|
|
|
|
(setq secondary-tool-bar-map nil))
|
2023-07-07 10:00:56 +08:00
|
|
|
|
;; Update the mode line now.
|
|
|
|
|
(force-mode-line-update t))
|
2000-09-19 17:36:49 +00:00
|
|
|
|
|
2006-05-03 11:56:53 +00:00
|
|
|
|
(provide 'tool-bar)
|
2010-10-28 20:29:29 -07:00
|
|
|
|
|
2000-09-19 17:36:49 +00:00
|
|
|
|
;;; tool-bar.el ends here
|