GNU bug report logs - #76585
ielm clobbers history on C-c C-c, C-d

Previous Next

Package: emacs;

Reported by: Daniel Colascione <dancol <at> dancol.org>

Date: Wed, 26 Feb 2025 12:46:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76585 in the body.
You can then email your comments to 76585 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#76585; Package emacs. (Wed, 26 Feb 2025 12:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Daniel Colascione <dancol <at> dancol.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 26 Feb 2025 12:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: bug-gnu-emacs <at> gnu.org
Subject: ielm clobbers history on C-c C-c, C-d
Date: Wed, 26 Feb 2025 07:44:54 -0500
When the ielm inferior dummy process exits, we don't save its history:
when we next start ielm, we reload its history from the save file,
losing any entries between last history save and the present.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76585; Package emacs. (Wed, 26 Feb 2025 15:59:01 GMT) Full text and rfc822 format available.

Message #8 received at 76585 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: 76585 <at> debbugs.gnu.org
Subject: Re: bug#76585: ielm clobbers history on C-c C-c, C-d
Date: Wed, 26 Feb 2025 17:58:25 +0200
> From: Daniel Colascione <dancol <at> dancol.org>
> Date: Wed, 26 Feb 2025 07:44:54 -0500
> 
> When the ielm inferior dummy process exits, we don't save its history:
> when we next start ielm, we reload its history from the save file,
> losing any entries between last history save and the present.

I don't use IELM too often, so apologies if what I ask below makes no
sense or is silly: you are saying that ielm--input-history-writer is
not called when the dummy process exits, is that right?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76585; Package emacs. (Thu, 27 Feb 2025 00:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 76585 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76585 <at> debbugs.gnu.org
Subject: Re: bug#76585: ielm clobbers history on C-c C-c, C-d
Date: Wed, 26 Feb 2025 19:09:16 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Daniel Colascione <dancol <at> dancol.org>
>> Date: Wed, 26 Feb 2025 07:44:54 -0500
>> 
>> When the ielm inferior dummy process exits, we don't save its history:
>> when we next start ielm, we reload its history from the save file,
>> losing any entries between last history save and the present.
>
> I don't use IELM too often,

Is there something better?

> so apologies if what I ask below makes no
> sense or is silly: you are saying that ielm--input-history-writer is
> not called when the dummy process exits, is that right?

When I start Emacs, if I type M-x ielm, then M-p through history, I
might observe (most recent first) history entries C, B, and A, with the
three entries coming from the ielm history file. If I type additional
ielm commands D and E, then at the next prompt after E, if I hit M-p, I
see E, and if I hit M-p again, I get D, then C, and so on. If I hit C-c
C-c, killing the ielm subprocess, then M-x ielm again, then press M-p, I
see C, B, A --- as if my D, E session had never happened.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76585; Package emacs. (Thu, 27 Feb 2025 14:14:02 GMT) Full text and rfc822 format available.

Message #14 received at 76585 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: 76585 <at> debbugs.gnu.org
Subject: Re: bug#76585: ielm clobbers history on C-c C-c, C-d
Date: Thu, 27 Feb 2025 16:13:35 +0200
> From: Daniel Colascione <dancol <at> dancol.org>
> Cc: 76585 <at> debbugs.gnu.org
> Date: Wed, 26 Feb 2025 19:09:16 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > I don't use IELM too often,
> 
> Is there something better?

Not necessarily better, but simpler: "M-:".

> When I start Emacs, if I type M-x ielm, then M-p through history, I
> might observe (most recent first) history entries C, B, and A, with the
> three entries coming from the ielm history file. If I type additional
> ielm commands D and E, then at the next prompt after E, if I hit M-p, I
> see E, and if I hit M-p again, I get D, then C, and so on. If I hit C-c
> C-c, killing the ielm subprocess, then M-x ielm again, then press M-p, I
> see C, B, A --- as if my D, E session had never happened.

Thanks.  Does the below give good results?

diff --git a/lisp/ielm.el b/lisp/ielm.el
index b3cd02b..c651612 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -521,6 +521,12 @@ ielm--input-history-writer
     (with-current-buffer buf
       (comint-write-input-ring))))
 
