aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Shahid2018-06-28 09:13:45 -0400
committerEli Zaretskii2018-07-01 19:05:37 +0300
commit260768a64be39aada03247d6057698df97bcb800 (patch)
treef61ec4466fc4768a2b0c610a8fc1ac931a067746
parent7edc019651b3e16592d2d16616a7d4cecc285ae6 (diff)
downloademacs-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.texi12
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/window.el10
-rw-r--r--src/window.c20
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);
4138only if point is already on that position do they signal an error. 4138only 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
4143This function scrolls the text in the selected window so that point is 4143This function scrolls the text in the selected window so that point is
4144displayed at a specified vertical position within the window. It does 4144displayed at a specified vertical position within the window. It does
@@ -4152,8 +4152,9 @@ line in the window.
4152 4152
4153If @var{count} is @code{nil} (or a non-@code{nil} list), 4153If @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
4155window. If @var{count} is @code{nil}, this function may redraw the 4155window. If @var{count} is @code{nil} and @var{redisplay} is
4156frame, according to the value of @code{recenter-redisplay}. 4156non-@code{nil}, this function may redraw the frame, according to the
4157value of @code{recenter-redisplay}.
4157 4158
4158When @code{recenter} is called interactively, @var{count} is the raw 4159When @code{recenter} is called interactively, @var{count} is the raw
4159prefix argument. Thus, typing @kbd{C-u} as the prefix sets the 4160prefix 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
4183If this variable is non-@code{nil}, calling @code{recenter} with a 4184If 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. 4186argument redraws the frame. The default value is @code{tty}, which
4187means 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
diff --git a/etc/NEWS b/etc/NEWS
index 63c59ae9218..d5f1abb5feb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
694If the optional second argument is nil, recenter will not redisplay
695the 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'.
694Use them when switching temporarily to another major mode, e.g. for 699Use 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
5899DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", 5899DEFUN ("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.
5901With a numeric prefix argument ARG, recenter putting point on screen line ARG 5901With a numeric prefix argument ARG, recenter putting point on screen line ARG
5902relative to the selected window. If ARG is negative, it counts up from the 5902relative to the selected window. If ARG is negative, it counts up from the
5903bottom of the window. (ARG should be less than the height of the window.) 5903bottom of the window. (ARG should be less than the height of the window.)
5904 5904
5905If ARG is omitted or nil, then recenter with point on the middle line of 5905If ARG is omitted or nil, then recenter with point on the middle line
5906the selected window; if the variable `recenter-redisplay' is non-nil, 5906of the selected window; if REDISPLAY & `recenter-redisplay' are
5907also erase the entire frame and redraw it (when `auto-resize-tool-bars' 5907non-nil, also erase the entire frame and redraw it (when
5908is 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
5909height needed); if `recenter-redisplay' has the special value `tty', 5909tool-bar's height to the minimum height needed); if
5910then only tty frames are redrawn. 5910`recenter-redisplay' has the special value `tty', then only tty frames
5911are redrawn.
5911 5912
5912Just C-u as prefix means put point in the center of the window 5913Just C-u as prefix means put point in the center of the window
5913and redisplay normally--don't erase and redraw the frame. */) 5914and 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 {