From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31193: 26.1; error in `term-down' after window configuration change Date: Tue, 17 Apr 2018 20:07:41 -0400 Message-ID: <87muy1tm0i.fsf@gmail.com> References: <5480f11459b73e4cf0aabe12da5ce675@webmail.orcon.net.nz> <87sh7ut199.fsf@gmail.com> <7063321d07dcc711cc24699e095dfb9d@webmail.orcon.net.nz> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1524009969 4183 195.159.176.226 (18 Apr 2018 00:06:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2018 00:06:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 31193@debbugs.gnu.org To: Phil Sainty Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 18 02:06:04 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 1f8abr-0000xz-0h for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 02:06:03 +0200 Original-Received: from localhost ([::1]:43957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8adx-00017d-Ou for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Apr 2018 20:08:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8adr-00017B-IK for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 20:08:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8adm-0003I9-JH for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 20:08:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8adm-0003Hz-Cx for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 20:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f8adm-0006yt-1r for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 20:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Apr 2018 00:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31193 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31193-submit@debbugs.gnu.org id=B31193.152401007226819 (code B ref 31193); Wed, 18 Apr 2018 00:08:02 +0000 Original-Received: (at 31193) by debbugs.gnu.org; 18 Apr 2018 00:07:52 +0000 Original-Received: from localhost ([127.0.0.1]:58236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8adc-0006yQ-6M for submit@debbugs.gnu.org; Tue, 17 Apr 2018 20:07:52 -0400 Original-Received: from mail-it0-f47.google.com ([209.85.214.47]:55356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8ada-0006y9-Mg; Tue, 17 Apr 2018 20:07:51 -0400 Original-Received: by mail-it0-f47.google.com with SMTP id 145-v6so314554itf.5; Tue, 17 Apr 2018 17:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=SI+Y8q5ucyJ14VKZr1wfKjBjz7hx4QpvH6JNfT/fy8I=; b=YwqpK2WJ/ZA0MbKVrmnqmBLw/pg5PHGVxWUrNiTlSqchnXzCcjzDVmOhiRddwiSOGk Xi6DsS/iT1VLsZg+rwB6QL/+rUcpFz6NWwx3tzBJplgh/DI8G+NEV3Gq/7uVnc+n51/s 4W0EDAV8aJUt3GQkM3u+tFZaNAYMIOq3+057va9I0pEnoMc2TUXQndPxFxsMyKxTyETH bSRTm8n7DiJy3rkNOgX3wqjHRgsO4yNfIscXfh4HRJmC8g15Ho6BHYO8QbHDEzrzpou2 k+TQPEkeR3pYNsm4H7MPaZUVOvldkCdKvZoxD7nCarVmCWn2JCeMNEMuoxM65wmKX2LH LZrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=SI+Y8q5ucyJ14VKZr1wfKjBjz7hx4QpvH6JNfT/fy8I=; b=DHgnTa0IInEwQIknDoY2kjXQiC4PMixYDrcDBXhPKvVQ0sLhyDv5GmbrwRD1p2Deth Gq/H/hUOGYljgZ9lTe1lUTUJuuVgs/QbpV2JarcbVmyBCa2J9AX8DCf86WagMcIuufjt LjSVMMGRLP5rzf16Ve1xtgnPCbeP3HU3hd5uGGPu0eCIQSds1ZEd4mB2h/2tECfn27zm nh056DUCbLFTlmAPczEBpBmAldznW5PwPMSZNCnot8rU1yqxfOV0PEQG9GnNYFQUsIiR IRKmooJCo54RyxFh7uGrwIYOH3fweY2FosP88C4LXsWkbLgaPOU0R4Np9EgpFOgZ9RM4 M75g== X-Gm-Message-State: ALQs6tAWPjelTWPpgDo2gXQgwsuvTVXJbwiYZrXCdIPoYL7NA2WY4kgb +mQrkdV6F3OXculXigN7JqeKtw== X-Google-Smtp-Source: AIpwx48l9yAOlEsgFsz2bnyI50cLTtbsBtSe9ddceQv+/Qov2IL2maWlPUR5UlQi0fb3pE067q+Sbg== X-Received: by 2002:a24:718a:: with SMTP id n132-v6mr312648itc.7.1524010064908; Tue, 17 Apr 2018 17:07:44 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id j195-v6sm124341itb.40.2018.04.17.17.07.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Apr 2018 17:07:43 -0700 (PDT) In-Reply-To: <7063321d07dcc711cc24699e095dfb9d@webmail.orcon.net.nz> (Phil Sainty's message of "Wed, 18 Apr 2018 01:49:20 +1200") 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:145539 Archived-At: --=-=-= Content-Type: text/plain tags 31193 + patch quit Phil Sainty writes: > On 2018-04-18 01:23, Noam Postavsky wrote: >> Hmm, I'm not able to reproduce this, even though it makes sense to me >> that my fix for Bug#30544 [1: a64c11a3aa] would cause this. Perhaps it >> depends on your shell prompt as well? > > I do have a non-trivial prompt; but after setting PS1="$ " I still see > the same issue, so I'm unsure whether that's a factor. My shell is > bash. Hmm, maybe it's a difference in bash versions? I tried adding a newline to my prompt with PS1=$'one\ntwo$ ', but bash doesn't send the newline after the terminal resizes. Seems it's clever enough just to redraw the last line. GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) And since terminal-emulate-terminal doesn't receive a \n character, it doesn't call term-down before calling (term-current-row) near the end of that function: (when (>= (term-current-row) term-height) (term-handle-deferred-scroll)) So I definitely can't see how you trigger this with PS1="$ ", but perhaps your version of bash sends a newline for some other reason? Can you show the backtrace with PS1="$ "? >> I think changing them to function calls, i.e., (term-current-row) >> instead of term-current-row would be the right thing; all the other >> term >> functions use the function rather than accessing the variable directly. > > That sounds sane, and I can confirm that it fixes the problem. Okay, here's the patch with message. Eli, should I apply this to emacs-26? I believe it's safe because the term-current-row function simply returns the value of the term-current-row variable if that is non-nil. Hence it should only affect cases where we were going to signal an error due to type-mismatch anyway. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Don-t-assume-term-current-row-cache-is-valid-Bug-311.patch Content-Description: patch >From c1faca2b07ac86f84450bbb95ecb6d8635410281 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 17 Apr 2018 19:17:18 -0400 Subject: [PATCH] Don't assume term-current-row cache is valid (Bug#31193) * lisp/term.el (term-down): Call `term-current-row' instead of directly accessing the variable `term-current-row. Following a resize of the terminal's window, `term-current-row' is reset to nil, so it is not safe to assume it is a number. --- lisp/term.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/term.el b/lisp/term.el index 0a5efa4abc..6860ea6934 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -3764,7 +3764,7 @@ term-down (let ((start-column (term-horizontal-column))) (when (and check-for-scroll (or term-scroll-with-delete term-pager-count)) (setq down (term-handle-scroll down))) - (unless (and (= term-current-row 0) (< down 0)) + (unless (and (= (term-current-row) 0) (< down 0)) (term-adjust-current-row-cache down) (when (or (/= (point) (point-max)) (< down 0)) (setq down (- down (term-vertical-motion down))))) @@ -3774,7 +3774,7 @@ term-down (setq term-current-column 0) (setq term-start-line-column 0)) (t - (when (= term-current-row 0) + (when (= (term-current-row) 0) ;; Insert lines if at the beginning. (save-excursion (term-insert-char ?\n (- down))) (save-excursion -- 2.11.0 --=-=-=--