+(defun ielm--write-history-on-interrupt (_proc _group)
+  "Save the IELM input history when the process is interrupted."
+  (funcall (ielm--input-history-writer (current-buffer)))
+  ;; Let the rest of the hook functions run as well.
+  nil)
+
 ;;; Major mode
 
 (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM"
@@ -658,7 +664,9 @@ inferior-emacs-lisp-mode
          '(rear-nonsticky t field output inhibit-line-move-field-capture t))))
     (comint-output-filter (ielm-process) ielm-prompt-internal)
     (set-marker comint-last-input-start (ielm-pm))
-    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)))
+    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)
+    (add-hook 'interrupt-process-functions
+              #'ielm--write-history-on-interrupt -1 t)))
 
 (defun ielm-get-old-input nil
   ;; Return the previous input surrounding point




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#76585; Package emacs. (Fri, 28 Feb 2025 21:28:02 GMT) Full text and rfc822 format available.

Message #17 received at 76585 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76585 <at> debbugs.gnu.org
Subject: Re: bug#76585: ielm clobbers history on C-c C-c, C-d
Date: Fri, 28 Feb 2025 16:27:04 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Daniel Colascione <dancol <at> dancol.org>
>> Cc: 76585 <at> debbugs.gnu.org
>> Date: Wed, 26 Feb 2025 19:09:16 -0500
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > I don't use IELM too often,
>> 
>> Is there something better?
>
> Not necessarily better, but simpler: "M-:".
>
>> When I start Emacs, if I type M-x ielm, then M-p through history, I
>> might observe (most recent first) history entries C, B, and A, with the
>> three entries coming from the ielm history file. If I type additional
>> ielm commands D and E, then at the next prompt after E, if I hit M-p, I
>> see E, and if I hit M-p again, I get D, then C, and so on. If I hit C-c
>> C-c, killing the ielm subprocess, then M-x ielm again, then press M-p, I
>> see C, B, A --- as if my D, E session had never happened.
>
> Thanks.  Does the below give good results?
>
> diff --git a/lisp/ielm.el b/lisp/ielm.el
> index b3cd02b..c651612 100644
> --- a/lisp/ielm.el
> +++ b/lisp/ielm.el
> @@ -521,6 +521,12 @@ ielm--input-history-writer
>      (with-current-buffer buf
>        (comint-write-input-ring))))
>  
> +(defun ielm--write-history-on-interrupt (_proc _group)
> +  "Save the IELM input history when the process is interrupted."
> +  (funcall (ielm--input-history-writer (current-buffer)))
> +  ;; Let the rest of the hook functions run as well.
> +  nil)
> +
>  ;;; Major mode
>  
>  (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM"
> @@ -658,7 +664,9 @@ inferior-emacs-lisp-mode
>           '(rear-nonsticky t field output inhibit-line-move-field-capture t))))
>      (comint-output-filter (ielm-process) ielm-prompt-internal)
>      (set-marker comint-last-input-start (ielm-pm))
> -    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)))
> +    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)
> +    (add-hook 'interrupt-process-functions
> +              #'ielm--write-history-on-interrupt -1 t)))
>  
>  (defun ielm-get-old-input nil
>    ;; Return the previous input surrounding point

This works. Thanks




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 01 Mar 2025 08:29:02 GMT) Full text and rfc822 format available.

Notification sent to Daniel Colascione <dancol <at> dancol.org>:
bug acknowledged by developer. (Sat, 01 Mar 2025 08:29:03 GMT) Full text and rfc822 format available.

Message #22 received at 76585-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: 76585-done <at> debbugs.gnu.org
Subject: Re: bug#76585: ielm clobbers history on C-c C-c, C-d
Date: Sat, 01 Mar 2025 10:28:43 +0200
> From: Daniel Colascione <dancol <at> dancol.org>
> Cc: 76585 <at> debbugs.gnu.org
> Date: Fri, 28 Feb 2025 16:27:04 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Thanks.  Does the below give good results?
> >
> > diff --git a/lisp/ielm.el b/lisp/ielm.el
> > index b3cd02b..c651612 100644
> > --- a/lisp/ielm.el
> > +++ b/lisp/ielm.el
> > @@ -521,6 +521,12 @@ ielm--input-history-writer
> >      (with-current-buffer buf
> >        (comint-write-input-ring))))
> >  
> > +(defun ielm--write-history-on-interrupt (_proc _group)
> > +  "Save the IELM input history when the process is interrupted."
> > +  (funcall (ielm--input-history-writer (current-buffer)))
> > +  ;; Let the rest of the hook functions run as well.
> > +  nil)
> > +
> >  ;;; Major mode
> >  
> >  (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM"
> > @@ -658,7 +664,9 @@ inferior-emacs-lisp-mode
> >           '(rear-nonsticky t field output inhibit-line-move-field-capture t))))
> >      (comint-output-filter (ielm-process) ielm-prompt-internal)
> >      (set-marker comint-last-input-start (ielm-pm))
> > -    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)))
> > +    (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)
> > +    (add-hook 'interrupt-process-functions
> > +              #'ielm--write-history-on-interrupt -1 t)))
> >  
> >  (defun ielm-get-old-input nil
> >    ;; Return the previous input surrounding point
> 
> This works. Thanks

Thanks, installed on the master branch, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Mar 2025 11:24:45 GMT) Full text and rfc822 format available.

This bug report was last modified 81 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.