julia-repl icon indicating copy to clipboard operation
julia-repl copied to clipboard

Feature request: Restart julia process in vterm

Open jlapeyre opened this issue 4 years ago • 5 comments

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

jlapeyre avatar Jun 11 '21 17:06 jlapeyre

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.

wentasah avatar Aug 20 '21 12:08 wentasah

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?

ggebbie avatar Jan 25 '22 02:01 ggebbie

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.

wentasah avatar Jan 25 '22 20:01 wentasah

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.

ggebbie avatar Feb 05 '22 15:02 ggebbie

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.

rdiaz02 avatar Oct 25 '22 17:10 rdiaz02