(file-cache-minibuffer-complete): Accept a prefix arg.
[bpt/emacs.git] / lisp / scroll-bar.el
index 8e07f3a..f94fc67 100644 (file)
@@ -58,25 +58,33 @@ that scroll bar position."
 
 (defvar scroll-bar-mode)
 
-(defun set-scroll-bar-mode (ignore value)
+(defvar scroll-bar-mode-explicit nil
+  "Non-nil means `set-scroll-bar-mode' should really do something.
+This is nil while loading `scroll-bar.el', and t afterward.")
+
+(defun set-scroll-bar-mode-1 (ignore value)
+  (set-scroll-bar-mode value))
+
+(defun set-scroll-bar-mode (value)
   "Set `scroll-bar-mode' to VALUE and put the new value into effect."
   (setq scroll-bar-mode value)
 
-  ;; 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)))))
+  (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))))))
 
 (defcustom scroll-bar-mode 'left
   "*Specify whether to have vertical scroll bars, and on which side.
@@ -90,7 +98,11 @@ it takes effect immediately for all frames."
                 (const left)
                 (const right))
   :group 'frames
-  :set 'set-scroll-bar-mode)
+  :set 'set-scroll-bar-mode-1)
+
+;; We just set scroll-bar-mode, but that was the default.
+;; If it is set again, that is for real.
+(setq scroll-bar-mode-explicit t)
 
 (defun scroll-bar-mode (flag)
   "Toggle display of vertical scroll bars on all frames.
@@ -102,8 +114,7 @@ turn off scroll bars; otherwise, turn on scroll bars."
   (if flag (setq flag (prefix-numeric-value flag)))
 
   ;; Tweedle the variable according to the argument.
-  (set-scroll-bar-mode nil
-                      (if (null flag) (not scroll-bar-mode)
+  (set-scroll-bar-mode (if (null flag) (not scroll-bar-mode)
                         (and (or (not (numberp flag)) (>= flag 0))
                              'left))))
 
@@ -117,7 +128,8 @@ when they are turned on; if it is nil, they go on the left."
       (setq arg
            (if (cdr (assq 'vertical-scroll-bars
                           (frame-parameters (selected-frame))))
-               -1 1)))
+               -1 1))
+    (setq arg (prefix-numeric-value arg)))
   (modify-frame-parameters (selected-frame)
                           (list (cons 'vertical-scroll-bars
                                       (if (> arg 0)
@@ -177,7 +189,7 @@ EVENT should be a scroll bar click or drag event."
       (setq next-portion-start (max
                                (scroll-bar-drag-position next-portion-whole)
                                (1+ portion-start)))
-      (if (or (> current-start next-portion-start)
+      (if (or (>= current-start next-portion-start)
              (< current-start portion-start))
          (set-window-start window portion-start)
        ;; Always set window start, to ensure scroll bar position is updated.