From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#54800: 28.1; calc: Cursor positioned at weird position in calc stack Date: Sat, 09 Apr 2022 10:34:44 +0300 Message-ID: <831qy6aewb.fsf@gnu.org> References: <4a0319d6-b533-b3d8-bf52-bb18d74757e1@web.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10024"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54800@debbugs.gnu.org To: Christoph Arenz Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 09 09:35:24 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nd5cx-0002Vb-U7 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 09:35:23 +0200 Original-Received: from localhost ([::1]:44874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nd5cx-0002Ly-0D for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Apr 2022 03:35:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nd5cc-0002Lj-J1 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 03:35:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nd5cc-0007DK-9Y for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 03:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nd5cc-0004yk-5S for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 03:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Apr 2022 07:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54800 X-GNU-PR-Package: emacs Original-Received: via spool by 54800-submit@debbugs.gnu.org id=B54800.164948970119136 (code B ref 54800); Sat, 09 Apr 2022 07:35:02 +0000 Original-Received: (at 54800) by debbugs.gnu.org; 9 Apr 2022 07:35:01 +0000 Original-Received: from localhost ([127.0.0.1]:36630 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nd5cb-0004yT-41 for submit@debbugs.gnu.org; Sat, 09 Apr 2022 03:35:01 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49586) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nd5cZ-0004xK-6a for 54800@debbugs.gnu.org; Sat, 09 Apr 2022 03:34:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nd5cT-0007Cm-Ho; Sat, 09 Apr 2022 03:34:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BVwnWGG5DK2t7mOMfjmtKo4GWhdgoPxNkXEpo2SYUiQ=; b=aR3ePekHJEWP 5PSvfviKSxyM6HR6N+doCg0ZwpLjOfNpoq0CNt3W1m5SK4z4Q3EM8h71BBNyVZG8EtWGYAdwXyOCx JL/fq4VAuNbvDXAhSJ15chAn8joGfVWwlj+NtUGgyt9puFtxWXSrUoom8byqN472XDcm1iSp+jy9U CXbYacnCZ0Jjf4reXbx3OtQX5rbysdMBSbEBYy/pyTC+40eS/jiAFZWIk4DJ5HI0CQbYlASWG2PCJ HySYTfo06SDoZV/tFcBehg3lY0IilnsvPp/F+CKfSvz7a5PB2WKLWJGt7tftUVMkBhpBvwyUpX7xh D7Imj8EPHDaqHEwoG5Yxcw==; Original-Received: from [87.69.77.57] (port=3101 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nd5cR-0005Hb-0Z; Sat, 09 Apr 2022 03:34:53 -0400 In-Reply-To: <4a0319d6-b533-b3d8-bf52-bb18d74757e1@web.de> (message from Christoph Arenz on Fri, 8 Apr 2022 21:44:38 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229600 Archived-At: > Date: Fri, 8 Apr 2022 21:44:38 +0200 > From: Christoph Arenz > > When the content of the calc stack inclusive top-of-stack symbol `.' > gets larger in height than the calc window, the cursor is positioned at > a weird position in the upper half of the stack window. When > line-numbering is on, the cursor is positioned at the beginning of the > line at the line number. Calling `calc-realign' does not change the > cursor postion. > > How to reproduce: > 1. emacs -Q > 2. C-x * * (to start calc) > 3. enter a number and RET > 4. repeat No. 3 until the stacks grows and the symptom appears > > Expected behavior for the cursor is to be placed on the `.' symbol, > representing the top of the stack. > > 5. After pressing `o' [calc-realign], the expected behavior would also > be for the cursor to be positioned at the top of the calc stack. > > Debugging the function calc-align-stack-window with edebug, the symptom > goes away when placing a breakpoint at the line > (calc-cursor-stack-index 0) just after the set-window-start call, and > then continuing from there. > > The following patch fixes the problem for me, but I do not fully > understand the NOFORCE option of the set-window-start function. Thanks, but I think using NOFORCE is not the best solution here, because that causes Emacs to recenter the stack window, thus showing fewer stack entries than possible. I think the bug is actually off-by-one error, because the vertical-motion call doesn't take the header-line into account. So I suggest the following patch instead, please see if it solves the problem: diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 81677d7..900940d 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -1815,8 +1815,8 @@ calc-align-stack-window (if win (progn (calc-cursor-stack-index 0) - (vertical-motion (- 2 (window-height win))) - (set-window-start win (point))))) + (vertical-motion (- 3 (window-height win))) + (set-window-start win (point) 'noforce)))) (calc-cursor-stack-index 0) (if (looking-at " *\\.$") (goto-char (1- (match-end 0)))))