hvesalai / emacs-sbt-mode

An emacs mode for interacting with scala sbt and projects
GNU General Public License v3.0
125 stars 38 forks source link

comint-history isn't read from or written to history files #141

Closed nverno closed 2 years ago

nverno commented 6 years ago

When entering an sbt mode, the history file isn't loaded. When switching between submodes, the history isn't saved. It might be nice to have a hook that runs when switching between submodes.

hvesalai commented 6 years ago

Infact, comint is reading the history. It might be reading the wrong one. See also #61 #81

And it should not write any history, that should be sbt:s task.

nverno commented 6 years ago

Of course, your're right it is reading the history files. But it's current behaviour isn't great. If you switch to a console, type some commands, then switch back to sbt console all of the history from both submodes is lost. How would sbt know when to write history? In its current state, no history is written to either sbt or console history files AFAICT. In shell-mode history is written in a process-sentinel. It seems to me that a hook would be useful when changing submodes so users could apply things like comint-write-input-ring

hvesalai commented 6 years ago

Hmm... the problem seems to be that where old versions of sbt did write the history upon changing modes, current sbt does not do that when running inside emacs. I suspect something to do with jline.

You can make the following test:

Do the test both inside and outside emacs.

On my current setup nothing is recorded when run from within emacs. This is not how it was when I developed the mode and to me it is a bug in sbt that we must get fixed. @fommil

hvesalai commented 6 years ago

Never the less, the sbt-mode must not be made to write any files. It should just read the history and it shall be sbt:s job to record actions and store them

fommil commented 6 years ago

I've never been able to get history to work properly. It'd be really good to get this fixed, I spent some time looking into it last year and failed. There is an sbt option to set the location of the history file so we can't necessarily assume the location.

hvesalai commented 6 years ago

Yeah, the history missing has bothered me also for some time, but haven't had time to look into it. Here is a draft for a better history

1) make sure sbt actually records it (now it doesn't -- as I pointed out above)

2)

I'd go for option B. Much less hassle with the files.

fommil commented 6 years ago

this is what remains of my "notes to self" in my global sbt config

// causes weird problems with clean
//historyPath := Some((baseDirectory in ThisBuild).value / ".history")
fommil commented 6 years ago

oh, you're talking about REPL history. I was talking about the actual sbt history.

hvesalai commented 6 years ago

Both... "REPL" = scala console, "actual sbt" = sbt shell.

fommil commented 6 years ago

if we got this working, having fuzzy search on the history would be such a huge productivity boost.

nverno commented 6 years ago

yea I use repl history as prefix for hippie-expansion in emacs comint modes and it is a huge plus

hvesalai commented 6 years ago

Ok, so one bug squashed as JLine2 was not storing the history when the simple terminal was used. This is now fixed in Jline 2.14.6, which I'm trying to get into all relevant scala and sbt builds

nverno commented 6 years ago

Back when I was looking at this, I thought maybe a possibility of using process-put to store history location when changing projects. I don't know if that would be a useful avenue for you. I think it would benefit a lot from not using comint-prompt-regex so you could take advantage of other comint features like jumping between prompts. But, that would probably require some pretty major changes (something akin to ESS where you would wait for the process).

hvesalai commented 2 years ago

fixed in 9fe1e8807c22cc1dc56a6233e000969518907f4d