]> code.delx.au - gnu-emacs/blobdiff - lisp/scroll-bar.el
* server.el (server-buffer-done): Avoid changing the buffer when
[gnu-emacs] / lisp / scroll-bar.el
index 2d2921e9fc9b578d4f7dfdd58fceeeac7e19354e..f12e0b42b9459ae9fd8100724c00c789c6f5e2ca 100644 (file)
@@ -1,17 +1,17 @@
 ;;; scroll-bar.el --- window system-independent scroll bar support
 
-;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2003
-;;  Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: hardware
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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 2, or (at your option)
-;; any later version.
+;; 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
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -75,6 +73,7 @@ SIDE must be the symbol `left' or `right'."
 ;;;; Helpful functions for enabling and disabling scroll bars.
 
 (defvar scroll-bar-mode)
+(defvar previous-scroll-bar-mode nil)
 
 (defvar scroll-bar-mode-explicit nil
   "Non-nil means `set-scroll-bar-mode' should really do something.
@@ -85,24 +84,14 @@ This is nil while loading `scroll-bar.el', and t afterward.")
 
 (defun set-scroll-bar-mode (value)
   "Set `scroll-bar-mode' to VALUE and put the new value into effect."
+  (if scroll-bar-mode
+      (setq previous-scroll-bar-mode scroll-bar-mode))
+
   (setq scroll-bar-mode value)
 
   (when scroll-bar-mode-explicit
-    ;; Apply it to default-frame-alist.
-    (let ((parameter (assq 'vertical-scroll-bars default-frame-alist)))
-      (if (consp parameter)
-         (setcdr parameter scroll-bar-mode)
-       (setq default-frame-alist
-             (cons (cons 'vertical-scroll-bars scroll-bar-mode)
-                   default-frame-alist))))
-
-    ;; Apply it to existing frames.
-    (let ((frames (frame-list)))
-      (while frames
-       (modify-frame-parameters
-        (car frames)
-        (list (cons 'vertical-scroll-bars scroll-bar-mode)))
-       (setq frames (cdr frames))))))
+    (modify-all-frames-parameters (list (cons 'vertical-scroll-bars
+                                             scroll-bar-mode)))))
 
 (defcustom scroll-bar-mode default-frame-scroll-bars
   "*Specify whether to have vertical scroll bars, and on which side.
@@ -137,7 +126,8 @@ turn off scroll bars; otherwise, turn on scroll bars."
                               (not scroll-bar-mode)
                             (setq flag (prefix-numeric-value flag))
                             (or (not (numberp flag)) (>= flag 0)))
-                          default-frame-scroll-bars)))
+                          (or previous-scroll-bar-mode
+                              default-frame-scroll-bars))))
 
 (defun toggle-scroll-bar (arg)
   "Toggle whether or not the selected frame has vertical scroll bars.
@@ -368,5 +358,5 @@ EVENT should be a scroll bar click."
 \f
 (provide 'scroll-bar)
 
-;;; arch-tag: 6f1d01d0-0b1e-4bf8-86db-d491e0f399f3
+;; arch-tag: 6f1d01d0-0b1e-4bf8-86db-d491e0f399f3
 ;;; scroll-bar.el ends here