about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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)