diff options
| author | Eric S. Raymond | 1993-04-27 22:01:32 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 1993-04-27 22:01:32 +0000 |
| commit | 0d5bbbf750427d5783de4836c969f254d76185e3 (patch) | |
| tree | a1b0f454cd57a7a2062008422282f823ae4748ad | |
| parent | ac669fa2a99d847823f1a355bde6dbfa654a5fda (diff) | |
| download | emacs-0d5bbbf750427d5783de4836c969f254d76185e3.tar.gz emacs-0d5bbbf750427d5783de4836c969f254d76185e3.zip | |
(hscroll-step): New variable.
(hscroll-point-visible): New function.
(left-arrow, right-arrow): These use hscroll-point-visible for better auto-
scrolling behavior.
| -rw-r--r-- | lisp/simple.el | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 3731fbebb13..3196eee32b3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1387,28 +1387,47 @@ The goal column is stored in the variable `goal-column'." | |||
| 1387 | goal-column)) | 1387 | goal-column)) |
| 1388 | nil) | 1388 | nil) |
| 1389 | 1389 | ||
| 1390 | ;;; Partial support for horizontal autoscrolling. Someday, this feature | ||
| 1391 | ;;; will be built into the C level and all the (hscroll-point-visible) calls | ||
| 1392 | ;;; will go away. | ||
| 1393 | |||
| 1394 | (defvar hscroll-step 0 | ||
| 1395 | "*The number of columns to try scrolling a window by when point moves out. | ||
| 1396 | If that fails to bring point back on frame, point is centered instead. | ||
| 1397 | If this is zero, point is always centered after it moves off frame.") | ||
| 1398 | |||
| 1399 | (defun hscroll-point-visible () | ||
| 1400 | "Scrolls the window horizontally to make point visible." | ||
| 1401 | (let* ((min (window-hscroll)) | ||
| 1402 | (max (- (+ min (window-width)) 2)) | ||
| 1403 | (here (current-column)) | ||
| 1404 | (delta (if (zerop hscroll-step) (/ (window-width) 2) hscroll-step)) | ||
| 1405 | ) | ||
| 1406 | (if (< here min) | ||
| 1407 | (scroll-right (max 0 (+ (- min here) delta))) | ||
| 1408 | (if (>= here max) | ||
| 1409 | (scroll-left (- (- here min) delta)) | ||
| 1410 | )))) | ||
| 1411 | |||
| 1390 | ;;; Make arrow keys do the right thing for improved terminal support | 1412 | ;;; Make arrow keys do the right thing for improved terminal support |
| 1391 | ;;; When we implement true horizontal autoscrolling, right-arrow and | 1413 | ;;; When we implement true horizontal autoscrolling, right-arrow and |
| 1392 | ;;; left-arrow can lose the (if truncate-lines ...) clause and become | 1414 | ;;; left-arrow can lose the (if truncate-lines ...) clause and become |
| 1393 | ;;; aliases. | 1415 | ;;; aliases. These functions are bound to the corresponding keyboard |
| 1416 | ;;; events in loaddefs.el. | ||
| 1394 | 1417 | ||
| 1395 | (defun right-arrow (arg) | 1418 | (defun right-arrow (arg) |
| 1396 | "Move right one character on the screen (with prefix ARG, that many chars). | 1419 | "Move right one character on the screen (with prefix ARG, that many chars). |
| 1397 | Scroll right if needed to keep point horizontally onscreen." | 1420 | Scroll right if needed to keep point horizontally onscreen." |
| 1398 | (interactive "P") | 1421 | (interactive "P") |
| 1399 | (forward-char arg) | 1422 | (forward-char arg) |
| 1400 | (if truncate-lines | 1423 | (hscroll-point-visible)) |
| 1401 | (let ((x (current-column)) (w (- (window-width) 2))) | ||
| 1402 | (set-window-hscroll (selected-window) (- x (% x w)) )))) | ||
| 1403 | 1424 | ||
| 1404 | (defun left-arrow (arg) | 1425 | (defun left-arrow (arg) |
| 1405 | "Move left one character on the screen (with prefix ARG, that many chars). | 1426 | "Move left one character on the screen (with prefix ARG, that many chars). |
| 1406 | Scroll left if needed to keep point horizontally onscreen." | 1427 | Scroll left if needed to keep point horizontally onscreen." |
| 1407 | (interactive "P") | 1428 | (interactive "P") |
| 1408 | (backward-char arg) | 1429 | (backward-char arg) |
| 1409 | (if truncate-lines | 1430 | (hscroll-point-visible)) |
| 1410 | (let ((x (current-column)) (w (- (window-width) 2))) | ||
| 1411 | (set-window-hscroll (selected-window) (- x (% x w)) )))) | ||
| 1412 | 1431 | ||
| 1413 | (defun down-arrow (arg) | 1432 | (defun down-arrow (arg) |
| 1414 | "Move down one line on the screen (with prefix ARG, that many lines). | 1433 | "Move down one line on the screen (with prefix ARG, that many lines). |