unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: John Shahid <jvshahid@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 31325@debbugs.gnu.org
Subject: bug#31325: 27.0.50; PROPOSAL: introduce a new function to recenter without redisplaying the frame
Date: Thu, 28 Jun 2018 13:27:34 +0000	[thread overview]
Message-ID: <87sh57yrax.fsf@gmail.com> (raw)
In-Reply-To: <jwvsh73vspr.fsf-monnier+bug#31325@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> This BUG is a continuation of this help-gnu-emacs mailing list
>> thread [1]. As mentioned in the thread, I ran into a terminal flickering
>> issue in flycheck which turns out to be caused by `recenter'
>> redisplaying the frame when `recenter-redisplay' value is either `t' or
>> `tty'. I agree with the arguments in the thread to maintain the backward
>> compatible behavior. Instead, I'm proposing one of the following
>> alternatives:
>
> Indeed, most/all uses from Elisp shouldn't redisplay.
>
>> 1. introduce a new lisp function for recentering and discourage the use
>> of `recenter' from lisp (i.e. declaring it `interactive-only'), or
>> 2. add a new `recenter-and-redisplay' and bound it to C-l
>> Also, Stefan's suggestion/possible solution:
>> 3. adding an argument to `recenter' to control the redisplay behavior
>
> Either of those is OK.  The benefit of the 3rd is that it would likely
> "magically fix" 99% of the existing uses (I'm thinking of adding an
> optional argument which we could call `and-redisplay` which when non-nil
> tells recenter to do a redisplay, so all existing Elisp calls would be
> implicitly modified not to cause a redisplay).

I ended up going with option 3. I also used `redisplay` instead of
`and-redisplay`. I felt the `and` is redundant, not sure how strongly
you feel about the name.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-a-new-argument-to-recenter-to-allow-finer-contro.patch --]
[-- Type: text/x-diff, Size: 3683 bytes --]

From a8c544c40f1d01544ced20fad3e81a231f5715c7 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid@gmail.com>
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


  reply	other threads:[~2018-06-28 13:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01  0:48 bug#31325: 27.0.50; PROPOSAL: introduce a new function to recenter without redisplaying the frame John Shahid
2018-05-08  1:37 ` Stefan Monnier
2018-06-28 13:27   ` John Shahid [this message]
2018-06-30  9:45     ` Eli Zaretskii
2018-06-30 20:20       ` John Shahid
2018-07-01  9:05         ` martin rudalics
2018-07-01 13:17           ` John Shahid
2018-07-01 16:22             ` Eli Zaretskii
2018-07-01 16:54               ` John Shahid
2018-07-01 17:03                 ` Eli Zaretskii
2018-07-01 17:14                   ` Eli Zaretskii
2018-07-01 17:25                     ` John Shahid
2018-07-01 20:17                       ` Drew Adams
2018-07-01 20:56                         ` John Shahid
2018-07-01 23:04                           ` Drew Adams
2018-07-02  2:27                             ` John Shahid
2018-07-02 15:18                               ` Eli Zaretskii
2018-07-01 17:18                   ` John Shahid
2018-07-01 18:05                     ` Eli Zaretskii
2018-07-01 18:58                       ` John Shahid
2018-07-02 15:22                         ` Eli Zaretskii
2018-07-02 20:38                           ` John Shahid
2018-07-03  8:49                             ` Robert Pluim
2018-07-03 16:38                             ` John Shahid
2018-07-07  9:09                               ` Eli Zaretskii

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=87sh57yrax.fsf@gmail.com \
    --to=jvshahid@gmail.com \
    --cc=31325@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).