GNU bug report logs -
#67000
30.0.50; [PATCH] Add support for reading/writing IELM input history
Previous Next
Reported by: Simen Heggestøyl <simenheg <at> runbox.com>
Date: Wed, 8 Nov 2023 15:13:01 UTC
Severity: wishlist
Tags: patch
Found in version 30.0.50
Done: Simen Heggestøyl <simenheg <at> runbox.com>
Bug is archived. No further changes may be made.
Full log
Message #34 received at 67000 <at> debbugs.gnu.org (full text, mbox):
Simen Heggestøyl <simenheg <at> runbox.com> writes:
> Right, good catch. New attempt in the attached patch!
Thanks, please find some comments below.
> +---
> +*** IELM now remembers input history between sessions.
> +
> +---
> +*** New variable 'ielm-history-file-name'.
> +If non-nil, name of the file to read/write IELM input history. Set to
> +nil to revert IELM to the old behavior of not remembering input
> +history between sessions.
I would probably make this into one entry, like so:
*** IELM now remembers input history between sessions.
The new user option 'ielm-history-file-name' is the name of the file
where IELM input history will be saved. Customize it to nil to revert
to the old behavior of not remembering input history between sessions.
> +(defcustom ielm-history-file-name
> + (locate-user-emacs-file "ielm-history.eld")
> + "If non-nil, name of the file to read/write IELM input history."
> + :type '(choice (const :tag "nil" nil)
The tag here should be "Disable input history" or something like that.
> + file)
> + :version "30.1")
> +
> (defvaralias 'inferior-emacs-lisp-mode-hook 'ielm-mode-hook)
> (defcustom ielm-mode-hook nil
> "Hooks to be run when IELM (`inferior-emacs-lisp-mode') is started."
> @@ -503,6 +510,17 @@ ielm--expand-ellipsis
> (funcall pp-default-function beg end)
> end))
>
> +;;; Input history
> +
> +(defvar ielm--exit
This should read
(defvar ielm--exit nil
or the below docstring will instead be its value.
> + "Function to call when Emacs is killed.")
> +
> +(defun ielm--input-history-writer (buf)
> + "Return a function writing IELM input history to BUF."
> + (lambda ()
> + (with-current-buffer buf
> + (comint-write-input-ring))))
> +
> ;;; Major mode
>
> (define-derived-mode inferior-emacs-lisp-mode comint-mode "IELM"
> @@ -605,6 +623,17 @@ 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 ielm--exit (ielm--input-history-writer (current-buffer)))
> + (setq-local 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)
There are some complications here:
You can get more than one IELM buffer using
M-x ielm RET
M-x rename-buffer RET foo RET
M-x ielm RET
What happens if there is more than one IELM buffer? It will save only
the history from the last one, or something like that?
Perhaps the kill-emacs-hook should look for all buffers that are using
`ielm-mode' and save the history from all of them?
> +
> ;; 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
> --
> 2.39.2
>
>
> -- Simen
This bug report was last modified 1 year and 181 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.