Mercurial > emacs
comparison lisp/simple.el @ 2597:562d2dea4f05
(hscroll-step): New variable.
(hscroll-point-visible): New function.
(left-arrow, right-arrow): These use hscroll-point-visible for better auto-
scrolling behavior.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Tue, 27 Apr 1993 22:01:32 +0000 |
parents | b28675709d41 |
children | cd5e799be39b |
comparison
equal
deleted
inserted
replaced
2596:ee5b45777c6f | 2597:562d2dea4f05 |
---|---|
1385 (message (substitute-command-keys | 1385 (message (substitute-command-keys |
1386 "Goal column %d (use \\[set-goal-column] with an arg to unset it)") | 1386 "Goal column %d (use \\[set-goal-column] with an arg to unset it)") |
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). |
1415 If doing so would add lines to the end of the buffer, raise an error." | 1434 If doing so would add lines to the end of the buffer, raise an error." |
1416 (interactive "P") | 1435 (interactive "P") |