Subject: bug#54800: closed (Re: bug#54800: 28.1; calc: Cursor positioned at weird position in calc stack)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 09 Apr 2022 13:33:02 +0000

Your bug report

#54800: 28.1; calc: Cursor positioned at weird position in calc stack

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
54800: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=54800
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#54800: 28.1; calc: Cursor positioned at weird position in calc stack
From: Eli Zaretskii <[email-masked]>
To: Christoph Arenz <[email-masked]>
Cc: [email-masked]
Date: Sat, 09 Apr 2022 16:32:15 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sat, 9 Apr 2022 14:31:06 +0200
> Cc: [email-masked]
> From: Christoph Arenz <[email-masked]>
> 
> > 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:
> 
> Your patch solves the problem and shows maximum content of the stack
> in the window.

Thanks, I installed the fix on the emacs-28 branch.

> Note that it still contains the NOFORCE while the off-by-one fix also
> works without it.

Right, I removed it before committing.  Thanks for pointing that out.

And with that, I'm closing this bug report.

Subject: 28.1; calc: Cursor positioned at weird position in calc stack
From: Christoph Arenz <[email-masked]>
To: [email-masked]
Date: Fri, 8 Apr 2022 21:44:38 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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, Christoph

1 file changed, 1 insertion(+), 1 deletion(-)
lisp/calc/calc.el | 2 +-

modified   lisp/calc/calc.el
@@ -1816,7 +1816,7 @@ calc-align-stack-window
            (progn
          (calc-cursor-stack-index 0)
          (vertical-motion (- 2 (window-height win)))
-        (set-window-start win (point)))))
+        (set-window-start win (point) 'noforce))))
      (calc-cursor-stack-index 0)
      (if (looking-at " *\\.$")
          (goto-char (1- (match-end 0)))))

In GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30,
cairo version 1.15.10)
of 2022-04-05 built on M92p
Repository revision: 5a223c7f2ef4c31abbd46367b6ea83cd19d30aa7
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.6 LTS

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
GTK3 ZLIB

Important settings:
value of $LC_MONETARY: de_DE.UTF-8
value of $LC_NUMERIC: de_DE.UTF-8
value of $LC_TIME: de_DE.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix