From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Shahid Newsgroups: gmane.emacs.bugs 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 Message-ID: <87sh57yrax.fsf@gmail.com> References: <87po2gkxpi.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1530192601 11728 195.159.176.226 (28 Jun 2018 13:30:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 28 Jun 2018 13:30:01 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: 31325@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 28 15:29:57 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fYWzk-0002wS-Uc for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Jun 2018 15:29:57 +0200 Original-Received: from localhost ([::1]:36738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYX1s-0001W4-BB for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Jun 2018 09:32:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYWy0-0006zq-S4 for bug-gnu-emacs@gnu.org; Thu, 28 Jun 2018 09:28:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYWxu-0007KZ-Sw for bug-gnu-emacs@gnu.org; Thu, 28 Jun 2018 09:28:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYWxu-0007KR-OG for bug-gnu-emacs@gnu.org; Thu, 28 Jun 2018 09:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fYWxu-0008PQ-Cg for bug-gnu-emacs@gnu.org; Thu, 28 Jun 2018 09:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: John Shahid Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Jun 2018 13:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31325 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31325-submit@debbugs.gnu.org id=B31325.153019247132293 (code B ref 31325); Thu, 28 Jun 2018 13:28:02 +0000 Original-Received: (at 31325) by debbugs.gnu.org; 28 Jun 2018 13:27:51 +0000 Original-Received: from localhost ([127.0.0.1]:38316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fYWxj-0008On-CX for submit@debbugs.gnu.org; Thu, 28 Jun 2018 09:27:51 -0400 Original-Received: from mail-qt0-f171.google.com ([209.85.216.171]:38202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fYWxf-0008OM-OK for 31325@debbugs.gnu.org; Thu, 28 Jun 2018 09:27:49 -0400 Original-Received: by mail-qt0-f171.google.com with SMTP id c5-v6so4677375qth.5 for <31325@debbugs.gnu.org>; Thu, 28 Jun 2018 06:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=hN2vzKy7CEcmXaeQlzPWeT7AhV7i4wp4WFUeC10CK6Q=; b=HcuvZKiaQJ2XF55S7qGrqG1YE9F/Ib+hFs6TheYKOBKUoI7kXiXWVqiabbhB06j2GN M+GIhRlCvc3dIYSJ1vnisOfwazI+tlxN4ii0eo4OLJBNDd3bsdG1sWlJqWg0RJs2Qkcq 1j+0IugAC24+zky2VCtbG7oUeJhgG7CehP+jo6q1pD8zfJnvYKns9N0fqKtVaUhWBKBU eWVGxO0FxBsPVpMERlrBsnvJnjLF9fLQbAAfabAQj+gKwvJ5eaeZRtBJ2iyA7FjHrOWD 6HuyeVCwu+uYVZvYz0aYeHDQnqdJp/N50rUWeGOf03gKvCS2UayGFb08/grFqr/4/K3G bOEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=hN2vzKy7CEcmXaeQlzPWeT7AhV7i4wp4WFUeC10CK6Q=; b=jfh9aMnO7qtqAWCG88Ymz0IHeiG5/fO6YAD8CW9kQiSV9dbUUgYLlKqFumDOXF9V6s EN4nbcPEIJjrq8Rg1Gzinf4CZ3x2zz6/fpanAWl5bgXF82HjdyQQFvPJ7kqiwgEQvsQo tZYwlyrZKBAuPGzQhz3UbxDO2fz4B/jcvfc+DuRxyVBfTx3quWDnDOPN7AwZIOkOqnfF Rc2sxxU4KNnxTbqTZQkB25xUWPJpzoyKjAcBXE8dc7eQ0QEso28Z+yhGwFoZNC0b8SKu SyDV7yXuYdiE9wIm4XegRYWj376jRlIbhFGKVPnzTbmQcCUeTx9cPGAVi8r+v15+MCyl 2doA== X-Gm-Message-State: APt69E1N8tVyJKFIhvP1SD85C3sMOiBIiWq7p4n6llgiwTzhZMfnPk18 tIL882+oxeuwB1JuaML8+t2R7zi3 X-Google-Smtp-Source: AAOMgpeZMP1jckqGFjPQ6QMAAlWBVI/3rqPpY2hcL9pdHaS4s3bl89iwyu2W1JentAXvd839vVB8fg== X-Received: by 2002:a0c:94f1:: with SMTP id k46-v6mr9144472qvk.113.1530192461734; Thu, 28 Jun 2018 06:27:41 -0700 (PDT) Original-Received: from fc83e572df23 (mobile-107-107-57-88.mycingular.net. [107.107.57.88]) by smtp.gmail.com with ESMTPSA id q26-v6sm1257593qte.51.2018.06.28.06.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 06:27:40 -0700 (PDT) In-reply-to: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147908 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-a-new-argument-to-recenter-to-allow-finer-contro.patch >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 --=-=-=--