diff options
| author | Alan Mackenzie | 2016-04-29 14:58:21 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-04-29 14:58:21 +0000 |
| commit | c6077bfd297a8a0e4deaec217db17be630d98b9c (patch) | |
| tree | 40b31ef5fc00a49c4b1ebae497cb7b2b883fd373 | |
| parent | b671e218db4bed019edd80abf72f77f9b5a07f0d (diff) | |
| download | emacs-c6077bfd297a8a0e4deaec217db17be630d98b9c.tar.gz emacs-c6077bfd297a8a0e4deaec217db17be630d98b9c.zip | |
Restore follow-scroll-up/down to scrolling by the combined size of all windows
Also rename the current follow-scroll-up/down functions to
follow-scroll-up-window and follow-scroll-down-window. These scroll by the
height of the current window.
This fixes bug #23347.
* lisp/follow.el (follow-mode): Tweak the doc string.
(follow-scroll-up-arg, follow-scroll-down-arg): new functions, extracted from
follow-scroll-up/down.
(follow-scroll-up-window, follow-scroll-down-window): Functions renamed from
follow-scroll-up/down.
(follow-scroll-up, follow-scroll-down): Restore the historic functionality.
| -rw-r--r-- | lisp/follow.el | 138 |
1 files changed, 107 insertions, 31 deletions
diff --git a/lisp/follow.el b/lisp/follow.el index 5801f79341e..c510e5a848b 100644 --- a/lisp/follow.el +++ b/lisp/follow.el | |||
| @@ -399,11 +399,11 @@ virtual window. This is accomplished by two main techniques: | |||
| 399 | makes it possible to walk between windows using normal cursor | 399 | makes it possible to walk between windows using normal cursor |
| 400 | movement commands. | 400 | movement commands. |
| 401 | 401 | ||
| 402 | Follow mode comes to its prime when used on a large screen and two | 402 | Follow mode comes to its prime when used on a large screen and two or |
| 403 | side-by-side windows are used. The user can, with the help of Follow | 403 | more side-by-side windows are used. The user can, with the help of |
| 404 | mode, use two full-height windows as though they would have been | 404 | Follow mode, use these full-height windows as though they were one. |
| 405 | one. Imagine yourself editing a large function, or section of text, | 405 | Imagine yourself editing a large function, or section of text, and |
| 406 | and being able to use 144 lines instead of the normal 72... (your | 406 | being able to use 144 or 216 lines instead of the normal 72... (your |
| 407 | mileage may vary). | 407 | mileage may vary). |
| 408 | 408 | ||
| 409 | To split one large window into two side-by-side windows, the commands | 409 | To split one large window into two side-by-side windows, the commands |
| @@ -532,6 +532,80 @@ Return the new position." | |||
| 532 | ;; position... (This would also be corrected if we would have had a | 532 | ;; position... (This would also be corrected if we would have had a |
| 533 | ;; good redisplay abstraction.) | 533 | ;; good redisplay abstraction.) |
| 534 | 534 | ||
| 535 | (defun follow-scroll-up-arg (arg) | ||
| 536 | "Scroll the text in a follow mode window chain up by ARG lines. | ||
| 537 | If ARG is nil, scroll the size of the current window. | ||
| 538 | |||
| 539 | This is an internal function for `follow-scroll-up' and | ||
| 540 | `follow-scroll-up-window'." | ||
| 541 | (let ((opoint (point)) (owin (selected-window))) | ||
| 542 | (while | ||
| 543 | ;; If we are too near EOB, try scrolling the previous window. | ||
| 544 | (condition-case nil (progn (scroll-up arg) nil) | ||
| 545 | (end-of-buffer | ||
| 546 | (condition-case nil (progn (follow-previous-window) t) | ||
| 547 | (error | ||
| 548 | (select-window owin) | ||
| 549 | (goto-char opoint) | ||
| 550 | (signal 'end-of-buffer nil)))))) | ||
| 551 | (unless (and scroll-preserve-screen-position | ||
| 552 | (get this-command 'scroll-command)) | ||
| 553 | (goto-char opoint)) | ||
| 554 | (setq follow-fixed-window t))) | ||
| 555 | |||
| 556 | (defun follow-scroll-down-arg (arg) | ||
| 557 | "Scroll the text in a follow mode window chain down by ARG lines. | ||
| 558 | If ARG is nil, scroll the size of the current window. | ||
| 559 | |||
| 560 | This is an internal function for `follow-scroll-down' and | ||
| 561 | `follow-scroll-down-window'." | ||
| 562 | (let ((opoint (point))) | ||
| 563 | (scroll-down arg) | ||
| 564 | (unless (and scroll-preserve-screen-position | ||
| 565 | (get this-command 'scroll-command)) | ||
| 566 | (goto-char opoint)) | ||
| 567 | (setq follow-fixed-window t))) | ||
| 568 | |||
| 569 | ;;;###autoload | ||
| 570 | (defun follow-scroll-up-window (&optional arg) | ||
| 571 | "Scroll text in a Follow mode window up by that window's size. | ||
| 572 | The other windows in the window chain will scroll synchronously. | ||
| 573 | |||
| 574 | If called with no ARG, the `next-screen-context-lines' last lines of | ||
| 575 | the window will be visible after the scroll. | ||
| 576 | |||
| 577 | If called with an argument, scroll ARG lines up. | ||
| 578 | Negative ARG means scroll downward. | ||
| 579 | |||
| 580 | Works like `scroll-up' when not in Follow mode." | ||
| 581 | (interactive "P") | ||
| 582 | (cond ((not follow-mode) | ||
| 583 | (scroll-up arg)) | ||
| 584 | ((eq arg '-) | ||
| 585 | (follow-scroll-down-window)) | ||
| 586 | (t (follow-scroll-up-arg arg)))) | ||
| 587 | (put 'follow-scroll-up-window 'scroll-command t) | ||
| 588 | |||
| 589 | ;;;###autoload | ||
| 590 | (defun follow-scroll-down-window (&optional arg) | ||
| 591 | "Scroll text in a Follow mode window down by that window's size. | ||
| 592 | The other windows in the window chain will scroll synchronously. | ||
| 593 | |||
| 594 | If called with no ARG, the `next-screen-context-lines' top lines of | ||
| 595 | the window in the chain will be visible after the scroll. | ||
| 596 | |||
| 597 | If called with an argument, scroll ARG lines down. | ||
| 598 | Negative ARG means scroll upward. | ||
| 599 | |||
| 600 | Works like `scroll-down' when not in Follow mode." | ||
| 601 | (interactive "P") | ||
| 602 | (cond ((not follow-mode) | ||
| 603 | (scroll-down arg)) | ||
| 604 | ((eq arg '-) | ||
| 605 | (follow-scroll-up-window)) | ||
| 606 | (t (follow-scroll-down-arg arg)))) | ||
| 607 | (put 'follow-scroll-down-window 'scroll-command t) | ||
| 608 | |||
| 535 | ;;;###autoload | 609 | ;;;###autoload |
| 536 | (defun follow-scroll-up (&optional arg) | 610 | (defun follow-scroll-up (&optional arg) |
| 537 | "Scroll text in a Follow mode window chain up. | 611 | "Scroll text in a Follow mode window chain up. |
| @@ -546,23 +620,18 @@ Works like `scroll-up' when not in Follow mode." | |||
| 546 | (interactive "P") | 620 | (interactive "P") |
| 547 | (cond ((not follow-mode) | 621 | (cond ((not follow-mode) |
| 548 | (scroll-up arg)) | 622 | (scroll-up arg)) |
| 549 | ((eq arg '-) | 623 | (arg (follow-scroll-up-arg arg)) |
| 550 | (follow-scroll-down)) | 624 | (t |
| 551 | (t | 625 | (let* ((windows (follow-all-followers)) |
| 552 | (let ((opoint (point)) (owin (selected-window))) | 626 | (end (window-end (car (reverse windows))))) |
| 553 | (while | 627 | (if (eq end (point-max)) |
| 554 | ;; If we are too near EOB, try scrolling the previous window. | 628 | (signal 'end-of-buffer nil) |
| 555 | (condition-case nil (progn (scroll-up arg) nil) | 629 | (select-window (car windows)) |
| 556 | (end-of-buffer | 630 | ;; `window-end' might return nil. |
| 557 | (condition-case nil (progn (follow-previous-window) t) | 631 | (if end |
| 558 | (error | 632 | (goto-char end)) |
| 559 | (select-window owin) | 633 | (vertical-motion (- next-screen-context-lines)) |
| 560 | (goto-char opoint) | 634 | (set-window-start (car windows) (point))))))) |
| 561 | (signal 'end-of-buffer nil)))))) | ||
| 562 | (unless (and scroll-preserve-screen-position | ||
| 563 | (get this-command 'scroll-command)) | ||
| 564 | (goto-char opoint)) | ||
| 565 | (setq follow-fixed-window t))))) | ||
| 566 | (put 'follow-scroll-up 'scroll-command t) | 635 | (put 'follow-scroll-up 'scroll-command t) |
| 567 | 636 | ||
| 568 | ;;;###autoload | 637 | ;;;###autoload |
| @@ -579,15 +648,22 @@ Works like `scroll-down' when not in Follow mode." | |||
| 579 | (interactive "P") | 648 | (interactive "P") |
| 580 | (cond ((not follow-mode) | 649 | (cond ((not follow-mode) |
| 581 | (scroll-down arg)) | 650 | (scroll-down arg)) |
| 582 | ((eq arg '-) | 651 | (arg (follow-scroll-down-arg arg)) |
| 583 | (follow-scroll-up)) | 652 | (t |
| 584 | (t | 653 | (let* ((windows (follow-all-followers)) |
| 585 | (let ((opoint (point))) | 654 | (win (car (reverse windows))) |
| 586 | (scroll-down arg) | 655 | (start (window-start (car windows)))) |
| 587 | (unless (and scroll-preserve-screen-position | 656 | (if (eq start (point-min)) |
| 588 | (get this-command 'scroll-command)) | 657 | (signal 'beginning-of-buffer nil) |
| 589 | (goto-char opoint)) | 658 | (select-window win) |
| 590 | (setq follow-fixed-window t))))) | 659 | (goto-char start) |
| 660 | (vertical-motion (- (- (window-height win) | ||
| 661 | (if header-line-format 2 1) | ||
| 662 | next-screen-context-lines))) | ||
| 663 | (set-window-start win (point)) | ||
| 664 | (goto-char start) | ||
| 665 | (vertical-motion (- next-screen-context-lines 1)) | ||
| 666 | (setq follow-internal-force-redisplay t)))))) | ||
| 591 | (put 'follow-scroll-down 'scroll-command t) | 667 | (put 'follow-scroll-down 'scroll-command t) |
| 592 | 668 | ||
| 593 | (declare-function comint-adjust-point "comint" (window)) | 669 | (declare-function comint-adjust-point "comint" (window)) |