haskell-mode icon indicating copy to clipboard operation
haskell-mode copied to clipboard

Add persistent history to haskell-interactive-mode

Open rpglover64 opened this issue 10 years ago • 2 comments

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

rpglover64 avatar May 21 '15 20:05 rpglover64

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 avatar May 04 '23 17:05 ParetoOptimalDev

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.

ParetoOptimalDev avatar May 04 '23 17:05 ParetoOptimalDev