# Using emacs-jupyter mode for development

**URL:** <https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276>\
**Category:** Tooling\
**Tags:** jupyter, emacs\
**Created:** [August 20, 2020, 1:28am UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276 "2020-08-20T01:28:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 20, 2020, 1:28am UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/1 "2020-08-20T01:28:13Z")

</div>

> [@Keeping the syntax and the need to memorise syntax simple](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/90):
>
> I love emacs for julia development and see no reason to change. I mostly use [emacs-jupyter](https://github.com/nnicandro/emacs-jupyter) in org notebooks as essentially a REPL / scratch space with better history support and then I use Revise.jl to hot-reload code in `.jl` files that I’m working on.

Can you write a post on your setup? (Your emacs config for it, an example notebook or two, a videocast perhaps) It sounds wonderful. 🙂

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [August 20, 2020, 1:50am UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/2 "2020-08-20T01:50:37Z")

</div>

I use a pretty similar setup with emacs-jupyter and org notebooks for everything (that doesn’t need to be reusable as a julia package). [Configuration is basically nonexistent](https://github.com/non-Jedi/.emacs.d/blob/master/lisp/jupyter-config.el). If Mason doesn’t have any readily available examples, I’ll take a look around my org directory and see if any are suitable for public consumption.

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 20, 2020, 3:24pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/3 "2020-08-20T15:24:24Z")

</div>

I played around with emacs-jupyter. I can get the completion to work on normal Julia buffers by calling `eglot` (though ithe completion system is still somewhat buggy and sometimes doesn’t work):

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/c/bc5077161c28bdfa6598846e2e394130c9f6c392.png)  
but the completion is incomplete in the special buffers of org babel:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/e/4e07d959ad9b0e28858c26818996f273a2c76e38.png)

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [August 20, 2020, 4:18pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/4 "2020-08-20T16:18:39Z")

</div>

I think eglot will never work with editing source code that isn’t directly linked to a specific julia file due to the limitations of how the language server protocol works:

[https://github.com/joaotavora/eglot/issues/523](https://github.com/joaotavora/eglot/issues/523)

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 20, 2020, 4:35pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/5 "2020-08-20T16:35:01Z")

</div>

VSCode itself works though:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/7/0747d149418b9434e5dd9d8d0beb74d29448732c.png)  
They are using the language server as well, aren’t they?

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [August 20, 2020, 4:36pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/6 "2020-08-20T16:36:30Z")

</div>

I don’t know how the new notebook interface works to be honest. They might be doing something custom or hooking into endpoints of the language server that aren’t part of the specification.

---

<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:** [August 20, 2020, 5:10pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/7 "2020-08-20T17:10:41Z")

</div>

emacs-jupyter provides also its own completion by querying the jupyter kernel (or something like this). For me completion in the special buffer works when I use only emacs-jupyter without eglot running (Edit: actually it works for me also when eglot is running)

Can you try to disable eglot and then call completion-at-point in the special buffer?

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 20, 2020, 6:51pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/8 "2020-08-20T18:51:36Z")

</div>

Have you tried my specific example (trying to complete a function imported via “using x”)? There is some completion support, but it is very incomplete.

---

<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:** [August 20, 2020, 6:57pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/9 "2020-08-20T18:57:54Z")

</div>

yes

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/f/5f6834afa760886f3c711877a4e374146b1b0c0e.png)

Just to clarify because it is not clear from your screenshot, did you first run the block with `using Distrbutions` before trying to get completions? If `Distributions` was not loaded in the kernel yet you would not get completion (same as in a Jupyter notebook or the REPL).

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [August 20, 2020, 8:12pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/10 "2020-08-20T20:12:53Z")

</div>

