aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/scroll-bar.el52
1 files changed, 30 insertions, 22 deletions
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 3e30e1b5e7d..8fd62f02898 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -48,9 +48,6 @@ that scroll bar position."
48 48
49 49
50;;;; Helpful functions for enabling and disabling scroll bars. 50;;;; Helpful functions for enabling and disabling scroll bars.
51;;; This is not documented because you can't change the
52;;; mode properly by setting it.
53(defvar scroll-bar-mode t)
54 51
55(defun scroll-bar-mode (flag) 52(defun scroll-bar-mode (flag)
56 "Toggle display of vertical scroll bars on each frame. 53 "Toggle display of vertical scroll bars on each frame.
@@ -59,25 +56,36 @@ created in the future.
59With a numeric argument, if the argument is negative, 56With a numeric argument, if the argument is negative,
60turn off scroll bars; otherwise, turn on scroll bars." 57turn off scroll bars; otherwise, turn on scroll bars."
61 (interactive "P") 58 (interactive "P")
62 (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode) 59
63 (or (not (numberp flag)) (>= flag 0)))) 60 ;; Obtain the current setting by looking at default-frame-alist.
64 (mapcar 61 (let ((scroll-bar-mode
65 (function 62 (let ((assq (assq 'vertical-scroll-bars default-frame-alist)))
66 (lambda (param-name) 63 (if assq (cdr assq) t))))
67 (let ((parameter (assq param-name default-frame-alist))) 64
68 (if (consp parameter) 65 ;; Tweedle it according to the argument.
69 (setcdr parameter scroll-bar-mode) 66 (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode)
70 (setq default-frame-alist 67 (or (not (numberp flag)) (>= flag 0))))
71 (cons (cons param-name scroll-bar-mode) 68
72 default-frame-alist)))))) 69 ;; Apply it to default-frame-alist.
73 '(vertical-scroll-bars horizontal-scroll-bars)) 70 (mapcar
74 (let ((frames (frame-list))) 71 (function
75 (while frames 72 (lambda (param-name)
76 (modify-frame-parameters 73 (let ((parameter (assq param-name default-frame-alist)))
77 (car frames) 74 (if (consp parameter)
78 (list (cons 'vertical-scroll-bars scroll-bar-mode) 75 (setcdr parameter scroll-bar-mode)
79 (cons 'horizontal-scroll-bars scroll-bar-mode))) 76 (setq default-frame-alist
80 (setq frames (cdr frames))))) 77 (cons (cons param-name scroll-bar-mode)
78 default-frame-alist))))))
79 '(vertical-scroll-bars horizontal-scroll-bars))
80
81 ;; Apply it to existing frames.
82 (let ((frames (frame-list)))
83 (while frames
84 (modify-frame-parameters
85 (car frames)
86 (list (cons 'vertical-scroll-bars scroll-bar-mode)
87 (cons 'horizontal-scroll-bars scroll-bar-mode)))
88 (setq frames (cdr frames))))))
81 89
82;;;; Buffer navigation using the scroll bar. 90;;;; Buffer navigation using the scroll bar.
83 91