tpapp / julia-repl

Run an inferior Julia REPL in a terminal inside Emacs
Other
169 stars 35 forks source link

No history beyond previous command in REPL #115

Closed dbpatankar closed 2 years ago

dbpatankar commented 2 years ago
  1. the Emacs version (M-x emacs-version [RET], will also appear in the buffer *Messages*), GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4) of 2021-03-26

  2. the Julia version (VERSION) julia-1.6.4

  3. the version of julia-repl (something like “latest master” is fine). 20210913.1256

  4. self-contained steps to replicate the issue. a) Start julia repl with C-c C-z b) Type a = 1 RET c) Type b = 2 RET d) Use up arrow multiple times. Only b = 2 line will appear.

hexaeder commented 2 years ago

I cannot reproduce this on

GNU Emacs 27.2 (build 1, aarch64-apple-darwin20.6.0, Carbon Version 164 AppKit 2022.6) of 2021-11-21
Julia 1.6.4

My Julia command history works across all Julia processes (in terminal or emacs) and versions. Does this feature works for you in normal Julia sessions in terminal? What happens if you launch the Julia process in the Emacs terminal without usage of julia-repl?

hexaeder commented 2 years ago

Ah well I was trying in vterm. As soon as I run a term terminal in emacs and start Julia I can reproduce the error.

In term it is defined as

;; Which would be better:  "\e[A" or "\eOA"? readline accepts either.
;; For my configuration it's definitely better \eOA but YMMV. -mm
;; For example: vi works with \eOA while elm wants \e[A ...
;; (terminfo: kcuu1, kcud1, kcuf1, kcub1, khome, kend, kpp, knp, kdch1, kbs)
(defun term-send-up    () (interactive) (term-send-raw-string "\eOA"))

and the docstring hints that it might be better to send \e[A

If you overwrite the definition with (defun term-send-up () (interactive) (term-send-raw-string "\e[A")) in your emacs session it works as expected.

dbpatankar commented 2 years ago

This solves the issue for now. Also the above workaround works only for up arrow (to go back in history) but down arrow press results in empty line. Hence adding another line for down arrow press solves the issue completely for me. Here are the two lines I added in my emacs init.

(defun term-send-up () (interactive) (term-send-raw-string "\e[A"))

(defun term-send-down () (interactive) (term-send-raw-string "\e[B"))

Thanks for the solution. Closing the issue.

tpapp commented 2 years ago

@dbpatankar: thanks for reporting this and the workaround. I am hesitant to modify a lot of term-related bindings in this package since they are global (shared by all other usages of term). vterm is the recommended solution.