From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#67000: 30.0.50; [PATCH] Add support for reading/writing IELM input history Date: Mon, 8 Jan 2024 11:51:39 -0800 Message-ID: References: <87sf5ge0v6.fsf@runbox.com> <87a5pl1qym.fsf@runbox.com> <87y1d0p9ic.fsf@runbox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22319"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67000@debbugs.gnu.org, Eli Zaretskii To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 08 20:52:19 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 1rMvfX-0005Wm-9G for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Jan 2024 20:52:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rMvfA-0001zq-SO; Mon, 08 Jan 2024 14:51:56 -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 1rMvfA-0001zi-7i for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 14:51: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 1rMvf9-0006IG-VU for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 14:51:55 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rMvfG-0006LC-8U for bug-gnu-emacs@gnu.org; Mon, 08 Jan 2024 14:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Jan 2024 19:52:02 +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.170474351524360 (code B ref 67000); Mon, 08 Jan 2024 19:52:02 +0000 Original-Received: (at 67000) by debbugs.gnu.org; 8 Jan 2024 19:51:55 +0000 Original-Received: from localhost ([127.0.0.1]:37661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMvf8-0006Kp-RV for submit@debbugs.gnu.org; Mon, 08 Jan 2024 14:51:55 -0500 Original-Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:44082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rMvf7-0006Kc-AU for 67000@debbugs.gnu.org; Mon, 08 Jan 2024 14:51:54 -0500 Original-Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2cd0f4797aaso23534191fa.0 for <67000@debbugs.gnu.org>; Mon, 08 Jan 2024 11:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704743501; x=1705348301; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=/buqsVkuX87v+hbzr0NrI/s574kCG5JWExYyaYwyCN8=; b=Q3/q3jDFT0ErWWANAJqM+jpCzPN2Vupb6k5SSOz5zTXuWVQSHOH5gbW1Sdzfl56Ay+ QneY+SB2A7eTOEZl8k7dx5ThsACuNND9vukqDGSLbu/JHz/JNxUl5pszokWX9b0vmwjZ hX8HOCV+PZwCTNI+4t6JQQxVsWrtQw7YNoZNAW1L4GZ9ZIB3rDnXGgjSsnDv+NP8YogY QHfk5kwXSt3CspzZalyuU4ucj0IM/s9m057wyKH2CXb6PoHTljsDsig1qxxgx20hPpFF JJo/59FIU8gIjZwt/JJh+8agmR8Jf9uLZAFyYsn5vZCZHGI7M6r7wtiCpRmndveNFX8l AZVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704743501; x=1705348301; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=/buqsVkuX87v+hbzr0NrI/s574kCG5JWExYyaYwyCN8=; b=cag6gmrkbNadt28TpTwsnIW4isRLoH+TGk47N+hVvMkhkVG58z/pNE5KVI96WHY9lk 8oKEJpOnPWcYeLsICRGERwfC6omoLsDghwkfGyisIw4NRGCG//GKHJ1udszWO53ZlwIP MWadCfbf1TB9CVhbh3sPdInKrk2Y8DpdcO7uR7+x+rKDiP0sAysml97B70XMSntFpxek V5O+cyRgRopDwPwyLyaZLzygeJl890ARhvc1V71fFQi59QZTCfxTvUSuHQykYPgDYPVi FFYDClSAzk3/TdTtO3HHeyp5wnA/CkreAd5eaOC2HCi28wNzsZxHmMrPQYR4J1mZQup6 xhZQ== X-Gm-Message-State: AOJu0Yy4wXQGdPED5F22elFKKM9oujCrpK3nmikgQg7MKJrOur0TqPCD epEwroPF4htRWpJyT9zr9ta1FrM3tJ/iuq9gPzE= X-Google-Smtp-Source: AGHT+IGQ9lFPj2Ry9hrAdt3Srq6QbH+YAyV8FfVTQkFCmWBSCMT+CIkwnCQJohfqmcniSLtjybQI19nTcMNFNVk94zY= X-Received: by 2002:a2e:be08:0:b0:2cd:5519:35e2 with SMTP id z8-20020a2ebe08000000b002cd551935e2mr1004692ljq.5.1704743500744; Mon, 08 Jan 2024 11:51:40 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 8 Jan 2024 11:51:39 -0800 In-Reply-To: <87y1d0p9ic.fsf@runbox.com> 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:277575 Archived-At: Simen Heggest=C3=B8yl writes: > From a2322770acb6bceab36224989cbbe9b777312997 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D > 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. > + > =0C > * 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.") On closer thought, I think this should be a defcustom. See `lua-ts-inferior-history' and `sql-input-ring-file-name' for example. I also think nil might as well be a valid value which disables history altogether (maybe users don't want that for some reason, let's say privacy or whatever). And the defcustom should be mentioned in NEWS, too. > (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-ou= tput-filter))) > > +(unless noninteractive > + (add-hook 'kill-emacs-hook #'comint-write-input-ring)) > + I'm not so sure about this part. If this is correct, why should it be defined here, and not, say, in comint.el? It seems like a separate, unrelated change. What am I missing? > (defun ielm-get-old-input nil > ;; Return the previous input surrounding point > (save-excursion > -- > 2.39.2