aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1999-07-05 05:42:30 +0000
committerRichard M. Stallman1999-07-05 05:42:30 +0000
commit0aeff9e00d04d0af5b32f0619f81b61ca7c45da9 (patch)
tree9be2c1a664fd7484e911d26c80309cef561df94d
parent3c75023fda350b03a95c982e4e42b4233111c8a4 (diff)
downloademacs-0aeff9e00d04d0af5b32f0619f81b61ca7c45da9.tar.gz
emacs-0aeff9e00d04d0af5b32f0619f81b61ca7c45da9.zip
(hscroll-window-maybe): Do nothing in the minibuffer.
(hscroll-mode): Make it a permanent local. (hscroll-mode): Don't cancel the timer if HScroll mode is enabled in some other buffer.
-rw-r--r--lisp/hscroll.el27
1 files changed, 19 insertions, 8 deletions
diff --git a/lisp/hscroll.el b/lisp/hscroll.el
index c69e6c59282..04c582fbee1 100644
--- a/lisp/hscroll.el
+++ b/lisp/hscroll.el
@@ -109,6 +109,9 @@ Set this to nil to conserve valuable mode line space."
109(defvar hscroll-mode nil 109(defvar hscroll-mode nil
110 "Non-nil if HScroll mode is enabled.") 110 "Non-nil if HScroll mode is enabled.")
111(make-variable-buffer-local 'hscroll-mode) 111(make-variable-buffer-local 'hscroll-mode)
112;; Make it a permanent local
113;; so it will only turn off when WE turn it off.
114(put 'hscroll-mode 'permanent-local t)
112 115
113(defvar hscroll-timer nil 116(defvar hscroll-timer nil
114 "Timer used by HScroll mode.") 117 "Timer used by HScroll mode.")
@@ -142,9 +145,9 @@ right when point gets near either edge of the window.
142 (> (prefix-numeric-value arg) 0)))) 145 (> (prefix-numeric-value arg) 0))))
143 146
144 (if newmode 147 (if newmode
145 ;; turn it on 148 ;; Turn it on.
146 (if (not hscroll-mode) 149 (if (not hscroll-mode)
147 ;; it was off 150 ;; It was off.
148 (let ((localp (local-variable-p 'truncate-lines))) 151 (let ((localp (local-variable-p 'truncate-lines)))
149 (if localp 152 (if localp
150 (setq hscroll-old-truncate-local truncate-lines)) 153 (setq hscroll-old-truncate-local truncate-lines))
@@ -152,16 +155,22 @@ right when point gets near either edge of the window.
152 (setq truncate-lines t) 155 (setq truncate-lines t)
153 (setq hscroll-timer 156 (setq hscroll-timer
154 (run-with-idle-timer 0 t 'hscroll-window-maybe)))) 157 (run-with-idle-timer 0 t 'hscroll-window-maybe))))
155 ;; turn it off 158 ;; Turn it off.
156 (if hscroll-mode 159 (if hscroll-mode
157 ;; it was on 160 ;; It was on.
158 (progn 161 (progn
159 (if hscroll-old-truncate-was-global 162 (if hscroll-old-truncate-was-global
160 (kill-local-variable 'truncate-lines) 163 (kill-local-variable 'truncate-lines)
161 (setq truncate-lines hscroll-old-truncate-local)) 164 (setq truncate-lines hscroll-old-truncate-local))
162 (if (not truncate-lines) 165 (if (not truncate-lines)
163 (set-window-hscroll (selected-window) 0)) 166 (set-window-hscroll (selected-window) 0))
164 (cancel-timer hscroll-timer)))) 167 ;; If hscroll is not enabled in any buffer now,
168 ;; turn off the timer.
169 (unless (memq t (mapcar (lambda (buffer)
170 (with-current-buffer buffer
171 hscroll-mode))
172 (buffer-list)))
173 (cancel-timer hscroll-timer)))))
165 174
166 (setq hscroll-mode newmode) 175 (setq hscroll-mode newmode)
167 (force-mode-line-update nil))) 176 (force-mode-line-update nil)))
@@ -169,7 +178,7 @@ right when point gets near either edge of the window.
169 178
170;;;###autoload 179;;;###autoload
171(defun hscroll-global-mode (&optional arg) 180(defun hscroll-global-mode (&optional arg)
172 "Toggle HScroll mode in all buffers. 181 "Toggle HScroll mode in all buffers (excepting minibuffers).
173With ARG, turn HScroll mode on if ARG is positive, off otherwise. 182With ARG, turn HScroll mode on if ARG is positive, off otherwise.
174If a buffer ever has HScroll mode set locally (via \\[hscroll-mode]), 183If a buffer ever has HScroll mode set locally (via \\[hscroll-mode]),
175it will forever use the local value (i.e., \\[hscroll-global-mode] 184it will forever use the local value (i.e., \\[hscroll-global-mode]
@@ -204,12 +213,14 @@ will have no effect on it).
204(defun hscroll-window-maybe () 213(defun hscroll-window-maybe ()
205 "Scroll horizontally if point is off or nearly off the edge of the window. 214 "Scroll horizontally if point is off or nearly off the edge of the window.
206This is called automatically when in HScroll mode, but it can be explicitly 215This is called automatically when in HScroll mode, but it can be explicitly
207invoked as well (i.e., it can be bound to a key)." 216invoked as well (i.e., it can be bound to a key).
217This does nothing in the minibuffer."
208 (interactive) 218 (interactive)
209 ;; Only consider scrolling if truncate-lines is true, 219 ;; Only consider scrolling if truncate-lines is true,
210 ;; the window is already scrolled or partial-widths is true and this is 220 ;; the window is already scrolled or partial-widths is true and this is
211 ;; a partial width window. See display_text_line() in xdisp.c. 221 ;; a partial width window. See display_text_line in xdisp.c.
212 (if (and hscroll-mode 222 (if (and hscroll-mode
223 (not (window-minibuffer-p (selected-window)))
213 (or truncate-lines 224 (or truncate-lines
214 (not (zerop (window-hscroll))) 225 (not (zerop (window-hscroll)))
215 (and truncate-partial-width-windows 226 (and truncate-partial-width-windows