diff options
| author | Richard M. Stallman | 1997-06-28 00:43:48 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-28 00:43:48 +0000 |
| commit | 04c34f2e7151ced32813fd630a3a0090abb48aae (patch) | |
| tree | 31497e256cd3455e20f598d687c1c2fdaf9aad67 | |
| parent | 4db2b1c70f5f69c904d93df7d32e22864e2e0ea9 (diff) | |
| download | emacs-04c34f2e7151ced32813fd630a3a0090abb48aae.tar.gz emacs-04c34f2e7151ced32813fd630a3a0090abb48aae.zip | |
(toggle-scroll-bar): Moved from frame.el.
Use scroll-bar-mode to determine which side; if it's nil, use left.
(set-scroll-bar-mode): New subroutine, taken from scroll-bar-mode.
(scroll-bar-mode): Use the variable set-scroll-bar-mode.
(scroll-bar-mode): New variable.
(toggle-horizontal-scroll-bar): Moved from frame.el.
| -rw-r--r-- | lisp/scroll-bar.el | 93 |
1 files changed, 63 insertions, 30 deletions
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el index ec0f7164943..bf0c1e8ed0a 100644 --- a/lisp/scroll-bar.el +++ b/lisp/scroll-bar.el | |||
| @@ -56,8 +56,42 @@ that scroll bar position." | |||
| 56 | 56 | ||
| 57 | ;;;; Helpful functions for enabling and disabling scroll bars. | 57 | ;;;; Helpful functions for enabling and disabling scroll bars. |
| 58 | 58 | ||
| 59 | (defun set-scroll-bar-mode (ignore value) | ||
| 60 | "Set `scroll-bar-mode' to VALUE and put the new value into effect." | ||
| 61 | (setq scroll-bar-mode value) | ||
| 62 | |||
| 63 | ;; Apply it to default-frame-alist. | ||
| 64 | (let ((parameter (assq 'vertical-scroll-bars default-frame-alist))) | ||
| 65 | (if (consp parameter) | ||
| 66 | (setcdr parameter scroll-bar-mode) | ||
| 67 | (setq default-frame-alist | ||
| 68 | (cons (cons 'vertical-scroll-bars scroll-bar-mode) | ||
| 69 | default-frame-alist)))) | ||
| 70 | |||
| 71 | ;; Apply it to existing frames. | ||
| 72 | (let ((frames (frame-list))) | ||
| 73 | (while frames | ||
| 74 | (modify-frame-parameters | ||
| 75 | (car frames) | ||
| 76 | (list (cons 'vertical-scroll-bars scroll-bar-mode))) | ||
| 77 | (setq frames (cdr frames))))) | ||
| 78 | |||
| 79 | (defcustom scroll-bar-mode 'left | ||
| 80 | "*Specify whether to have vertical scroll bars, and on which side. | ||
| 81 | Possible values are nil (no scroll bars), `left' (scroll bars on left) | ||
| 82 | and `right' (scroll bars on right). | ||
| 83 | When you set the variable in a Lisp program, it takes effect for new frames, | ||
| 84 | and for existing frames when `toggle-scroll-bar' is used. | ||
| 85 | When you set this with the customization buffer, | ||
| 86 | it takes effect immediately for all frames." | ||
| 87 | :type '(choice (const :tag "none (nil)") | ||
| 88 | (const left) | ||
| 89 | (const right)) | ||
| 90 | :group 'frames | ||
| 91 | :set 'set-scroll-bar-mode) | ||
| 92 | |||
| 59 | (defun scroll-bar-mode (flag) | 93 | (defun scroll-bar-mode (flag) |
| 60 | "Toggle display of vertical scroll bars on each frame. | 94 | "Toggle display of vertical scroll bars on all frames. |
| 61 | This command applies to all frames that exist and frames to be | 95 | This command applies to all frames that exist and frames to be |
| 62 | created in the future. | 96 | created in the future. |
| 63 | With a numeric argument, if the argument is negative, | 97 | With a numeric argument, if the argument is negative, |
| @@ -65,35 +99,34 @@ turn off scroll bars; otherwise, turn on scroll bars." | |||
| 65 | (interactive "P") | 99 | (interactive "P") |
| 66 | (if flag (setq flag (prefix-numeric-value flag))) | 100 | (if flag (setq flag (prefix-numeric-value flag))) |
| 67 | 101 | ||
| 68 | ;; Obtain the current setting by looking at default-frame-alist. | 102 | ;; Tweedle the variable according to the argument. |
| 69 | (let ((scroll-bar-mode | 103 | (set-scroll-bar-mode nil |
| 70 | (let ((assq (assq 'vertical-scroll-bars default-frame-alist))) | 104 | (if (null flag) (not scroll-bar-mode) |
| 71 | (if assq (cdr assq) t)))) | 105 | (and (or (not (numberp flag)) (>= flag 0)) |
| 72 | 106 | 'left)))) | |
| 73 | ;; Tweedle it according to the argument. | 107 | |
| 74 | (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode) | 108 | (defun toggle-scroll-bar (arg) |
| 75 | (or (not (numberp flag)) (>= flag 0)))) | 109 | "Toggle whether or not the selected frame has vertical scroll bars. |
| 76 | 110 | With arg, turn vertical scroll bars on if and only if arg is positive. | |
| 77 | ;; Apply it to default-frame-alist. | 111 | The variable `scroll-bar-mode' controls which side the scroll bars are on |
| 78 | (mapcar | 112 | when they are turned on; if it is nil, they go on the left." |
| 79 | (function | 113 | (interactive "P") |
| 80 | (lambda (param-name) | 114 | (if (null arg) |
| 81 | (let ((parameter (assq param-name default-frame-alist))) | 115 | (setq arg |
| 82 | (if (consp parameter) | 116 | (if (cdr (assq 'vertical-scroll-bars |
| 83 | (setcdr parameter scroll-bar-mode) | 117 | (frame-parameters (selected-frame)))) |
| 84 | (setq default-frame-alist | 118 | -1 1))) |
| 85 | (cons (cons param-name scroll-bar-mode) | 119 | (modify-frame-parameters (selected-frame) |
| 86 | default-frame-alist)))))) | 120 | (list (cons 'vertical-scroll-bars |
| 87 | '(vertical-scroll-bars horizontal-scroll-bars)) | 121 | (if (> arg 0) |
| 88 | 122 | (or scroll-bar-mode 'left)))))) | |
| 89 | ;; Apply it to existing frames. | 123 | |
| 90 | (let ((frames (frame-list))) | 124 | (defun toggle-horizontal-scroll-bar (arg) |
| 91 | (while frames | 125 | "Toggle whether or not the selected frame has horizontal scroll bars. |
| 92 | (modify-frame-parameters | 126 | With arg, turn horizontal scroll bars on if and only if arg is positive. |
| 93 | (car frames) | 127 | Horizontal scroll bars aren't implemented yet." |
| 94 | (list (cons 'vertical-scroll-bars scroll-bar-mode) | 128 | (interactive "P") |
| 95 | (cons 'horizontal-scroll-bars scroll-bar-mode))) | 129 | (error "Horizontal scroll bars aren't implemented yet")) |
| 96 | (setq frames (cdr frames)))))) | ||
| 97 | 130 | ||
| 98 | ;;;; Buffer navigation using the scroll bar. | 131 | ;;;; Buffer navigation using the scroll bar. |
| 99 | 132 | ||