Closed mars0i closed 2 years ago
@mars0i Thanks for your reporting!
So it would make sense to me that when iced repl is run from IcedJackIn, it should not use .lein-repl-history at all.
Agreed.
But maybe you (@liquidz ) or another contributor already know what to do.
Hmm, I have no idea for now. I'll have to take a look at Leiningen's code.
Thanks @liquidz! I'll try to figure out whether there's configuration setting for rlwrap that can be set. Maybe it's possible to pass something to Leiningen that will modify that, if it's correct that Leiningen or nrepl or something is using rlwrap.
Here's more info. I'm not certain about everything, but the following seems correct to me at present. (I haven't followed every relevant code path, so I'm making reasonable guesses about some things.)
The history file name for a project or for running lein outside of a project are coded here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/repl.clj#L123
The filename is passed to reply
as the value of :history-filename
, which seems to be what actually writes the history file. https://github.com/trptcolin/reply/blob/f0c730e7a6753494f9f90f02234bc040318da393/src/clj/reply/eval_modes/standalone.clj#L39
So I found that I can override the history filename by placing:
:repl-options {:history-file ".my-history"}
in my project.clj. I thought this would solve the problem. However, when I change my history file, :IcedJackIn
just uses the new history file, when it does write to the history file. (I don't think that vim-iced always overwrites the history file, but when it does, it happens when exiting vim, I think. It might have to do with whether I start the repl from the command line or call :IcedJackIn
first.)
So it doesn't seem that I can work around the problem with my config, but maybe there's an easy workaround at the vim-iced end. If vim-iced assoc-in
s a different value for :history-file
when it runs leiningen, perhaps that would give it a separate history file. ("/dev/null" is an option--that seems to work as expected when I make it the value of :history-file
.)
[I don't think rlwrap has any role at all. That was from some old information I saw on the internet. :-) Leiningen uses reply
afaics.]
Could this problem be related to #401 ?
Good question. I'll check.
So far, .lein-repl-history isn't getting deleted by IcedJackin
. I'll let you know if it happens again in the next few days.
Feel free to reopen if you have any problems :)
Thanks @liquidz !
I'm still experimenting with how I want to use vim-iced, but often I have been using
IcedJackIn
(via<leader>"
) instead of connecting toiced repl
. I'm runninglein repl
with special profiles, and running computations that take a long time. So it's made more sense to run vim-iced's REPL separately usingIcedJackIn
. I run experiments withvim-iced
, but then for the long-running computations, I enter commands in a separate Leiningen repl in a terminal.It appears that the
iced repl
run fromIcedJackIn
overwrites the Leiningen history file .lein-repl-history. Sometimes it preserves what was in the file beforeIcedJackIn
is run, but sometimes it just zeros out the entire file. So any history from what I was typing or pasting into the REPL running in the terminal is lost. (I tried this in both the pre-3.8.4 dev version, and in the new 3.8.4 release.)I assume that since the iced REPL run by
IcedJackIn
doesn't keep a history of what it evaluated--that probably wouldn't make sense--there is no history to write to .lein-repl-history. But that file gets written to anyway.So it would make sense to me that when
iced repl
is run fromIcedJackIn
, it should not use .lein-repl-history at all.Maybe a fix would be to be able to configure
iced repl
to pass something to Leiningen that would turn off or change the history file. I don't yet see a way to do that with Leiningen. I can investigate further if that would be helpful. But maybe you (@liquidz ) or another contributor already know what to do.(This is with Vim. I've been experimenting with neovim, too, but I haven't verified that the problem occurs with neovim.)