From c41b624c46a28d4ab326f2f55acfb90657f3b48c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 1 Mar 2025 10:27:17 +0200 Subject: [PATCH] Save IELM input history on "C-c C-c" * lisp/ielm.el (ielm--write-history-on-interrupt): New function. (inferior-emacs-lisp-mode): Install it as buffer-local value of the 'interrupt-process-functions' hook. (Bug#76585) * etc/NEWS: Announce the behavior change. (cherry picked from commit cabbb36ae1d089e34c501c54a682ea7121899565) --- lisp/ielm.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/ielm.el b/lisp/ielm.el index b3cd02b4dc0..43529f36cd6 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -521,6 +521,12 @@ behavior of the indirect buffer." (with-current-buffer buf (comint-write-input-ring)))) +(defun ielm--write-history-on-interrupt (_proc _group) + "Save the IELM input history when the process is interrupted." + (funcall (ielm--input-history-writer (current-buffer))) + ;; Let the rest of the hook functions run as well. + nil) + ;;; Major mode (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM" @@ -658,7 +664,10 @@ Customized bindings may be defined in `ielm-map', which currently contains: '(rear-nonsticky t field output inhibit-line-move-field-capture t)))) (comint-output-filter (ielm-process) ielm-prompt-internal) (set-marker comint-last-input-start (ielm-pm)) - (set-process-filter (get-buffer-process (current-buffer)) 'comint-output-filter))) + (set-process-filter (get-buffer-process (current-buffer)) + 'comint-output-filter) + (add-hook 'interrupt-process-functions + #'ielm--write-history-on-interrupt -1 t))) (defun ielm-get-old-input nil ;; Return the previous input surrounding point -- 2.39.5