From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Madhu Newsgroups: gmane.emacs.devel Subject: Re: ielm automatic saving of history -- bug 67000 Date: Thu, 17 Oct 2024 07:34:04 +0530 (IST) Message-ID: <20241017.073404.1864437790200780338.enometh@meer.net> References: <86v7xwtu3i.fsf@gnu.org> <877ca8vv59.fsf@runbox.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Oct_17_07_34_04_2024_519)--" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38203"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org, emacs-devel@gnu.org To: simenheg@runbox.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 17 04:05:07 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t1Fsx-0009lR-7R for ged-emacs-devel@m.gmane-mx.org; Thu, 17 Oct 2024 04:05:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1Fs8-0007Mc-2A; Wed, 16 Oct 2024 22:04:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1Fs6-0007M9-DN for emacs-devel@gnu.org; Wed, 16 Oct 2024 22:04:14 -0400 Original-Received: from smtp7.ctinetworks.com ([205.166.61.237]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1Fs4-00055h-Mw; Wed, 16 Oct 2024 22:04:14 -0400 X-ctinetworks-Watermark: 1729994650.08436@X6m3dI5GHENxT+euJ8vQng X-ctinetworks-Envelope-From: enometh@meer.net X-ctinetworks-VirusCheck: Found to be clean X-ctinetworks-Message-ID: 55610E9B6.A79D4 Original-Received: from localhost (unknown [117.254.37.188]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: enometh@meer.net) by smtp7.ctinetworks.com (Postfix) with ESMTPSA id 55610E9B6; Wed, 16 Oct 2024 22:04:08 -0400 (EDT) In-Reply-To: <877ca8vv59.fsf@runbox.com> X-Mailer: Mew version 6.9 on Emacs 31.0.50 Received-SPF: pass client-ip=205.166.61.237; envelope-from=enometh@meer.net; helo=smtp7.ctinetworks.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:324614 Archived-At: ----Next_Part(Thu_Oct_17_07_34_04_2024_519)-- Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable * Simen Heggest=F8yl <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 f= ind > 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 ----Next_Part(Thu_Oct_17_07_34_04_2024_519)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-fix-some-ielm-history-issues.patch" >From fe78a75cc3d322b3b8f2df24d50dca1b1216d894 Mon Sep 17 00:00:00 2001 From: Madhu 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 ----Next_Part(Thu_Oct_17_07_34_04_2024_519)----