unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32839@debbugs.gnu.org
Subject: bug#32839: 27.0.50; recenter doesn't redisplay
Date: Sun, 30 Sep 2018 02:32:57 +0300	[thread overview]
Message-ID: <87k1n3ev6e.fsf@mail.linkov.net> (raw)
In-Reply-To: <83k1n66t0w.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 28 Sep 2018 09:22:07 +0300")

>> >>      (recenter 0 t)
>> >>
>> >>    Despite its REDISPLAY argument set to t, the frame is not redisplayed.
>> >
>> > This is how 'recenter' is documented to behave:
>> >
>> >   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 [...]
>> >
>> > IOW, the frame is redrawn only when ARG is nil and REDISPLAY is
>> > non-nil.
>>
>> Then why REDISPLAY is non-nil, if it doesn't redisplay the frame?
>
> There's a long history to this, you may wish to use "git -L" and look
> at the discussions/bug reports related to 'recenter'.
>
> The short answer is that this arrangement (which is new in Emacs 27)
> has its main goal to allow "C-l" to redraw the entire frame when the
> user so desires (by default, only on TTY frames), while avoiding the
> frame redraw in most, if not all, other situations, because redrawing
> a frame causes flickering.  This flickering is caused by Lisp programs
> calling 'recenter', directly or indirectly.

I see that before the recent changes, on a TTY 'C-l' and
all non-interactive calls of 'recenter' cleared the frame,
but now only interactive calls of 'recenter' redraw the frame.

OTOH, what I'm trying to achieve here is to allow C-l with a non-nil
argument to refresh the *Messages* buffer when recenter-redisplay is t.

An additional problem is that when 'recenter-positions' is customized
to not contain the keyword 'middle', then 'recenter-top-bottom' never
uses a nil arg of 'recenter', thus never redraws the frame.

But since redrawing a frame causes flickering, I'm not interested
in setting recenter-redisplay to t.  So I could implement more
fundamental changes for this only if you insist.

However, a minimal change that is needed here is to fix inconsistencies
in the recent changes: the argument name 'redisplay' is confusing -
it implies that it overrides the default value of recenter-redisplay
to force the redisplay.  A proper name would be 'interactive'.
There are dozens of commands already that use this naming convention.

diff --git a/lisp/window.el b/lisp/window.el
index 76de4207e7..584b25224c 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8759,17 +8759,19 @@ recenter-positions
   :version "23.2"
   :group 'windows)
 
-(defun recenter-top-bottom (&optional arg)
+(defun recenter-top-bottom (&optional arg interactive)
   "Move current buffer line to the specified window line.
 With no prefix argument, successive calls place point according
 to the cycling order defined by `recenter-positions'.
 
 A prefix argument is handled like `recenter':
  With numeric prefix ARG, move current line to window-line ARG.
- With plain `C-u', move current line to window center."
-  (interactive "P")
+ With plain `C-u', move current line to window center.
+
+Interactively, INTERACTIVE is non-nil and handled like in `recenter'."
+  (interactive "P\np")
   (cond
-   (arg (recenter arg t))                 ; Always respect ARG.
+   (arg (recenter arg interactive))     ; Always respect ARG.
    (t
     (setq recenter-last-op
 	  (if (eq this-command last-command)
@@ -8780,15 +8782,15 @@ recenter-top-bottom
 	   (min (max 0 scroll-margin)
 		(truncate (/ (window-body-height) 4.0)))))
       (cond ((eq recenter-last-op 'middle)
-	     (recenter nil t))
+	     (recenter nil interactive))
 	    ((eq recenter-last-op 'top)
-	     (recenter this-scroll-margin t))
+	     (recenter this-scroll-margin interactive))
 	    ((eq recenter-last-op 'bottom)
-	     (recenter (- -1 this-scroll-margin) t))
+	     (recenter (- -1 this-scroll-margin) interactive))
 	    ((integerp recenter-last-op)
-	     (recenter recenter-last-op t))
+	     (recenter recenter-last-op interactive))
 	    ((floatp recenter-last-op)
-	     (recenter (round (* recenter-last-op (window-height))) t)))))))
+	     (recenter (round (* recenter-last-op (window-height))) interactive)))))))
 
 (define-key global-map [?\C-l] 'recenter-top-bottom)
 
diff --git a/src/window.c b/src/window.c
index 6cdc52f90e..dd8c221308 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5944,16 +5944,16 @@ 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 REDISPLAY & `recenter-redisplay' are
+of the selected window; if INTERACTIVE & `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.  Interactively, REDISPLAY is always non-nil.
+are redrawn.  Interactively, INTERACTIVE is always non-nil.
 
 Just C-u as prefix means put point in the center of the window
 and redisplay normally--don't erase and redraw the frame.  */)
-  (Lisp_Object arg, Lisp_Object redisplay)
+  (Lisp_Object arg, Lisp_Object interactive)
 {
   struct window *w = XWINDOW (selected_window);
   struct buffer *buf = XBUFFER (w->contents);
@@ -5973,7 +5973,7 @@ and redisplay normally--don't erase and redraw the frame.  */)
 
   if (NILP (arg))
     {
-      if (!NILP (redisplay)
+      if (!NILP (interactive)
 	  && !NILP (Vrecenter_redisplay)
 	  && (!EQ (Vrecenter_redisplay, Qtty)
 	      || !NILP (Ftty_type (selected_frame))))





  reply	other threads:[~2018-09-29 23:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 19:11 bug#32839: 27.0.50; recenter doesn't redisplay Juri Linkov
2018-09-25 20:08 ` Eli Zaretskii
2018-09-25 20:55   ` Juri Linkov
2018-09-26  5:39     ` Eli Zaretskii
2018-09-26 23:55       ` Juri Linkov
2018-09-27  6:44         ` Eli Zaretskii
2018-09-27 22:59           ` Juri Linkov
2018-09-28  6:22             ` Eli Zaretskii
2018-09-29 23:32               ` Juri Linkov [this message]
2018-09-30  6:08                 ` Eli Zaretskii
2018-09-30 19:40                   ` Juri Linkov
2018-10-01  5:34                     ` Eli Zaretskii
2018-09-29 23:38               ` Juri Linkov
2018-09-30  6:22                 ` Eli Zaretskii
2018-09-30 19:46                   ` Juri Linkov
2018-10-01  6:58                     ` Eli Zaretskii
2018-10-08 22:56                   ` Juri Linkov
2018-10-09  7:44                     ` martin rudalics
2020-02-07  0:30           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1n3ev6e.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=32839@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).