unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Christoph Arenz <tiga.arenz@web.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 54800@debbugs.gnu.org
Subject: bug#54800: 28.1; calc: Cursor positioned at weird position in calc stack
Date: Sat, 9 Apr 2022 14:31:06 +0200	[thread overview]
Message-ID: <3e3b4386-9720-60bb-1e54-fa7326191b7a@web.de> (raw)
In-Reply-To: <831qy6aewb.fsf@gnu.org>

On 09.04.22 09:34, Eli Zaretskii wrote:
>> Date: Fri, 8 Apr 2022 21:44:38 +0200
>> From: Christoph Arenz <tiga.arenz@web.de>
>>
>> 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:

Your patch solves the problem and shows maximum content of the stack
in the window.
Note that it still contains the NOFORCE while the off-by-one fix also
works without it.

> 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)))))





  reply	other threads:[~2022-04-09 12:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 19:44 bug#54800: 28.1; calc: Cursor positioned at weird position in calc stack Christoph Arenz
2022-04-09  7:34 ` Eli Zaretskii
2022-04-09 12:31   ` Christoph Arenz [this message]
2022-04-09 13:32     ` Eli Zaretskii
2022-04-11 10:25       ` Christoph Arenz
2022-04-11 11:27         ` Eli Zaretskii
2022-04-11 11:45           ` Eli Zaretskii
2022-04-11 14:53             ` Christoph Arenz
2022-04-12 15:45               ` Christoph Arenz
2022-04-12 20:44                 ` Christoph Arenz
2022-04-13 13:11                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e3b4386-9720-60bb-1e54-fa7326191b7a@web.de \
    --to=tiga.arenz@web.de \
    --cc=54800@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).