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: Sat, 30 Jun 2018 20:20:24 +0000 Message-ID: <878t6wxbzr.fsf@gmail.com> References: <87po2gkxpi.fsf@gmail.com> <87sh57yrax.fsf@gmail.com> <83lgawmwup.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1530389955 27361 195.159.176.226 (30 Jun 2018 20:19:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Jun 2018 20:19:15 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: 31325@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 30 22:19:11 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 1fZMKr-0006wB-7R for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jun 2018 22:19:09 +0200 Original-Received: from localhost ([::1]:47894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZMMy-0005QA-1R for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jun 2018 16:21:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZMMk-0005Q5-71 for bug-gnu-emacs@gnu.org; Sat, 30 Jun 2018 16:21:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZMMg-0007at-Q8 for bug-gnu-emacs@gnu.org; Sat, 30 Jun 2018 16:21:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZMMg-0007aQ-Im for bug-gnu-emacs@gnu.org; Sat, 30 Jun 2018 16:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fZMMg-0003Mj-B3 for bug-gnu-emacs@gnu.org; Sat, 30 Jun 2018 16:21: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: Sat, 30 Jun 2018 20:21: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.153039004212888 (code B ref 31325); Sat, 30 Jun 2018 20:21:02 +0000 Original-Received: (at 31325) by debbugs.gnu.org; 30 Jun 2018 20:20:42 +0000 Original-Received: from localhost ([127.0.0.1]:41478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZMMM-0003Ln-64 for submit@debbugs.gnu.org; Sat, 30 Jun 2018 16:20:42 -0400 Original-Received: from mail-qk0-f193.google.com ([209.85.220.193]:33134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZMMJ-0003LZ-TW for 31325@debbugs.gnu.org; Sat, 30 Jun 2018 16:20:40 -0400 Original-Received: by mail-qk0-f193.google.com with SMTP id c131-v6so6814858qkb.0 for <31325@debbugs.gnu.org>; Sat, 30 Jun 2018 13:20:39 -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=MaFqZd+j1t1Fjk2Z0Ro3Bby55iv9UZZW3Kxvrllxv1Y=; b=G2iayylChyJDODvxx6+Ad0qduQG9yTFYffRJampvdyKCozJmV2WkgdU754yK7rQMO3 f3Y5qVgirHtFOmOscc+AoTHCGqNqSchWbyG3zBbUyXctvWd8xHM295Fjh6/y/A2rj01w yl7sTgkRC3iH/Vy3aeTrXyMqK+0RAkySKsrTl3I/jEz4yhIreH5s9w/SdERl7HBeyxZb CpwrOlaj42bbmioZu7w9U3CzbyvF0U+ftbbHcejIG/T4vIprnpgdfpnyIds303tAHPjp 3WD7WtJfdQIDQyw4MFVB8VNDCErlxnC0rt8C9Q8mEYvV/QTJDE5iOGwH2PRbgT9ZRwDF JLWQ== 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=MaFqZd+j1t1Fjk2Z0Ro3Bby55iv9UZZW3Kxvrllxv1Y=; b=W5t7mADOqh1/RrMPmSk1kSEadSxUrdYZmrt65gxC3jLz5Xd2Vtmm32SFp1l/zlJez4 8N0hYGyb162ebYhi1dA/aD7rWmmYt+Uzi36tYc+SveHwpF6q/oqsXEWXyBkucLz2DhOS QRpAmJs2ziBBu+c3pXboeyKyD91rbyJE6ArgmCUTHDFty42IbjTe662sxjMopr8gdXeI INYltug+3Lb3rnIwbju644/NIJVTHVWrndaV1wbkkUdwDlqDG3s/2vkdzHHNsmD9hghs 4BnqcD4C8eciepbTQ6i3ApwYwoRLYAjae3HAKU3ZvWX5zqeMQ0mephsGntek+WDKqP8d shkQ== X-Gm-Message-State: APt69E1Mf+mfiPfLKi/8tIVe5LkwXSUmVIIW375LHucOvvMLDQS9MSmC Rrph9exhyHoRi/ccyHu+5p6jSeYD X-Google-Smtp-Source: AAOMgpfXDgYAtBRhwHUQ/NeX65QBxYXMESxSK74R3Q+8+5IswxzBO8yWE6TB0gVgJBsq0MzNVULrkA== X-Received: by 2002:a37:c8e:: with SMTP id 136-v6mr17311153qkm.197.1530390033909; Sat, 30 Jun 2018 13:20:33 -0700 (PDT) Original-Received: from 36032806ccb0 (cpe-184-152-55-93.nyc.res.rr.com. [184.152.55.93]) by smtp.gmail.com with ESMTPSA id c191-v6sm8167959qkb.22.2018.06.30.13.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jun 2018 13:20:32 -0700 (PDT) In-reply-to: <83lgawmwup.fsf@gnu.org> 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:148027 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: John Shahid >> Date: Thu, 28 Jun 2018 13:27:34 +0000 >> Cc: 31325@debbugs.gnu.org >> >> >> 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. > > Thanks, but please also include a NEWS entry announcing the change, > and a suitable change for the ELisp manual. > > And I have a few comments: > >> - (register Lisp_Object arg) >> + (register Lisp_Object arg, register Lisp_Object redisplay) > > I believe nowadays we remove the 'register' qualifiers whenever we > change code that uses them. > >> { >> 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) > ^^^^^^^^^ > This should have been Vrecenter_redisplay, right? fixed all the issues mentioned above in the attached patch and documented the change in the NEWS file and the manual. cheers, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-a-new-argument-to-recenter-to-allow-finer-contro.patch >From 1b7380df866e3ca7c1a940a92c36f43ce8e5043f 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 --- doc/lispref/windows.texi | 12 +++++++----- etc/NEWS | 5 +++++ lisp/window.el | 10 +++++----- src/window.c | 20 +++++++++++--------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 5497759595..9740bbebf2 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -4138,7 +4138,7 @@ Textual Scrolling only if point is already on that position do they signal an error. @end defopt -@deffn Command recenter &optional count +@deffn Command recenter &optional count redisplay @cindex centering point This function scrolls the text in the selected window so that point is displayed at a specified vertical position within the window. It does @@ -4152,8 +4152,9 @@ Textual Scrolling If @var{count} is @code{nil} (or a non-@code{nil} list), @code{recenter} puts the line containing point in the middle of the -window. If @var{count} is @code{nil}, this function may redraw the -frame, according to the value of @code{recenter-redisplay}. +window. If @var{count} is @code{nil} and @var{redisplay} is +non-@code{nil}, this function may redraw the frame, according to the +value of @code{recenter-redisplay}. When @code{recenter} is called interactively, @var{count} is the raw prefix argument. Thus, typing @kbd{C-u} as the prefix sets the @@ -4181,8 +4182,9 @@ Textual Scrolling @defopt recenter-redisplay If this variable is non-@code{nil}, calling @code{recenter} with a -@code{nil} argument redraws the frame. The default value is -@code{tty}, which means only redraw the frame if it is a tty frame. +@code{nil} @var{count} argument and non-@code{nil} @var{redisplay} +argument redraws the frame. The default value is @code{tty}, which +means only redraw the frame if it is a tty frame. @end defopt @deffn Command recenter-top-bottom &optional count diff --git a/etc/NEWS b/etc/NEWS index 12757f61d2..8adb962120 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -658,6 +658,11 @@ manual for more details. * Lisp Changes in Emacs 27.1 ++++ +** The function 'recenter' accepts an additional optional argument. +If the optional second argument is nil, recenter will not redisplay +the frame regardless of the value of 'recenter-redisplay'. + +++ ** New functions 'major-mode-suspend' and 'major-mode-restore'. Use them when switching temporarily to another major mode, e.g. for 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..a966e99ca8 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) + (Lisp_Object arg, Lisp_Object redisplay) { struct window *w = XWINDOW (selected_window); struct buffer *buf = XBUFFER (w->contents); @@ -5933,7 +5934,8 @@ and redisplay normally--don't erase and redraw the frame. */) if (NILP (arg)) { - if (!NILP (Vrecenter_redisplay) + if (!NILP (redisplay) + && !NILP (Vrecenter_redisplay) && (!EQ (Vrecenter_redisplay, Qtty) || !NILP (Ftty_type (selected_frame)))) { -- 2.18.0 --=-=-=--