unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Madhu <enometh@meer.net>
To: simenheg@runbox.com
Cc: eliz@gnu.org, emacs-devel@gnu.org
Subject: Re: ielm automatic saving of history -- bug 67000
Date: Thu, 17 Oct 2024 07:34:04 +0530 (IST)	[thread overview]
Message-ID: <20241017.073404.1864437790200780338.enometh@meer.net> (raw)
In-Reply-To: <877ca8vv59.fsf@runbox.com>

[-- Attachment #1: Type: Text/Plain, Size: 982 bytes --]

*  Simen Heggestøyl <simenheg@runbox.com> <877ca8vv59.fsf@runbox.com>
Wrote on Wed, 16 Oct 2024 19:02:10 +0200
> I don't have time to devote to this issue on the short term (that is,
> before the release of Emacs 30.1). However I see that the discussion has
> carried on since you sent me this question. It would be good if you find
> a way to improve it enough in time to ship with Emacs 30.1, otherwise
> reverting my commit is also fine, and I may have the time to help
> improve the feature for a later release.

I am attaching a patch (not fully tested) where I tried to fix the
most important issues with the history mechanism. Perhaps Eli could
review and commit parts of as he sees fit (maybe dropping the change
to the default value). btw I don't think it is possible to stick file
local variables into the file read by comint-read-input-ring

Or alternatively maybe bug67000 should be reopened and this should be
continued there. -- Best Regards. Madhu


[-- Attachment #2: 0001-fix-some-ielm-history-issues.patch --]
[-- Type: Text/X-Patch, Size: 2950 bytes --]

From fe78a75cc3d322b3b8f2df24d50dca1b1216d894 Mon Sep 17 00:00:00 2001
From: Madhu <enometh@net.meer>
Date: Fri, 11 Oct 2024 21:16:46 +0530
Subject: [PATCH] fix some issues in the persistent ielm history mechanism
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

this fixes some issues in commit 60cff1ac9d21. (bug 67000)

* lisp/elm.el: (ielm-history-file-name): initially
nil. (inferior-emacs-lisp-mode): do not invoke the machinery at all if
ielm-history-file-name is nil. use add-hook on kill-buffer-hook instead
of replacing kill-buffer-hook. bind coding-system-for-read around call
to comint-read-input-ring.  (ielm-input-history-writer): bind
coding-system-on-write around call to comint-write-input-ring.

---
 lisp/ielm.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/lisp/ielm.el b/lisp/ielm.el
index f62db7510de..000ba48ba68 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -111,7 +111,8 @@ ielm-dynamic-multiline-inputs
   :type 'boolean)
 
 (defcustom ielm-history-file-name
-  (locate-user-emacs-file "ielm-history.eld")
+  (if t nil
+      (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)
@@ -520,7 +521,9 @@ ielm--input-history-writer
   "Return a function writing IELM input history to BUF."
   (lambda ()
     (with-current-buffer buf
-      (comint-write-input-ring))))
+      (let ((coding-system-for-write 'utf-8-emacs-unix))
+        ;; cannot add a file-local section when using comint.
+        (comint-write-input-ring)))))
 
 ;;; Major mode
 
@@ -623,17 +626,19 @@ inferior-emacs-lisp-mode
   (add-hook 'comint-indirect-setup-hook
             #'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 ielm--exit (ielm--input-history-writer (current-buffer)))
-  (setq-local kill-buffer-hook
+  (when ielm-history-file-name
+    ;; Input history
+    (setq-local comint-input-ring-file-name ielm-history-file-name)
+    (setq-local ielm--exit (ielm--input-history-writer (current-buffer)))
+    (add-hook 'kill-buffer-hook
               (lambda ()
                 (funcall ielm--exit)
-                (remove-hook 'kill-emacs-hook ielm--exit)))
-  (unless noninteractive
-    (add-hook 'kill-emacs-hook ielm--exit))
-  (comint-read-input-ring t)
+                (remove-hook 'kill-emacs-hook ielm--exit))
+              nil t)
+    (unless noninteractive
+      (add-hook 'kill-emacs-hook ielm--exit))
+    (let ((coding-system-for-read 'utf-8-unix))
+      (comint-read-input-ring t)))
 
   ;; A dummy process to keep comint happy. It will never get any input
   (unless (comint-check-proc (current-buffer))
-- 
2.46.0.27.gfa3b914457


      reply	other threads:[~2024-10-17  2:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-13  4:17 ielm automatic saving of history -- bug 67000 Madhu
2024-10-13  6:06 ` Eli Zaretskii
2024-10-13  9:49   ` Madhu
2024-10-14  6:23   ` Augusto Stoffel
2024-10-14 14:05     ` Eli Zaretskii
2024-10-15  4:46       ` Madhu
2024-10-15 12:18         ` Eli Zaretskii
2024-10-15 17:30           ` Madhu
2024-10-15 18:23             ` Eli Zaretskii
2024-10-16  4:25               ` Madhu
2024-10-16  6:04                 ` Eli Zaretskii
2024-10-16  9:03                   ` Madhu
2024-10-16 18:36                     ` Eli Zaretskii
2024-10-16 17:02   ` Simen Heggestøyl
2024-10-17  2:04     ` Madhu [this message]

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=20241017.073404.1864437790200780338.enometh@meer.net \
    --to=enometh@meer.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=simenheg@runbox.com \
    /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).