Stefan Kangas writes: > 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. Thanks, makes sense. Updated in the attached patch! >> (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)) >> + > > 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? Usually comint-derived modes use a process sentinel to listen to some external process and call `comint-write-input-ring' when the process exists, which works both the buffer is killed or Emacs itself is quit. For IELM there is no such process to listen to, so I hook into `kill-buffer-hook' and `kill-emacs-hook' to achieve the same things.