Subject: bug#77816: closed (Re: bug#77816: [PATCH] Fix deleting the first line of calc-trail-mode)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 15 Apr 2025 08:59:02 +0000

Your bug report

#77816: [PATCH] Fix deleting the first line of calc-trail-mode

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].

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

Subject: Re: bug#77816: [PATCH] Fix deleting the first line of calc-trail-mode
From: Eli Zaretskii <[email-masked]>
To: Wojciech Siewierski <[email-masked]>
Cc: [email-masked]
Date: Tue, 15 Apr 2025 11:58:19 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Wojciech Siewierski <[email-masked]>
> Date: Mon, 14 Apr 2025 19:20:37 +0200
> 
> As of GNU Emacs 30.1 it's not possible to delete the first line of the
> calc trail visible after invoking the Emacs calculator.
> 
> To reproduce:
> 
> 1. Start Emacs calc: C-x * c
> 2. Enter a few numbers: 10 RET 20 RET 30 RET
> 3. Try deleting the trail lines, repeat for each line: t k
> 
> Expected behavior: all the trail lines are being deleted.
> 
> Actual behavior: the first line is still left, no error is reported.
> 
> This bug was introduced in commit
> 8e1376a39125c3ffc0484077b502444d853eca79, included since Emacs 28.1.
> Before that commit, calc trail used its first line as a header, which
> wasn't meant to be deleted.  After migrating to using header-line, the
> code preserving the first line was kept intact, still preventing the
> removal of the first line even though it's no longer special.
> 
> I'm attaching a patch fixing this behavior.

Thanks, I've now installed this on the emacs-30 release branch, and
I'm closing this bug.

Subject: [PATCH] Fix deleting the first line of calc-trail-mode
From: Wojciech Siewierski <[email-masked]>
To: [email-masked]
Date: Mon, 14 Apr 2025 19:20:37 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

As of GNU Emacs 30.1 it's not possible to delete the first line of the
calc trail visible after invoking the Emacs calculator.

To reproduce:

1. Start Emacs calc: C-x * c
2. Enter a few numbers: 10 RET 20 RET 30 RET
3. Try deleting the trail lines, repeat for each line: t k

Expected behavior: all the trail lines are being deleted.

Actual behavior: the first line is still left, no error is reported.

This bug was introduced in commit
8e1376a39125c3ffc0484077b502444d853eca79, included since Emacs 28.1.
Before that commit, calc trail used its first line as a header, which
wasn't meant to be deleted.  After migrating to using header-line, the
code preserving the first line was kept intact, still preventing the
removal of the first line even though it's no longer special.

I'm attaching a patch fixing this behavior.

Best regards
-- 
Wojciech Siewierski
>From d3bf63bf78073ed908785d0f1cd2f0095b4338c6 Mon Sep 17 00:00:00 2001
From: Wojciech Siewierski <[email-masked]>
Date: Mon, 14 Apr 2025 18:57:28 +0200
Subject: [PATCH] Fix deleting the first line of calc-trail-mode

* lisp/calc/calc-trail.el (calc-trail-kill): Remove the check preventing
the removal of the first trail line which is no longer relevant since
commit 8e1376a3912.
---
 lisp/calc/calc-trail.el | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/lisp/calc/calc-trail.el b/lisp/calc/calc-trail.el
index f134a7b16b9..433d3983b12 100644
--- a/lisp/calc/calc-trail.el
+++ b/lisp/calc/calc-trail.el
@@ -167,14 +167,7 @@
   (interactive "p")
   (calc-with-trail-buffer
    (let ((buffer-read-only nil))
-     (save-restriction
-       (narrow-to-region   ; don't delete "Emacs Trail" header
-	(save-excursion
-	  (goto-char (point-min))
-	  (forward-line 1)
-	  (point))
-	(point-max))
-       (kill-line n)))
+     (kill-line n))
    (calc-trail-here)))
 
 (provide 'calc-trail)
-- 
2.49.0