aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMartin Rudalics2014-09-03 17:10:29 +0200
committerMartin Rudalics2014-09-03 17:10:29 +0200
commit568df136f13451a098d166918b9602cf8dedf976 (patch)
treed9870a3b614c9f10d2f626e7481c796b750f171b /lisp
parent62fca47221fc9d248511cd94fbcb41ddb46763e6 (diff)
downloademacs-568df136f13451a098d166918b9602cf8dedf976.tar.gz
emacs-568df136f13451a098d166918b9602cf8dedf976.zip
Clean up initialization and customization of horizontal scroll bars.
* frame.el (frame-initialize): Remove horizontal-scroll-bars from frame-initial-frame-alist. * scroll-bar.el (previous-horizontal-scroll-bar-mode) (horizontal-scroll-bar-mode-explicit) (set-horizontal-scroll-bar-mode, get-horizontal-scroll-bar-mode) (toggle-horizontal-scroll-bar): Remove. (horizontal-scroll-bar-mode): Remove defcustom. (horizontal-scroll-bar-mode): Fix doc-string. (scroll-bar-toolkit-scroll) (scroll-bar-toolkit-horizontal-scroll): Add doc-strings stubs. * buffer.c (scroll-bar-height): Fix typo in doc-string. * frame.c (Vdefault_frame_horizontal_scroll_bars): Remove variable. * nsfns.m (Fx_create_frame): * w32fns.c (Fx_create_frame): * xfns.c (Fx_create_frame): Default horizontal scroll bars to nil.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/frame.el4
-rw-r--r--lisp/scroll-bar.el68
3 files changed, 26 insertions, 59 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 29fec987a2e..d4bb37d32c6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12014-09-03 Martin Rudalics <rudalics@gmx.at>
2
3 * frame.el (frame-initialize): Remove horizontal-scroll-bars
4 from frame-initial-frame-alist.
5 * scroll-bar.el (previous-horizontal-scroll-bar-mode)
6 (horizontal-scroll-bar-mode-explicit)
7 (set-horizontal-scroll-bar-mode, get-horizontal-scroll-bar-mode)
8 (toggle-horizontal-scroll-bar): Remove.
9 (horizontal-scroll-bar-mode): Remove defcustom.
10 (horizontal-scroll-bar-mode): Fix doc-string.
11 (scroll-bar-toolkit-scroll)
12 (scroll-bar-toolkit-horizontal-scroll): Add doc-strings stubs.
13
12014-09-03 Stefan Monnier <monnier@iro.umontreal.ca> 142014-09-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 15
3 * emacs-lisp/package.el (package-generate-description-file): 16 * emacs-lisp/package.el (package-generate-description-file):
diff --git a/lisp/frame.el b/lisp/frame.el
index d528eef6735..f144cf23405 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -174,10 +174,6 @@ This function runs the hook `focus-out-hook'."
174 (progn 174 (progn
175 (setq frame-initial-frame-alist 175 (setq frame-initial-frame-alist
176 (append initial-frame-alist default-frame-alist nil)) 176 (append initial-frame-alist default-frame-alist nil))
177 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
178 (setq frame-initial-frame-alist
179 (cons '(horizontal-scroll-bars . t)
180 frame-initial-frame-alist)))
181 (setq frame-initial-frame-alist 177 (setq frame-initial-frame-alist
182 (cons (cons 'window-system initial-window-system) 178 (cons (cons 'window-system initial-window-system)
183 frame-initial-frame-alist)) 179 frame-initial-frame-alist))
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 2dd394fa2af..588ac3b0f8a 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -90,16 +90,11 @@ SIDE must be the symbol `left' or `right'."
90(defvar scroll-bar-mode) 90(defvar scroll-bar-mode)
91(defvar horizontal-scroll-bar-mode) 91(defvar horizontal-scroll-bar-mode)
92(defvar previous-scroll-bar-mode nil) 92(defvar previous-scroll-bar-mode nil)
93(defvar previous-horizontal-scroll-bar-mode nil)
94 93
95(defvar scroll-bar-mode-explicit nil 94(defvar scroll-bar-mode-explicit nil
96 "Non-nil means `set-scroll-bar-mode' should really do something. 95 "Non-nil means `set-scroll-bar-mode' should really do something.
97This is nil while loading `scroll-bar.el', and t afterward.") 96This is nil while loading `scroll-bar.el', and t afterward.")
98 97
99(defvar horizontal-scroll-bar-mode-explicit nil
100 "Non-nil means `set-horizontal-scroll-bar-mode' should really do something.
101This is nil while loading `scroll-bar.el', and t afterward.")
102
103(defun set-scroll-bar-mode (value) 98(defun set-scroll-bar-mode (value)
104 "Set the scroll bar mode to VALUE and put the new value into effect. 99 "Set the scroll bar mode to VALUE and put the new value into effect.
105See the `scroll-bar-mode' variable for possible values to use." 100See the `scroll-bar-mode' variable for possible values to use."
@@ -112,18 +107,6 @@ See the `scroll-bar-mode' variable for possible values to use."
112 (modify-all-frames-parameters (list (cons 'vertical-scroll-bars 107 (modify-all-frames-parameters (list (cons 'vertical-scroll-bars
113 scroll-bar-mode))))) 108 scroll-bar-mode)))))
114 109
115(defun set-horizontal-scroll-bar-mode (value)
116 "Set the horizontal scroll bar mode to VALUE and put the new value into effect.
117See the `horizontal-scroll-bar-mode' variable for possible values to use."
118 (if horizontal-scroll-bar-mode
119 (setq previous-horizontal-scroll-bar-mode horizontal-scroll-bar-mode))
120
121 (setq horizontal-scroll-bar-mode value)
122
123 (when horizontal-scroll-bar-mode-explicit
124 (modify-all-frames-parameters (list (cons 'horizontal-scroll-bars
125 horizontal-scroll-bar-mode)))))
126
127(defcustom scroll-bar-mode default-frame-scroll-bars 110(defcustom scroll-bar-mode default-frame-scroll-bars
128 "Specify whether to have vertical scroll bars, and on which side. 111 "Specify whether to have vertical scroll bars, and on which side.
129Possible values are nil (no scroll bars), `left' (scroll bars on left) 112Possible values are nil (no scroll bars), `left' (scroll bars on left)
@@ -140,32 +123,14 @@ Setting the variable with a customization buffer also takes effect."
140 :initialize 'custom-initialize-default 123 :initialize 'custom-initialize-default
141 :set (lambda (_sym val) (set-scroll-bar-mode val))) 124 :set (lambda (_sym val) (set-scroll-bar-mode val)))
142 125
143(defcustom horizontal-scroll-bar-mode default-frame-horizontal-scroll-bars
144 "Specify whether to have horizontal scroll bars, and on which side.
145To set this variable in a Lisp program, use `set-horizontal-scroll-bar-mode'
146to make it take real effect.
147Setting the variable with a customization buffer also takes effect."
148 :type '(choice (const :tag "none (nil)" nil)
149 (const t))
150 :group 'frames
151 ;; The default value for :initialize would try to use :set
152 ;; when processing the file in cus-dep.el.
153 :initialize 'custom-initialize-default
154 :set (lambda (_sym val) (set-horizontal-scroll-bar-mode val)))
155
156;; We just set scroll-bar-mode, but that was the default. 126;; We just set scroll-bar-mode, but that was the default.
157;; If it is set again, that is for real. 127;; If it is set again, that is for real.
158(setq scroll-bar-mode-explicit t) 128(setq scroll-bar-mode-explicit t)
159(setq horizontal-scroll-bar-mode-explicit t)
160 129
161(defun get-scroll-bar-mode () 130(defun get-scroll-bar-mode ()
162 (declare (gv-setter set-scroll-bar-mode)) 131 (declare (gv-setter set-scroll-bar-mode))
163 scroll-bar-mode) 132 scroll-bar-mode)
164 133
165(defun get-horizontal-scroll-bar-mode ()
166 (declare (gv-setter set-horizontal-scroll-bar-mode))
167 horizontal-scroll-bar-mode)
168
169(define-minor-mode scroll-bar-mode 134(define-minor-mode scroll-bar-mode
170 "Toggle vertical scroll bars on all frames (Scroll Bar mode). 135 "Toggle vertical scroll bars on all frames (Scroll Bar mode).
171With a prefix argument ARG, enable Scroll Bar mode if ARG is 136With a prefix argument ARG, enable Scroll Bar mode if ARG is
@@ -187,10 +152,17 @@ enable the mode if ARG is omitted or nil.
187 152
188This command applies to all frames that exist and frames to be 153This command applies to all frames that exist and frames to be
189created in the future." 154created in the future."
190 :variable ((get-horizontal-scroll-bar-mode) 155 :init-value nil
191 . (lambda (v) (set-horizontal-scroll-bar-mode 156 :global t
192 (if v (or previous-scroll-bar-mode 157 :group 'frames
193 default-frame-horizontal-scroll-bars)))))) 158 (dolist (frame (frame-list))
159 (set-frame-parameter
160 frame 'horizontal-scroll-bars horizontal-scroll-bar-mode))
161 ;; Handle `default-frame-alist' entry.
162 (setq default-frame-alist
163 (cons (cons 'horizontal-scroll-bars horizontal-scroll-bar-mode)
164 (assq-delete-all 'horizontal-scroll-bars
165 default-frame-alist))))
194 166
195(defun toggle-scroll-bar (arg) 167(defun toggle-scroll-bar (arg)
196 "Toggle whether or not the selected frame has vertical scroll bars. 168 "Toggle whether or not the selected frame has vertical scroll bars.
@@ -209,22 +181,6 @@ when they are turned on; if it is nil, they go on the left."
209 (list (cons 'vertical-scroll-bars 181 (list (cons 'vertical-scroll-bars
210 (if (> arg 0) 182 (if (> arg 0)
211 (or scroll-bar-mode default-frame-scroll-bars)))))) 183 (or scroll-bar-mode default-frame-scroll-bars))))))
212
213(defun toggle-horizontal-scroll-bar (arg)
214 "Toggle whether or not the selected frame has horizontal scroll bars.
215With arg, turn horizontal scroll bars on if and only if arg is positive."
216 (interactive "P")
217 (if (null arg)
218 (setq arg
219 (if (cdr (assq 'horizontal-scroll-bars
220 (frame-parameters (selected-frame))))
221 -1 1))
222 (setq arg (prefix-numeric-value arg)))
223 (modify-frame-parameters
224 (selected-frame)
225 (list (cons 'horizontal-scroll-bars
226 (if (> arg 0)
227 (or horizontal-scroll-bar-mode default-frame-horizontal-scroll-bars))))))
228 184
229;;;; Buffer navigation using the scroll bar. 185;;;; Buffer navigation using the scroll bar.
230 186
@@ -412,6 +368,7 @@ EVENT should be a scroll bar click."
412;;; Tookit scroll bars. 368;;; Tookit scroll bars.
413 369
414(defun scroll-bar-toolkit-scroll (event) 370(defun scroll-bar-toolkit-scroll (event)
371 "Handle event EVENT on vertical scroll bar."
415 (interactive "e") 372 (interactive "e")
416 (let* ((end-position (event-end event)) 373 (let* ((end-position (event-end event))
417 (window (nth 0 end-position)) 374 (window (nth 0 end-position))
@@ -453,6 +410,7 @@ EVENT should be a scroll bar click."
453 (setq point-before-scroll before-scroll)))))) 410 (setq point-before-scroll before-scroll))))))
454 411
455(defun scroll-bar-toolkit-horizontal-scroll (event) 412(defun scroll-bar-toolkit-horizontal-scroll (event)
413 "Handle event EVENT on horizontal scroll bar."
456 (interactive "e") 414 (interactive "e")
457 (let* ((end-position (event-end event)) 415 (let* ((end-position (event-end event))
458 (window (nth 0 end-position)) 416 (window (nth 0 end-position))