Open SethTisue opened 4 years ago
@dwijnand notes that jshell has an edit command that actually works reliably and is useful. though it's more relevant in java given it's verbosity. our edit works or not if you're lukcy.
control-R already works for searching history. (this was true in JLine 2 as well.)
Details: in jshell /edit
works with my settings of EDITOR=vim
while with scala
I need to set EDITOR=mvim
to have something that works.
emacs-sbt-mode
uses the history commands as well and also expects the commands run from emacs to be there (i.e. when jline is off, I guess)
I've made this ticket history-only, labeled it a blocker, and moved the edit stuff to a new ticket (#700)
now that I take a second, slower look at this I see that :history
shows the history (optional numeric argument of how many entries to show) and :h?
is for searching it:
scala 2.13.1> 2 + 2
res0: Int = 4
scala 2.13.1> 3 + 4
res1: Int = 7
scala 2.13.1> 5 + 6
res2: Int = 11
scala 2.13.1> :history
1 2 + 2
2 3 + 4
3 5 + 6
4 :history
scala 2.13.1> :h? 5
3 5 + 6
5 :h? 5
scala 2.13.1> :history 2
5 :h? 5
6 :history 2
@hvesalai I see that emacs-sbt-mode reads ~/.scala_history
; note that we're changing it to ~/.scala_history_jline3
you write "uses the history commands as well" and I'm puzzled about that. I'm looking in the sbt-emacs-mode source code and I see that it uses :completions
, but I do not see that it uses either :history
or :h?
based on my observations, I'm removing the "blocker" label from this, but I can add it back if you can confirm that it's specifically :history
and/or :h?
that you want/need
Another thing I hadn't understood before: in JLine 3, history search is connected to up-arrow. So if you type e.g. pr
and then hit up arrow, it starts cycling through previous entries that begin with pr
. Dotty and Ammonite both support this. It doesn't make :h?
useless, I guess, but the need for it to exist is now less.
It already works in our PR, too. (Perhaps not perfectly?)
commented-out code in the PR: