tpapp / julia-repl

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

Feature request: Restart julia process in vterm #110

Open jlapeyre opened 3 years ago

jlapeyre commented 3 years ago

I am using vterm. I'd like to restart the Julia process and at the same time, keep the contents of the buffer. There may be a way around this, but what I am trying now is.

reproduce undesirable behavior

  1. M-x julia-repl
  2. ctrl-d (exits julia)
  3. M-x julia-repl This errors with "You cannot change major mode in vterm buffers"

I'd like to restart the Julia process and at the same time, keep the contents of the buffer.

configuration

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 julia-repl: 20210408.639 julia: v"1.7.0-DEV.961

julia-repl loaded like this

(use-package julia-repl
  :commands julia-repl julia-repl-mode
  :config (progn
            (julia-repl-set-terminal-backend 'vterm)
            (setq vterm-max-scrollback 100000)
            (load-library "julia-mode")))

EDIT: As a workaround, I change the argument of vterm-shell to the name of my shell, rather than julia. This requires only that I type "julia" to start julia in the vterm. https://github.com/tpapp/julia-repl/blob/79e686e3ebf164bd39fc2ea5cf09d38d0e1d763a/julia-repl.el#L214

wentasah commented 3 years ago

Interesting, my setup is almost the same as yours, but I cannot reproduce the problem. Whenever I exit Julia, the REPL buffer disappears and calling julia-repl makes it appear again with freshly started julia.

ggebbie commented 2 years ago

Same issue as jlapeyre here. Emacs 27.2, Julia 1.7.1, julia-repl 20211230.814. When I exit Julia, the REPL does not disappear and invoking M-x julia-repl gives same error (i.e., cannot change major mode). Some conflict elsewhere in emacs setup?

wentasah commented 2 years ago

Can you try to reproduce it with emacs configuration below?

Put the following to myinit.el:

;;; Straight bootstrap

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(setq package-enable-at-startup nil)

;; Use package setup

(setq straight-use-package-by-default t)
(straight-use-package 'use-package)

;; Package initialization

(use-package julia-mode)

(use-package julia-repl
  :commands julia-repl julia-repl-mode
  :config (progn
            (julia-repl-set-terminal-backend 'vterm)
            (setq vterm-max-scrollback 100000)
            (load-library "julia-mode")))

and run emacs as:

emacs -Q -l myinit.el

or, if you don't want straight.el to touch your ~/.emacs.d, run:

mkdir tmp
HOME=$PWD/tmp emacs -Q -l myinit.el

On my system, julia-repl works as expected with the above config. I guess that something else in your Emacs config can cause the problems.

ggebbie commented 2 years ago

thanks for the detailed instructions wentasah. I think your hypothesis is right.

using the minimal configuration, when I exit() julia, I get Process julia finished. The buffer is not minimized or killed. Then M-x julia-repl starts a new julia session in the same buffer as the earlier julia session. I don't get the "major mode" error. If I'm able to find the conflict in the rest of my emacs configuration, I will post it here.

rdiaz02 commented 1 year ago

In case it helps, I was experiencing the same issue. I had set (setq vterm-kill-buffer-on-exit nil) (as explained in https://github.com/tpapp/julia-repl#using-vterm to see error messages from processes that wouldn't start) but then forgot to set it to t.