Here is my config [https://github.com/MasonProtter/.emacs.d](https://github.com/MasonProtter/.emacs.d), but it’s not really the best for sharing widely; it’s pretty adapted to my specific machines, needs and workflows.

I can try to make a trimmed down ‘starter’ version of it though and then perhaps a little videocast of me using my ‘scrap notebooks’.

No guarantees I’ll get around to this anytime soon though, I’m a pretty egregious procrastinator.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [August 20, 2020, 8:23pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/11 "2020-08-20T20:23:52Z")

</div>

> [@Mason](#):
>
> [GitHub - MasonProtter/.emacs.d](https://github.com/MasonProtter/.emacs.d)

You should update `julia-mode`. It’s had a number of bugs fixed since 2017. 😉

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [August 20, 2020, 8:34pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/12 "2020-08-20T20:34:22Z")

</div>

Right, I should have said, the only files in there actually worth looking at is [myinit.org](https://github.com/MasonProtter/.emacs.d/blob/master/myinit.org) and I guess [init.el](https://github.com/MasonProtter/.emacs.d/blob/master/init.el) if one wants to know how I use a org file for the config.

The rest is junk I pushed to the repo years ago when I was still learning to use git and now regret doing so, but not enough to actually remove it.

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 21, 2020, 8:40pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/13 "2020-08-21T20:40:24Z")

</div>

You’re right. Is there a way to get the completions in the normal org buffer, without opening the special buffers?

---

<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:** [August 21, 2020, 10:59pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/14 "2020-08-21T22:59:39Z")

</div>

For me completion works also in the org buffer inside the source-code block.  
According to emacs-jupyter’s README I think it should just work (but maybe I’m missing something):

> For `org-mode` users, there is even completion in the `org-mode` buffer when editing the contents of a Jupyter source code block.

If you do `M-x completion-at-point` inside the source code block, does it work?

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 22, 2020, 2:16pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/15 "2020-08-22T14:16:32Z")

</div>

I needed to set company-backends to company-capf and then things work! 👍  
Is there a way to use several company backends together? I also like to have dabbrev-code …

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 22, 2020, 2:17pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/16 "2020-08-22T14:17:49Z")

</div>

Even the docs work:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/5/3578010fb220fa89fe2c27046297126398efc2fe.png)

It’s pretty awesome!

---

<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:** [August 22, 2020, 6:29pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/17 "2020-08-22T18:29:37Z")

</div>

> [@NightMachinary](#):
>
> Is there a way to use several company backends together? I also like to have dabbrev-code

I’m not an expert on company-mode, but it seems that you can define multiple backends in `compny-backends`. I’m not sure exactly how those different backends interact with each-other and how it is determined which one is called, try reading the documentation of that variable.  
I think you could also define different backends for different modes via mode hooks since `company-backends` is a buffer-local variable.

---

<div class="post-metadata">

**Author:** ![pyrex41](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@pyrex41](https://discourse.julialang.org/u/pyrex41)\
**Post date:** [September 10, 2020, 6:31pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/18 "2020-09-10T18:31:00Z")

</div>

As someone fairly new to emacs (just got Prelude up-and-running, not familiar with company mode or org mode), would be great if someone could put together just a basic guide to getting julia support working. I was able to install julia-mode to get syntax highlight w/ no problem, and also to launch an repl with julia-repl, but beyond that I am not really sure which way to go

---

<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:** [September 10, 2020, 7:33pm UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/19 "2020-09-10T19:33:14Z")

</div>

What features are you looking for? I think julia-mode + julia-repl is basically the basic setup.  
For code completion in source files you can take a look at [eglot-jl](https://github.com/non-Jedi/eglot-jl) or [julia-snail](https://github.com/gcv/julia-snail).  
For interactive notebook like experience take a look at emacs-jupyter.

If you have specific problems feel free to ask.

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [September 11, 2020, 9:31am UTC](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276/20 "2020-09-11T09:31:11Z")

</div>

Copy my doom config from [GitHub - NightMachinery/doom.d: My somewhat modular emacs config.](https://github.com/NightMachinary/doom.d) . You also need doom installed.

You need IJulia installed in your Julia environment.

Then you can put this in an .org file and press ‘Ctrl-c Ctrl-c’ to run the code:

```julia
#+begin_src jupyter-julia :session j1
println(8)
#+end_src

```

Pressing `K` in normal-mode on any symbol shows its docs. Autocompletion works by just typing:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/a/bafa0f705e52fdd311dbca464c3ca22fdfaa5906.png)

Typing `<sj` and pressing TAB will insert a Julia cell with `jupyter-julia :session j1` filled in.

[Next page](https://discourse.julialang.org/t/using-emacs-jupyter-mode-for-development/45276.md?page=2)
