changeset 98658:3e7bd62df13a

(tool-bar-setup): Variable deleted. (tool-bar-setup): Set it up unconditionally.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 12 Oct 2008 13:45:46 +0000
parents 3780bdf31ec4
children f19f5a4863df
files lisp/tool-bar.el
diffstat 1 files changed, 52 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/tool-bar.el	Sun Oct 12 13:45:29 2008 +0000
+++ b/lisp/tool-bar.el	Sun Oct 12 13:45:46 2008 +0000
@@ -57,7 +57,8 @@
   	(dolist (frame (frame-list))
   	  (if (display-graphic-p frame)
   	      (set-frame-parameter frame 'tool-bar-lines 1)))
-  	(tool-bar-setup))
+	(if (= 1 (length (default-value 'tool-bar-map))) ; not yet setup
+	    (tool-bar-setup)))
     (modify-all-frames-parameters (list (cons 'tool-bar-lines 0)))))
 
 ;;;###autoload
@@ -258,66 +259,59 @@
 
 ;;; Set up some global items.  Additions/deletions up for grabs.
 
-(defvar tool-bar-setup nil
-  "Non-nil if the tool-bar has been set up by `tool-bar-setup'.")
+(defun tool-bar-setup ()
+  ;; People say it's bad to have EXIT on the tool bar, since users
+  ;; might inadvertently click that button.
+  ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
+  (tool-bar-add-item-from-menu 'find-file "new")
+  (tool-bar-add-item-from-menu 'menu-find-file-existing "open")
+  (tool-bar-add-item-from-menu 'dired "diropen")
+  (tool-bar-add-item-from-menu 'kill-this-buffer "close")
+  (tool-bar-add-item-from-menu 'save-buffer "save" nil
+			       :visible '(or buffer-file-name
+					     (not (eq 'special
+						      (get major-mode
+							   'mode-class)))))
+  (tool-bar-add-item-from-menu 'write-file "saveas" nil
+			       :visible '(or buffer-file-name
+					     (not (eq 'special
+						      (get major-mode
+							   'mode-class)))))
+  (tool-bar-add-item-from-menu 'undo "undo" nil
+			       :visible '(not (eq 'special (get major-mode
+								'mode-class))))
+  (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
+			       "cut" nil
+			       :visible '(not (eq 'special (get major-mode
+								'mode-class))))
+  (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
+			       "copy")
+  (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
+			       "paste" nil
+			       :visible '(not (eq 'special (get major-mode
+								'mode-class))))
+  (tool-bar-add-item-from-menu 'nonincremental-search-forward "search")
+  ;;(tool-bar-add-item-from-menu 'ispell-buffer "spell")
 
-(defun tool-bar-setup (&optional frame)
-  (unless (or tool-bar-setup
-	      (null tool-bar-mode))
-    (with-selected-frame (or frame (selected-frame))
-      ;; People say it's bad to have EXIT on the tool bar, since users
-      ;; might inadvertently click that button.
-      ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
-      (tool-bar-add-item-from-menu 'find-file "new")
-      (tool-bar-add-item-from-menu 'menu-find-file-existing "open")
-      (tool-bar-add-item-from-menu 'dired "diropen")
-      (tool-bar-add-item-from-menu 'kill-this-buffer "close")
-      (tool-bar-add-item-from-menu 'save-buffer "save" nil
-				   :visible '(or buffer-file-name
-						 (not (eq 'special
-							  (get major-mode
-							       'mode-class)))))
-      (tool-bar-add-item-from-menu 'write-file "saveas" nil
-				   :visible '(or buffer-file-name
-						 (not (eq 'special
-							  (get major-mode
-							       'mode-class)))))
-      (tool-bar-add-item-from-menu 'undo "undo" nil
-				   :visible '(not (eq 'special (get major-mode
-								    'mode-class))))
-      (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [cut])
-				   "cut" nil
-				   :visible '(not (eq 'special (get major-mode
-								    'mode-class))))
-      (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [copy])
-				   "copy")
-      (tool-bar-add-item-from-menu (lookup-key menu-bar-edit-menu [paste])
-				   "paste" nil
-				   :visible '(not (eq 'special (get major-mode
-								    'mode-class))))
-      (tool-bar-add-item-from-menu 'nonincremental-search-forward "search")
-      ;;(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")
+
+  (tool-bar-add-item-from-menu 'print-buffer "print")
+
+  ;; tool-bar-add-item-from-menu itself operates on
+  ;; (default-value 'tool-bar-map), but when we don't use that function,
+  ;; we must explicitly operate on the default value.
 
-      ;; 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")
-
-      (tool-bar-add-item-from-menu 'print-buffer "print")
-
-      ;; tool-bar-add-item-from-menu itself operates on
-      ;; (default-value 'tool-bar-map), but when we don't use that function,
-      ;; we must explicitly operate on the default value.
+  (let ((tool-bar-map (default-value 'tool-bar-map)))
+    (tool-bar-add-item "preferences" 'customize 'customize
+		       :help "Edit preferences (customize)")
 
-      (let ((tool-bar-map (default-value 'tool-bar-map)))
-        (tool-bar-add-item "preferences" 'customize 'customize
-                           :help "Edit preferences (customize)")
-
-        (tool-bar-add-item "help" (lambda ()
-                                    (interactive)
-                                    (popup-menu menu-bar-help-menu))
-                           'help
-                           :help "Pop up the Help menu"))
-      (setq tool-bar-setup t))))
+    (tool-bar-add-item "help" (lambda ()
+				(interactive)
+				(popup-menu menu-bar-help-menu))
+		       'help
+		       :help "Pop up the Help menu")))
 
 
 (provide 'tool-bar)