diff options
| author | John Shahid | 2018-06-28 09:13:45 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2018-07-01 19:05:37 +0300 |
| commit | 260768a64be39aada03247d6057698df97bcb800 (patch) | |
| tree | f61ec4466fc4768a2b0c610a8fc1ac931a067746 | |
| parent | 7edc019651b3e16592d2d16616a7d4cecc285ae6 (diff) | |
| download | emacs-260768a64be39aada03247d6057698df97bcb800.tar.gz emacs-260768a64be39aada03247d6057698df97bcb800.zip | |
Add a new argument to 'recenter' to allow finer control of redisplay
* window.c (recenter): Add a new REDISPLAY argument to allow the
caller to control the redisplay behavior. 'recenter' will only
redisplay the frame if this new arg and 'recenter-redisplay' are
both non-nil.
(recenter-top-bottom): Pass an extra non-nil argument to
'recenter' to force a redisplay. (Bug#31325)
| -rw-r--r-- | doc/lispref/windows.texi | 12 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/window.el | 10 | ||||
| -rw-r--r-- | src/window.c | 20 |
4 files changed, 28 insertions, 19 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 54977595956..9740bbebf2c 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi | |||
| @@ -4138,7 +4138,7 @@ beginning or end of the buffer (depending on scrolling direction); | |||
| 4138 | only if point is already on that position do they signal an error. | 4138 | only if point is already on that position do they signal an error. |
| 4139 | @end defopt | 4139 | @end defopt |
| 4140 | 4140 | ||
| 4141 | @deffn Command recenter &optional count | 4141 | @deffn Command recenter &optional count redisplay |
| 4142 | @cindex centering point | 4142 | @cindex centering point |
| 4143 | This function scrolls the text in the selected window so that point is | 4143 | This function scrolls the text in the selected window so that point is |
| 4144 | displayed at a specified vertical position within the window. It does | 4144 | displayed at a specified vertical position within the window. It does |
| @@ -4152,8 +4152,9 @@ line in the window. | |||
| 4152 | 4152 | ||
| 4153 | If @var{count} is @code{nil} (or a non-@code{nil} list), | 4153 | If @var{count} is @code{nil} (or a non-@code{nil} list), |
| 4154 | @code{recenter} puts the line containing point in the middle of the | 4154 | @code{recenter} puts the line containing point in the middle of the |
| 4155 | window. If @var{count} is @code{nil}, this function may redraw the | 4155 | window. If @var{count} is @code{nil} and @var{redisplay} is |
| 4156 | frame, according to the value of @code{recenter-redisplay}. | 4156 | non-@code{nil}, this function may redraw the frame, according to the |
| 4157 | value of @code{recenter-redisplay}. | ||
| 4157 | 4158 | ||
| 4158 | When @code{recenter} is called interactively, @var{count} is the raw | 4159 | When @code{recenter} is called interactively, @var{count} is the raw |
| 4159 | prefix argument. Thus, typing @kbd{C-u} as the prefix sets the | 4160 | prefix argument. Thus, typing @kbd{C-u} as the prefix sets the |
| @@ -4181,8 +4182,9 @@ respect to the entire window group. | |||
| 4181 | 4182 | ||
| 4182 | @defopt recenter-redisplay | 4183 | @defopt recenter-redisplay |
| 4183 | If this variable is non-@code{nil}, calling @code{recenter} with a | 4184 | If this variable is non-@code{nil}, calling @code{recenter} with a |
| 4184 | @code{nil} argument redraws the frame. The default value is | 4185 | @code{nil} @var{count} argument and non-@code{nil} @var{redisplay} |
| 4185 | @code{tty}, which means only redraw the frame if it is a tty frame. | 4186 | argument redraws the frame. The default value is @code{tty}, which |
| 4187 | means only redraw the frame if it is a tty frame. | ||
| 4186 | @end defopt | 4188 | @end defopt |
| 4187 | 4189 | ||
| 4188 | @deffn Command recenter-top-bottom &optional count | 4190 | @deffn Command recenter-top-bottom &optional count |
| @@ -690,6 +690,11 @@ manual for more details. | |||
| 690 | * Lisp Changes in Emacs 27.1 | 690 | * Lisp Changes in Emacs 27.1 |
| 691 | 691 | ||
| 692 | +++ | 692 | +++ |
| 693 | ** The function 'recenter' accepts an additional optional argument. | ||
| 694 | If the optional second argument is nil, recenter will not redisplay | ||
| 695 | the frame regardless of the value of 'recenter-redisplay'. | ||
| 696 | |||
| 697 | +++ | ||
| 693 | ** New functions 'major-mode-suspend' and 'major-mode-restore'. | 698 | ** New functions 'major-mode-suspend' and 'major-mode-restore'. |
| 694 | Use them when switching temporarily to another major mode, e.g. for | 699 | Use them when switching temporarily to another major mode, e.g. for |
| 695 | 'hexl-mode', or to switch between 'c-mode' and 'image-mode' in XPM. | 700 | 'hexl-mode', or to switch between 'c-mode' and 'image-mode' in XPM. |
diff --git a/lisp/window.el b/lisp/window.el index fdd510401da..6d9d8bdcd2e 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -8778,15 +8778,15 @@ A prefix argument is handled like `recenter': | |||
| 8778 | (min (max 0 scroll-margin) | 8778 | (min (max 0 scroll-margin) |
| 8779 | (truncate (/ (window-body-height) 4.0))))) | 8779 | (truncate (/ (window-body-height) 4.0))))) |
| 8780 | (cond ((eq recenter-last-op 'middle) | 8780 | (cond ((eq recenter-last-op 'middle) |
| 8781 | (recenter)) | 8781 | (recenter nil t)) |
| 8782 | ((eq recenter-last-op 'top) | 8782 | ((eq recenter-last-op 'top) |
| 8783 | (recenter this-scroll-margin)) | 8783 | (recenter this-scroll-margin t)) |
| 8784 | ((eq recenter-last-op 'bottom) | 8784 | ((eq recenter-last-op 'bottom) |
| 8785 | (recenter (- -1 this-scroll-margin))) | 8785 | (recenter (- -1 this-scroll-margin) t)) |
| 8786 | ((integerp recenter-last-op) | 8786 | ((integerp recenter-last-op) |
| 8787 | (recenter recenter-last-op)) | 8787 | (recenter recenter-last-op t)) |
| 8788 | ((floatp recenter-last-op) | 8788 | ((floatp recenter-last-op) |
| 8789 | (recenter (round (* recenter-last-op (window-height)))))))))) | 8789 | (recenter (round (* recenter-last-op (window-height))) t))))))) |
| 8790 | 8790 | ||
| 8791 | (define-key global-map [?\C-l] 'recenter-top-bottom) | 8791 | (define-key global-map [?\C-l] 'recenter-top-bottom) |
| 8792 | 8792 | ||
diff --git a/src/window.c b/src/window.c index a97f1dd3efb..20f6862e3b4 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -5896,22 +5896,23 @@ displayed_window_lines (struct window *w) | |||
| 5896 | } | 5896 | } |
| 5897 | 5897 | ||
| 5898 | 5898 | ||
| 5899 | DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", | 5899 | DEFUN ("recenter", Frecenter, Srecenter, 0, 2, "P", |
| 5900 | doc: /* Center point in selected window and maybe redisplay frame. | 5900 | doc: /* Center point in selected window and maybe redisplay frame. |
| 5901 | With a numeric prefix argument ARG, recenter putting point on screen line ARG | 5901 | With a numeric prefix argument ARG, recenter putting point on screen line ARG |
| 5902 | relative to the selected window. If ARG is negative, it counts up from the | 5902 | relative to the selected window. If ARG is negative, it counts up from the |
| 5903 | bottom of the window. (ARG should be less than the height of the window.) | 5903 | bottom of the window. (ARG should be less than the height of the window.) |
| 5904 | 5904 | ||
| 5905 | If ARG is omitted or nil, then recenter with point on the middle line of | 5905 | If ARG is omitted or nil, then recenter with point on the middle line |
| 5906 | the selected window; if the variable `recenter-redisplay' is non-nil, | 5906 | of the selected window; if REDISPLAY & `recenter-redisplay' are |
| 5907 | also erase the entire frame and redraw it (when `auto-resize-tool-bars' | 5907 | non-nil, also erase the entire frame and redraw it (when |
| 5908 | is set to `grow-only', this resets the tool-bar's height to the minimum | 5908 | `auto-resize-tool-bars' is set to `grow-only', this resets the |
| 5909 | height needed); if `recenter-redisplay' has the special value `tty', | 5909 | tool-bar's height to the minimum height needed); if |
| 5910 | then only tty frames are redrawn. | 5910 | `recenter-redisplay' has the special value `tty', then only tty frames |
| 5911 | are redrawn. | ||
| 5911 | 5912 | ||
| 5912 | Just C-u as prefix means put point in the center of the window | 5913 | Just C-u as prefix means put point in the center of the window |
| 5913 | and redisplay normally--don't erase and redraw the frame. */) | 5914 | and redisplay normally--don't erase and redraw the frame. */) |
| 5914 | (register Lisp_Object arg) | 5915 | (Lisp_Object arg, Lisp_Object redisplay) |
| 5915 | { | 5916 | { |
| 5916 | struct window *w = XWINDOW (selected_window); | 5917 | struct window *w = XWINDOW (selected_window); |
| 5917 | struct buffer *buf = XBUFFER (w->contents); | 5918 | struct buffer *buf = XBUFFER (w->contents); |
| @@ -5931,7 +5932,8 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5931 | 5932 | ||
| 5932 | if (NILP (arg)) | 5933 | if (NILP (arg)) |
| 5933 | { | 5934 | { |
| 5934 | if (!NILP (Vrecenter_redisplay) | 5935 | if (!NILP (redisplay) |
| 5936 | && !NILP (Vrecenter_redisplay) | ||
| 5935 | && (!EQ (Vrecenter_redisplay, Qtty) | 5937 | && (!EQ (Vrecenter_redisplay, Qtty) |
| 5936 | || !NILP (Ftty_type (selected_frame)))) | 5938 | || !NILP (Ftty_type (selected_frame)))) |
| 5937 | { | 5939 | { |