diff options
| author | Richard M. Stallman | 1997-02-08 15:50:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-02-08 15:50:17 +0000 |
| commit | 9317a85d0f549f88d1bd5797d420a9b7fe40d00f (patch) | |
| tree | 04cf1254a446d2fb0c08cc410a0b74eab082c2d9 /src | |
| parent | 50b3531c8290a2877df9782559e28cee614b305f (diff) | |
| download | emacs-9317a85d0f549f88d1bd5797d420a9b7fe40d00f.tar.gz emacs-9317a85d0f549f88d1bd5797d420a9b7fe40d00f.zip | |
(scroll_preserve_screen_position): New variable.
(keys_of_window): Set up Lisp var.
(window_scroll): If scroll_preserve_screen_position is 0,
behave the old way (advancing point the minimum distance).
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/window.c b/src/window.c index dd5d472ed7e..071c3dc903c 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -111,8 +111,14 @@ static int sequence_number; | |||
| 111 | /* Nonzero after init_window_once has finished. */ | 111 | /* Nonzero after init_window_once has finished. */ |
| 112 | static int window_initialized; | 112 | static int window_initialized; |
| 113 | 113 | ||
| 114 | /* Nonzero means scroll commands try to put point | ||
| 115 | at the same screen height as previously. */ | ||
| 116 | static int scroll_preserve_screen_position; | ||
| 117 | |||
| 114 | #define min(a, b) ((a) < (b) ? (a) : (b)) | 118 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| 115 | 119 | ||
| 120 | extern int scroll_margin; | ||
| 121 | |||
| 116 | extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; | 122 | extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; |
| 117 | 123 | ||
| 118 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, | 124 | DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0, |
| @@ -2638,8 +2644,7 @@ window_internal_width (w) | |||
| 2638 | 2644 | ||
| 2639 | 2645 | ||
| 2640 | /* Scroll contents of window WINDOW up N lines. | 2646 | /* Scroll contents of window WINDOW up N lines. |
| 2641 | If WHOLE is nonzero, it means we wanted to scroll | 2647 | If WHOLE is nonzero, it means scroll N screenfuls instead. */ |
| 2642 | by entire screenfuls. */ | ||
| 2643 | 2648 | ||
| 2644 | static void | 2649 | static void |
| 2645 | window_scroll (window, n, whole, noerror) | 2650 | window_scroll (window, n, whole, noerror) |
| @@ -2693,8 +2698,6 @@ window_scroll (window, n, whole, noerror) | |||
| 2693 | 2698 | ||
| 2694 | if (pos < ZV) | 2699 | if (pos < ZV) |
| 2695 | { | 2700 | { |
| 2696 | extern int scroll_margin; | ||
| 2697 | |||
| 2698 | int this_scroll_margin = scroll_margin; | 2701 | int this_scroll_margin = scroll_margin; |
| 2699 | 2702 | ||
| 2700 | /* Don't use a scroll margin that is negative or too large. */ | 2703 | /* Don't use a scroll margin that is negative or too large. */ |
| @@ -2713,7 +2716,7 @@ window_scroll (window, n, whole, noerror) | |||
| 2713 | the window-scroll-functions. */ | 2716 | the window-scroll-functions. */ |
| 2714 | w->force_start = Qt; | 2717 | w->force_start = Qt; |
| 2715 | 2718 | ||
| 2716 | if (whole) | 2719 | if (whole && scroll_preserve_screen_position) |
| 2717 | { | 2720 | { |
| 2718 | SET_PT (pos); | 2721 | SET_PT (pos); |
| 2719 | Fvertical_motion (make_number (original_vpos), window); | 2722 | Fvertical_motion (make_number (original_vpos), window); |
| @@ -2735,11 +2738,13 @@ window_scroll (window, n, whole, noerror) | |||
| 2735 | 2738 | ||
| 2736 | if (top_margin <= opoint) | 2739 | if (top_margin <= opoint) |
| 2737 | SET_PT (opoint); | 2740 | SET_PT (opoint); |
| 2738 | else | 2741 | else if (scroll_preserve_screen_position) |
| 2739 | { | 2742 | { |
| 2740 | SET_PT (pos); | 2743 | SET_PT (pos); |
| 2741 | Fvertical_motion (make_number (original_vpos), window); | 2744 | Fvertical_motion (make_number (original_vpos), window); |
| 2742 | } | 2745 | } |
| 2746 | else | ||
| 2747 | SET_PT (pos); | ||
| 2743 | } | 2748 | } |
| 2744 | else if (n < 0) | 2749 | else if (n < 0) |
| 2745 | { | 2750 | { |
| @@ -2758,8 +2763,13 @@ window_scroll (window, n, whole, noerror) | |||
| 2758 | SET_PT (opoint); | 2763 | SET_PT (opoint); |
| 2759 | else | 2764 | else |
| 2760 | { | 2765 | { |
| 2761 | SET_PT (pos); | 2766 | if (scroll_preserve_screen_position) |
| 2762 | Fvertical_motion (make_number (original_vpos), window); | 2767 | { |
| 2768 | SET_PT (pos); | ||
| 2769 | Fvertical_motion (make_number (original_vpos), window); | ||
| 2770 | } | ||
| 2771 | else | ||
| 2772 | Fvertical_motion (make_number (-1), window); | ||
| 2763 | } | 2773 | } |
| 2764 | } | 2774 | } |
| 2765 | } | 2775 | } |
| @@ -3644,6 +3654,11 @@ If there is only one window, it is split regardless of this value."); | |||
| 3644 | "*Delete any window less than this wide."); | 3654 | "*Delete any window less than this wide."); |
| 3645 | window_min_width = 10; | 3655 | window_min_width = 10; |
| 3646 | 3656 | ||
| 3657 | DEFVAR_BOOL ("scroll-preserve-screen-position", | ||
| 3658 | &scroll_preserve_screen_position, | ||
| 3659 | "*Nonzero means scroll commands move point to keep its screen line unchanged."); | ||
| 3660 | scroll_preserve_screen_position = 0; | ||
| 3661 | |||
| 3647 | defsubr (&Sselected_window); | 3662 | defsubr (&Sselected_window); |
| 3648 | defsubr (&Sminibuffer_window); | 3663 | defsubr (&Sminibuffer_window); |
| 3649 | defsubr (&Swindow_minibuffer_p); | 3664 | defsubr (&Swindow_minibuffer_p); |