From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67000: 30.0.50; [PATCH] Add support for reading/writing IELM input history Date: Mon, 08 Jan 2024 08:30:35 +0100 Message-ID: <87y1d0p9ic.fsf@runbox.com> References: <87sf5ge0v6.fsf@runbox.com> <87a5pl1qym.fsf@runbox.com> Reply-To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11283"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67000@debbugs.gnu.org, Eli Zaretskii To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 08 08:32:36 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rMk7f-0002jL-U3 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Jan 2024 08:32:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMk75-0002H6-5m; Mon, 08 Jan 2024 02:31:59 -0500 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 1rMk72-0002Gv-NM for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 02:31:56 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rMk72-0004Qb-EP for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 02:31:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rMk77-0001Xy-Uo for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 02:32:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Jan 2024 07:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67000 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67000-submit@debbugs.gnu.org id=B67000.17046990654050 (code B ref 67000); Mon, 08 Jan 2024 07:32:01 +0000 Original-Received: (at 67000) by debbugs.gnu.org; 8 Jan 2024 07:31:05 +0000 Original-Received: from localhost ([127.0.0.1]:34875 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMk6C-00012U-CE for submit@debbugs.gnu.org; Mon, 08 Jan 2024 02:31:05 -0500 Original-Received: from mailtransmit05.runbox.com ([2a0c:5a00:149::26]:40472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMk69-0000pR-ER for 67000@debbugs.gnu.org; Mon, 08 Jan 2024 02:31:02 -0500 Original-Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1rMk5x-00A1vC-BX; Mon, 08 Jan 2024 08:30:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From; bh=Yo4AzCBoN4zS205zf1IFo/JmznbDLSsH6f41cKCmR2s=; b=IrDb4+w0daEPZ1QCmSlzWt+Rpw MpOH0IBasjFMGMHfTTpN81RwpOIKsY0VOTirfPo4Pj+NDZwq8kpireqwUTxfXj18fU167Ea8qcH5K kbeGHl4dMgHEhBt99Jizygh/xdxex/y4IjqoEbAPQSboV4rGUPd51WGUoRJRzVOnGhaUQ3Hg59hoZ N5BZirgLLQLUHFbWGJbTWOSOTeLsikkhQPMJjgT7I0q7wK5vVIxaMh6kEMWJdCOOsFOhSNozZC0VQ JIMpb4RNVIVYaCZX66U5HS0yMPl3YtkHGqIyqYpZO4aJi0M6Ku8xKA6+fpUHMpIg0VF0TZPervyJn CtOjn9Hg==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1rMk5w-0007tQ-UY; Mon, 08 Jan 2024 08:30:49 +0100 Original-Received: by submission03.runbox with esmtpsa [Authenticated ID (963757)] (TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_256_GCM:256) (Exim 4.93) id 1rMk5k-00GYVJ-Ch; Mon, 08 Jan 2024 08:30:36 +0100 In-Reply-To: (Stefan Kangas's message of "Fri, 5 Jan 2024 12:17:28 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277538 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Kangas writes: > Simen Heggest=C3=B8yl writes: > >>>> +(defvar ielm--history-file-name >>>> + (locate-user-emacs-file "ielm-history.el") >>> >>> Shouldn't that be .eld? >> >> Hm, the file will contain actual Lisp expressions, so I'd think that .el >> is fitting? > > I'm not so sure. We don't really intend for users to use it the way > you'd expect from an .el file, like byte-compiling or loading it. > > So while these are, hopefully, valid Lisp expressions (barring typos, > which frequently happens at a REPL), it's not really a file containing > meaningful code either. Okay, fair points. Updated patch attached! -- Simen --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-support-for-reading-writing-IELM-input-history.patch >From a2322770acb6bceab36224989cbbe9b777312997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= 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. --- etc/NEWS | 5 +++++ lisp/ielm.el | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index c3d777b971f..b62976143d2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1228,6 +1228,11 @@ chat buffers use by default. *** New command 'customize-dirlocals'. This command pops up a buffer to edit the settings in ".dir-locals.el". +** IELM + +--- +*** IELM now remembers input history between sessions. + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/ielm.el b/lisp/ielm.el index 777aebb70cf..6d4a11c1c28 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.eld") + "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 --=-=-=--