haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.33k stars 344 forks source link

Add persistent history to haskell-interactive-mode #661

Open rpglover64 opened 9 years ago

rpglover64 commented 9 years ago

It would be useful to have history which persisted after an emacs restart.

ParetoOptimalDev commented 1 year ago

I came to add this issue now, but first searched and found it exists.

I believe inf-haskell.el is used for haskell-interactive-mode and it uses comint. Maybe this was never added because "it's just comint" so you "just" need to connect a few things?

I think this will work but I haven't tested:

(defun turn-on-comint-history (history-file)
          (setq comint-input-ring-file-name history-file)
          (comint-read-input-ring 'silent))

(add-hook 'inf-haskell-mode-hook
          (lambda ()
            (turn-on-comint-history ".ghci")))
(add-hook 'kill-buffer-hook #'comint-write-input-ring)
(add-hook 'kill-emacs-hook
          (lambda ()
            (--each (buffer-list)
              (with-current-buffer it (comint-write-input-ring)))))

Customized from https://emacs.stackexchange.com/questions/9925/persistent-shell-command-historyi

Here are some examples of people using comint-input-ring-file-name in the wild if that doesn't work or you want to find other cool related things.

ParetoOptimalDev commented 1 year ago

It would be nice however if this were project specific history imo. One could probably modify the file-name to take project into account to accomplish this pretty easily though.