Subject: bug#67000: closed (Re: bug#67000: 30.0.50; [PATCH] Add support for reading/writing IELM input history)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 15 Feb 2024 07:56:02 +0000

Your bug report

#67000: 30.0.50; [PATCH] Add support for reading/writing IELM input history

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

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

Subject: Re: bug#67000: 30.0.50; [PATCH] Add support for reading/writing IELM input history
From: Simen Heggestøyl <[email-masked]>
To: Stefan Kangas <[email-masked]>
Cc: [email-masked], Eli Zaretskii <[email-masked]>
Date: Thu, 15 Feb 2024 08:53:00 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Stefan Kangas <[email-masked]> writes:

> LGTM, please install.

Done! Thanks again for reviewing.

>>>> +(defcustom ielm-history-file-name
>>>> +  (locate-user-emacs-file "ielm-history.eld")
>>>> +  "If non-nil, name of the file to read/write IELM input history."
>>>> +  :type '(choice (const :tag "nil" nil)
>>>
>>> The tag here should be "Disable input history" or something like that.
>>
>> Ok. Should it be updated for `comint-input-ring-file-name' too then (I
>> copied it from there)?
>
> Yes, that could be improved too.

Done.

>> From fe91c4f3aaefc109135c48ba26f8f21e87db465e Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <[email-masked]>
>> Date: Tue, 16 Jan 2024 08:21:41 +0100
>> Subject: [PATCH] Add support for reading/writing IELM input history
>>
>> * lisp/ielm.el (inferior-emacs-lisp-mode): Add support for
>> reading/writing input history.
>
> How about:
>
>     "Add support for saving input history to a file"

Changed.

>> (ielm--history-file-name): Name of the file to read/write IELM input
>> history.
>
> Maybe:
>
>     "New variable indicating IELM input history file.

Changed.

>> +(defcustom ielm-history-file-name
>> +  (locate-user-emacs-file "ielm-history.eld")
>> +  "If non-nil, name of the file to read/write IELM input history."
>> +  :type '(choice (const :tag "Disable input history" nil)
>> +                 file)
>> +  :version "30.1")
>
> Maybe `file' should have a tag too?

The label in the Custom menu says "File", which seems fine to me? Though
I never use Custom, so I'm not sure what's customary here. I installed
the above without changes, but please feel free to change it.

-- Simen

Subject: 30.0.50; [PATCH] Add support for reading/writing IELM input history
From: Simen Heggestøyl <[email-masked]>
To: [email-masked]
Date: Wed, 08 Nov 2023 16:11:25 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Attached is a proposed patch that adds input history read/write
capabilities to IELM.

>From 190a88ae55bb4a47de64cb50f2706798a100704b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <[email-masked]>
Date: Wed, 8 Nov 2023 16:08:08 +0100
Subject: [PATCH] Add support for reading/writing IELM input history

* lisp/ielm.el (inferior-emacs-lisp-mode): Add support for
reading/writing input history.
(ielm--history-file-name): Name of the file to read/write IELM input
history.
---
 lisp/ielm.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lisp/ielm.el b/lisp/ielm.el
index e51c46054b4..618cd033055 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -152,6 +152,10 @@ ielm-header
 \\[describe-mode] for help.\n"
   "Message to display when IELM is started.")
 
+(defvar ielm--history-file-name
+  (locate-user-emacs-file "ielm-history.el")
+  "Name of the file to read/write IELM input history.")
+
 (defvaralias 'inferior-emacs-lisp-mode-map 'ielm-map)
 (defvar-keymap ielm-map
   :doc "Keymap for IELM mode."
@@ -605,6 +609,11 @@ inferior-emacs-lisp-mode
             #'ielm-indirect-setup-hook 'append t)
   (setq comint-indirect-setup-function #'emacs-lisp-mode)
 
+  ;; Input history
+  (setq-local comint-input-ring-file-name ielm--history-file-name)
+  (setq-local kill-buffer-hook #'comint-write-input-ring)
+  (comint-read-input-ring t)
+
   ;; A dummy process to keep comint happy. It will never get any input
   (unless (comint-check-proc (current-buffer))
     ;; Was cat, but on non-Unix platforms that might not exist, so
@@ -631,6 +640,9 @@ inferior-emacs-lisp-mode
     (set-marker comint-last-input-start (ielm-pm))
     (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter)))
 
+(unless noninteractive
+  (add-hook 'kill-emacs-hook #'comint-write-input-ring))
+
 (defun ielm-get-old-input nil
   ;; Return the previous input surrounding point
   (save-excursion
-- 
2.39.2

-- Simen