From a8c544c40f1d01544ced20fad3e81a231f5715c7 Mon Sep 17 00:00:00 2001 From: John Shahid Date: Thu, 28 Jun 2018 09:13:45 -0400 Subject: [PATCH] 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. * window.el (recenter-top-bottom): pass an extra non-nil argument to `recenter' to force a redisplay --- lisp/window.el | 10 +++++----- src/window.c | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index fdd510401d..6d9d8bdcd2 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8778,15 +8778,15 @@ recenter-top-bottom (min (max 0 scroll-margin) (truncate (/ (window-body-height) 4.0))))) (cond ((eq recenter-last-op 'middle) - (recenter)) + (recenter nil t)) ((eq recenter-last-op 'top) - (recenter this-scroll-margin)) + (recenter this-scroll-margin t)) ((eq recenter-last-op 'bottom) - (recenter (- -1 this-scroll-margin))) + (recenter (- -1 this-scroll-margin) t)) ((integerp recenter-last-op) - (recenter recenter-last-op)) + (recenter recenter-last-op t)) ((floatp recenter-last-op) - (recenter (round (* recenter-last-op (window-height)))))))))) + (recenter (round (* recenter-last-op (window-height))) t))))))) (define-key global-map [?\C-l] 'recenter-top-bottom) diff --git a/src/window.c b/src/window.c index 81fd7f2b47..fcdb0d444e 100644 --- a/src/window.c +++ b/src/window.c @@ -5898,22 +5898,23 @@ displayed_window_lines (struct window *w) } -DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", +DEFUN ("recenter", Frecenter, Srecenter, 0, 2, "P", doc: /* Center point in selected window and maybe redisplay frame. With a numeric prefix argument ARG, recenter putting point on screen line ARG relative to the selected window. If ARG is negative, it counts up from the bottom of the window. (ARG should be less than the height of the window.) -If ARG is omitted or nil, then recenter with point on the middle line of -the selected window; if the variable `recenter-redisplay' is non-nil, -also erase the entire frame and redraw it (when `auto-resize-tool-bars' -is set to `grow-only', this resets the tool-bar's height to the minimum -height needed); if `recenter-redisplay' has the special value `tty', -then only tty frames are redrawn. +If ARG is omitted or nil, then recenter with point on the middle line +of the selected window; if REDISPLAY & `recenter-redisplay' are +non-nil, also erase the entire frame and redraw it (when +`auto-resize-tool-bars' is set to `grow-only', this resets the +tool-bar's height to the minimum height needed); if +`recenter-redisplay' has the special value `tty', then only tty frames +are redrawn. Just C-u as prefix means put point in the center of the window and redisplay normally--don't erase and redraw the frame. */) - (register Lisp_Object arg) + (register Lisp_Object arg, register Lisp_Object redisplay) { struct window *w = XWINDOW (selected_window); struct buffer *buf = XBUFFER (w->contents); @@ -5933,8 +5934,9 @@ and redisplay normally--don't erase and redraw the frame. */) if (NILP (arg)) { - if (!NILP (Vrecenter_redisplay) - && (!EQ (Vrecenter_redisplay, Qtty) + if (!NILP (redisplay) + && !NILP (Vrecenter_redisplay) + && (!EQ (redisplay, Qtty) || !NILP (Ftty_type (selected_frame)))) { ptrdiff_t i; -- 2.18.0