Function: tool-bar-mode
tool-bar-mode is an interactive and byte-compiled function defined in
tool-bar.el.gz.
Signature
(tool-bar-mode &optional ARG)
Documentation
Toggle the tool bar in all graphical frames (Tool Bar mode).
See tool-bar-add-item and tool-bar-add-item-from-menu for
conveniently adding tool bar items.
This is a global minor mode. If called interactively, toggle the
Tool-Bar mode mode. If the prefix argument is positive, enable the
mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate the variable tool-bar-mode(var)/tool-bar-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
Probably introduced at or before Emacs version 24.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/tool-bar.el.gz
;;; tool-bar.el --- setting up the tool bar -*- lexical-binding: t -*-
;; Copyright (C) 2000-2025 Free Software Foundation, Inc.
;; Author: Dave Love <fx@gnu.org>
;; Keywords: mouse frames
;; Package: emacs
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; 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
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Provides `tool-bar-mode' to control display of the tool-bar and
;; bindings for the global tool bar with convenience functions
;; `tool-bar-add-item' and `tool-bar-add-item-from-menu'.
;; The normal global binding for [tool-bar] (below) uses the value of
;; `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'
;; buffer-locally to override it. (Some items are removed from the
;; global bar in modes which have `special' as their `mode-class'
;; property.)
;; Todo: Somehow make tool bars easily customizable by the naive?
;;; Code:
;; 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.
(define-minor-mode tool-bar-mode
"Toggle the tool bar in all graphical frames (Tool Bar mode).
See `tool-bar-add-item' and `tool-bar-add-item-from-menu' for
conveniently adding tool bar items."
:init-value t
:global t
;; It's defined in C/cus-start, this stops the d-m-m macro defining it again.
:variable tool-bar-mode
(let ((val (if tool-bar-mode 1 0)))
(dolist (frame (frame-list))
(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)))