# Julia-repl in emacs

**URL:** https://discourse.julialang.org/t/julia-repl-in-emacs/33769
**Category:** Tooling
**Tags:** emacs
**Created:** [January 24, 2020, 10:23pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769 "2020-01-24T22:23:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![yzcj105](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yzcj105/32/8754_2.png) [@yzcj105](https://discourse.julialang.org/u/yzcj105)
#### Post date: [January 24, 2020, 10:23pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/1 "2020-01-24T22:23:22Z")

</div>

Hello, I used to be a juno user, however, I’d like to switch to emacs to keep everything in the command line.

I’m trying to use emacs repl in doom emacs, which is emcas with evil keybindings.

The packages I’m using is julia-mode (major mode) + julia-repl (minor mode)

The escape will bring me back to normal mode out of edit mode just as vim.  
The problem is when editing the source jl file if I accidentally pressed the “ESC” key twice. The first one brings me back to normal mode, however, the second one will quit the Julia-repl window together with the buffer and lost all the previous results. So whenever I switch between edit and normal mode, I feel very nervous.

I wonder if I’m using it the correct way or any good suggestions.

I’ve tried ess julia repl. However, the “;” command will be captured by emacs, instead of the julia REPL. So some features of julia REPL can not be used.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 25, 2020, 7:54am UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/2 "2020-01-25T07:54:57Z")

</div>

I am not familiar with those keybindings, but if

> [@yzcj105](#):
>
> The first one brings me back to normal mode, however, the second one will quit the Julia-repl window together with the buffer and lost all the previous results.

refers to using them in the `*julia*` window, note that it is basically an `ansi-term`, so whatever happens there applies.

I would suggest starting something else with `M-x ansi-term`, maybe a shell, and see if you can replicate the issue. Then it is not a `julia-repl` issue.

You may still be able to work around it by removing the binding for esc, or disabling the evil keybindings for that window only, with some hook. Frankly, I am not sure they even make sense for terminal emulators.

---

<div class="post-metadata">

### Author: ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)
#### Post date: [January 26, 2020, 10:12pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/3 "2020-01-26T22:12:19Z")

</div>

I’m not a doom user but I’ve looked at this as I have played with doom in the past.  
The main problem here seems to be that pressing esc in normal mode (bounded to `evil-force-normal-mode`) in any buffer closes the `julia-repl` buffer. This doesn’t seem to happen with `ansi-term`. I’m actually not sure what is the role of this `evil-force-normal-mode` when you are already in normal mode, so maybe you can just unbind it globally.  
This doesn’t seem to be an evil-mode issue, as I don’t see this problem in my spacemacs based config. Hence, I think it is something related specifically to doom and you might want to try and open an issue there first.

---

<div class="post-metadata">

### Author: ![yzcj105](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yzcj105/32/8754_2.png) [@yzcj105](https://discourse.julialang.org/u/yzcj105)
#### Post date: [January 28, 2020, 10:25pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/4 "2020-01-28T22:25:06Z")

</div>

> [@orialb](#):
>
> evil

Thank you very much. The `ansi-term` window remains when running `evil-force-normal-mode`. However, if it’s a julia-repl window, which is generated by running `inferior julia` (defined in julia-repl.el package), running `evil-force-normal-state` will kill the window.

I’ve also tried `eshell` in emacs, it’s also killed when pressing `<esc>`

Do you have use `julia-repl.el` in spacemacs? Is it a issue of `julia-repl` or `doom-emacs`?

---

<div class="post-metadata">

### Author: ![yzcj105](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yzcj105/32/8754_2.png) [@yzcj105](https://discourse.julialang.org/u/yzcj105)
#### Post date: [January 28, 2020, 10:31pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/5 "2020-01-28T22:31:19Z")

</div>

The ansi-term window will not be killed. It seems like, when running `inferior julia` or start a `eshell` in doom emacs, it will always be killed. From the color of some symbols, these `*julia*` or `eshell` windows looks a bit different from the `ansi-term`.

If I run a julia manually in `ansi-term`,it can capture the `;` or `]` key to transform to julia shell or package mode. It’s not the same in the automatic `*julia*` or `eshell` window.

The headache is, when ever I switched to a different buffer in the window (I only have one), the julia repl will be terminated.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 29, 2020, 7:21am UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/6 "2020-01-29T07:21:16Z")

</div>

Just to clarify, are we talking about

> **[GitHub - tpapp/julia-repl: Run an inferior Julia REPL in a terminal inside Emacs](https://github.com/tpapp/julia-repl/)**
>
> Run an inferior Julia REPL in a terminal inside Emacs - GitHub - tpapp/julia-repl: Run an inferior Julia REPL in a terminal inside Emacs

which _always_ uses an `ansi-term` buffer, or [`inferior-julia`](https://github.com/JuliaEditorSupport/julia-emacs/blob/5238f9adb7dd1c161fd6130435ebf0ac3755f33c/julia-mode.el#L882), which uses `comint`?

---

<div class="post-metadata">

### Author: ![yzcj105](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yzcj105/32/8754_2.png) [@yzcj105](https://discourse.julialang.org/u/yzcj105)
#### Post date: [January 29, 2020, 8:03pm UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/7 "2020-01-29T20:03:18Z")

</div>

Oh, sorry. I didn’t make it clear.

I have tried both the `inferior-julia` and `julia-repl C-c C-z`. Two esc will kill `inferior-julia` window and buffer immediately.

For `julia-repl` case, the `julia-repl C-c C-z` window will be killed. After a few seconds, the buffer is still there, the major mode transforms from `Term` to `Fundamental`, no text in windows. It looks like the julia process has been killed in background.

---

<div class="post-metadata">

### Author: ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)
#### Post date: [January 30, 2020, 7:45am UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/8 "2020-01-30T07:45:13Z")

</div>

> [@yzcj105](#):
>
> Do you have use `julia-repl.el` in spacemacs?

yes.

> [@yzcj105](#):
>
> Is it a issue of `julia-repl` or `doom-emacs` ?

I would guess it is a `doom` related issue.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 30, 2020, 11:18am UTC](https://discourse.julialang.org/t/julia-repl-in-emacs/33769/9 "2020-01-30T11:18:53Z")

</div>

> [@yzcj105](#):
>
> the `julia-repl C-c C-z` window will be killed

You should check what it is bound to (`M-x describe-key`), and investigate from there. `julia-repl-minor-mode` binds this, but possibly something else overwrites it.

Do you get any error messager, either in the minibuffer or the `*Messages*` buffer? Also, `M-x toggle-debug-on-error` could help you produce stacktraces which may be informative. I would like to help, but I need more information.
