about summary refs log tree commit diff stats
path: root/.emacs.d/lisp
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2023-05-17 12:47:40 +0100
committerDavid Morgan <djm_uk@protonmail.com>2023-05-17 12:47:40 +0100
commit05afb02a1a47b8c008d785f595143b4c1ae00dee (patch)
tree027f628959ff832fd92f66fef17ceae7181175f1 /.emacs.d/lisp
parent1e46e31b957711d73716a23387a06eff90de1cd5 (diff)
downloaddotfiles-05afb02a1a47b8c008d785f595143b4c1ae00dee.tar.gz
Read and write ielm history
Diffstat (limited to '.emacs.d/lisp')
-rw-r--r--.emacs.d/lisp/init-emacs-lisp.el15
1 files changed, 14 insertions, 1 deletions
diff --git a/.emacs.d/lisp/init-emacs-lisp.el b/.emacs.d/lisp/init-emacs-lisp.el
index 40c1820..3def7f2 100644
--- a/.emacs.d/lisp/init-emacs-lisp.el
+++ b/.emacs.d/lisp/init-emacs-lisp.el
@@ -34,10 +34,23 @@
 Start `ielm' if it's not already running."
     (interactive)
     (crux-start-or-switch-to 'ielm "*ielm*"))
+  ;; from https://www.n16f.net/blog/making-ielm-more-comfortable/
+  (defun ielm-init-history ()
+    (let ((path (expand-file-name "ielm/history" user-emacs-directory)))
+      (make-directory (file-name-directory path) t)
+      (setq-local comint-input-ring-file-name path))
+    (setq-local comint-input-ring-size 10000)
+    (setq-local comint-input-ignoredups t)
+    (comint-read-input-ring))
+  (defun ielm-write-history (&rest _args)
+    (with-file-modes #o600
+      (comint-write-input-ring)))
   :hook
   (ielm-mode . (lambda ()
                  (eldoc-mode +1)
-                 (rainbow-delimiters-mode +1)))
+                 (rainbow-delimiters-mode +1)
+                 (ielm-init-history)
+                 (advice-add 'ielm-send-input :after 'ielm-write-history)))
   (emacs-lisp-mode . (lambda ()
                        (eldoc-mode +1)
                        (rainbow-mode +1)