;;; scroll-bar.el --- window system-independent scroll bar support
;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: hardware
;; 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)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;;;; 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.
(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.
(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.