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: Sun, 01 Jul 2018 13:17:17 +0000 Message-ID: <87va9zxfhe.fsf@gmail.com> References: <87po2gkxpi.fsf@gmail.com> <87sh57yrax.fsf@gmail.com> <83lgawmwup.fsf@gnu.org> <878t6wxbzr.fsf@gmail.com> <5B38994B.2010605@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1530450967 4498 195.159.176.226 (1 Jul 2018 13:16:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Jul 2018 13:16:07 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: 31325@debbugs.gnu.org, monnier@iro.umontreal.ca To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 01 15:16:03 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 1fZcCw-000149-S9 for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jul 2018 15:16:03 +0200 Original-Received: from localhost ([::1]:54452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZcF4-0001Z3-2N for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jul 2018 09:18:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZcEw-0001Yy-8v for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 09:18:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZcEs-0007lJ-St for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 09:18:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33783) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZcEs-0007l3-NZ for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 09:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fZcEs-00058H-FY for bug-gnu-emacs@gnu.org; Sun, 01 Jul 2018 09:18: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: Sun, 01 Jul 2018 13:18: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.153045105219655 (code B ref 31325); Sun, 01 Jul 2018 13:18:02 +0000 Original-Received: (at 31325) by debbugs.gnu.org; 1 Jul 2018 13:17:32 +0000 Original-Received: from localhost ([127.0.0.1]:41680 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZcEN-00056w-VN for submit@debbugs.gnu.org; Sun, 01 Jul 2018 09:17:32 -0400 Original-Received: from mail-qt0-f171.google.com ([209.85.216.171]:32953) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZcEL-00056b-HZ for 31325@debbugs.gnu.org; Sun, 01 Jul 2018 09:17:29 -0400 Original-Received: by mail-qt0-f171.google.com with SMTP id l10-v6so11815082qtj.0 for <31325@debbugs.gnu.org>; Sun, 01 Jul 2018 06:17:29 -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=7oOnLlmUWXwaRulMqasRvIemifUqLZHSI6ufie032jA=; b=Rl4R4bg9LRAcglumSil0EDfJKwtFuji5w3R+v+GGYIEcL1JweSB5tDscocRb0H3N4Q VpcsvNneIgQS7sCfpGNFC5uJ2aFE2GArRTBj/xlAEAfwwDNLFy3Fh8+ycTXeOaQ31DjJ f1NiTdleJt/gUUNVLgBnFOR5N/5oNglaFy76t2egGb84O12cCKn1Z6Bwv5Q2ZgwUiMcb EW3mnQ4KkSsNU0yCbx2ISboOKH3Q9HMxEPPb/pMM+yJ4AmkHKZRnLErwaegiiWUNG08S 0tcVm8SAIYDw4qznRlvX/RAVnAVkWmsy1ocIAls1p9x9v0CvgxqlSSR9Jb2rPjRdIB80 WI6A== 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=7oOnLlmUWXwaRulMqasRvIemifUqLZHSI6ufie032jA=; b=XmN6Zr6G24P7LFg//uNFX1vL+r9GSeQi5QOawihXgS4jZpNWE9eTQUw8SNKE348m2e 71LgPNd0OkrBONzgsj13q+L3uKXbwDzgDCj6XC45ALPIOAK1oc2Os64zRZlhw/SKur7G 6lN8+MzfscgeFJerlEUikRBhaP1z+ee7E7I5kOkHGuBhaZpuXwMMSGkGwaYlRSWnmF7T 00C6q9w53HRkidXVO5WeeKNNb4pLrfmi6XxLMX6zzVffJblBWNuo86DEkezbiwvgXwAx j3CEfoUEJ8wwCSvlPDFHoExtyp2PtP5Ndy0HcjmThdZIVF25cWk6ByTbRLX/dXRcHIBy tT7g== X-Gm-Message-State: APt69E2hMW2wsuxib0oUbds34xwcF//jBM14LpLAoc3shRvlQ0qWDlhD jAXBASftAOEc8ibtIMDzo6U= X-Google-Smtp-Source: AAOMgpeSfH3x1K37uKC0az23AFfKePLorQaI4O/rjuZWLU10g1bCIpyrO1+mt3/1zoNvoFkj5+3X3Q== X-Received: by 2002:ac8:24fa:: with SMTP id t55-v6mr20656266qtt.196.1530451043827; Sun, 01 Jul 2018 06:17:23 -0700 (PDT) Original-Received: from 9a50e8462956 (cpe-184-152-55-93.nyc.res.rr.com. [184.152.55.93]) by smtp.gmail.com with ESMTPSA id c191-v6sm9102498qkb.22.2018.07.01.06.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 06:17:22 -0700 (PDT) In-reply-to: <5B38994B.2010605@gmx.at> 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:148044 Archived-At: --=-=-= Content-Type: text/plain martin rudalics writes: >> * window.c (recenter): add a new REDISPLAY argument to allow the > > Please capitalize the word after the colon ... > >> caller to control the redisplay behavior. `recenter' will only > > .. and use two spaces when beginning a new sentence. > > Thank you, martin Fixed in the attached patch. Cheers, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-a-new-argument-to-recenter-to-allow-finer-contro.patch >From c945faf3774ea8d331ced94b80422dfaebd83018 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 --=-=-=--