# Emacs with Julia on Windows

**URL:** <https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612>\
**Category:** Tooling\
**Tags:** emacs\
**Created:** [November 28, 2019, 8:58am UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612 "2019-11-28T08:58:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 8:58am UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/1 "2019-11-28T08:58:57Z")

</div>

Emacs running under Cygwin is perfectly usable and very functional when programming in Julia.  
It has been tested under Windows 10. Evaluation of code in files, interactive REPL, git, tags, multiple cursors, snippets, abbreviations and clever expansions, bookmarks, and more is available.

The guide [GitHub - PetrKryslUCSD/HowToUseJuliaWithCygwinEmacs: How to use Julia with Cygwin Emacs](https://github.com/PetrKryslUCSD/HowToUseJuliaWithCygwinEmacs)  
provides a quick introduction to setting up Emacs under Cygwin with julia-mode and julia-repl.  
(Hint: The quickest way is to simply copy the `.emacs.d` directory and you are up and running.)

---

<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:** [November 28, 2019, 11:16am UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/2 "2019-11-28T11:16:50Z")

</div>

I don’t think that manually copying the relevant Emacs packages is the best way to do this, as you won’t automatically track updates.

I would recommend using MELPA, possibly with

[https://github.com/jwiegley/use-package](https://github.com/jwiegley/use-package)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 11:52am UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/3 "2019-11-28T11:52:42Z")

</div>

You are undoubtedly correct, and switching over to a manner of installation which will draw in the latest versions and track updates will eventually be incorporated.

Current difficulties:

1. For someone who is installing Emacs perhaps for the first time, configuration from scratch is a bit daunting. It is hard to beat unzipping a preconfigured `.emacs.d` folder.
2. Some packages are frozen (multiple-cursors being one of them). Some parts (snippets, ctags)  
are not that easily installed from the Web in an automatic way.
3. Updating the packages that are distributed with the preconfigured `.emacs.d` folder is still possible using `package-list-packages`. Which is indubitably what more advanced users will do.
4. Updating by package installation from MELPA is not confidence-inspiring:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/2/320284e6ede29bea01d46b26c1fe063d613261b9.png)

By the way, if you have some ideas on how to configure Emacs automatically, starting from scratch, without user intervention, I’m all ears. 🙂

As always, I truly appreciate your help with things Julia (and Emacs).

---

<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:** [November 28, 2019, 12:35pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/4 "2019-11-28T12:35:32Z")

</div>

> [@PetrKryslUCSD](#):
>
> For someone who is installing Emacs perhaps for the first time, configuration from scratch is a bit daunting. It is hard to beat unzipping a preconfigured `.emacs.d` folder.

My elisp skills are not as good as Tamas\_papp 's, but I think the following code in ‘init.el’ should install `use-package` and `julia-mode` without user intervention.  
In general using `use-package` with `:ensure t` option should install the package, so you could use it in order to have all the packages you need installed without user intervention.

```julia
  (require 'package)
  (setq-default
   package-enable-at-startup nil)
  (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
  (package-initialize)

  ;; install use-package if not installed
  (unless (package-installed-p 'use-package)
    (package-refresh-contents)
    (package-install 'use-package t))

;; install julia-mode
(use-package julia-mode
      :ensure t
      :config
      ;; some config for julia-mode here
)

```

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 3:18pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/5 "2019-11-28T15:18:40Z")

</div>

That is most excellent! The guide was updated to use automatic installation (with attribution: please check to see if you’re happy).  
Everyone: please test. I did, but more people, more bugs found.

---

<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:** [November 28, 2019, 3:53pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/6 "2019-11-28T15:53:09Z")

</div>

Note that I also copied part of this code from someone else’s config at some point (not sure where) so I don’t know if this should be attributed to me : )

p.s.  
Is there a reason you are not using [magit](https://magit.vc/) instead of CLI git? In case you were unaware of magit I would definitely suggest giving it a go because it’s quite amazing in my opinion.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 4:05pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/7 "2019-11-28T16:05:07Z")

</div>

I’ve tried magit. It could be that I was running it under emacs-w32, but commit wouldn’t work: there was an error concerning emacsclient and I never got it to work.

---

<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:** [November 28, 2019, 4:15pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/8 "2019-11-28T16:15:44Z")

</div>

I don’t know when was the last time you tried it, but if it was already some time ago it seems that there was some [issue](https://github.com/magit/magit/issues/3491) that got fixed.

I think that if there is a package which is worth an extra effort, it’s definitely magit 🙂

EDIT:  
the issue I mentioned seems to be when using 64 bit version so maybe unrelated to your problem.

---

<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:** [November 28, 2019, 4:42pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/9 "2019-11-28T16:42:56Z")

</div>

I have seen reports of using Emacs in the WSL:

> **[Emacs 26.2 on WSL with working X-Windows UI](http://www.lonecpluspluscoder.com/2019/04/12/emacs-26-2-on-wsl-with-working-x-windows-ui/)**
>
> Diary of an experience C++ programmer. Thoughts on programming and other tools and languages.

which seems easier and more robust than Cygwin (but may require a recent Windows).

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 4:49pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/10 "2019-11-28T16:49:05Z")

</div>

The problem with magit is very recent (last time I’ve tried was two minutes ago :)).

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/7/b711d6f41e31b6a351b1ad87226e88b919b5111a.png)  
This was obtained with the X11 Emacs. Previously I have seen this with the w32 Emacs.  
I have tried to research this a bit, but I couldn’t find any solution and I got stuck.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 5:01pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/11 "2019-11-28T17:01:03Z")

</div>

The problem with WSL graphic programs is that they do not get recognized as individual applications,  
and the voice recognition program that I use cannot associate command sets with them. That is a dealbreaker for me.

The same problem actually occurs also with Emacs-X11 running under cygwin. And with other graphics programs that need the X server to be running.

Finally, at least under cygwin running the X server is extremely resource-hungry. Things simply slow down to a crawl. Emacs-w32 does not have that problem at all.

---

<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:** [November 28, 2019, 5:06pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/12 "2019-11-28T17:06:58Z")

</div>

Please note that because of your voice recognition program you may have unique constraints that don’t apply to the majority of users.

It would be great to have reports from users of Windows, Emacs, julia-mode and julia-repl in a plain vanilla environment without any of these complications; I imagine that simply having examples of what works would help some users greatly.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 5:47pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/13 "2019-11-28T17:47:31Z")

</div>

Re “plain-vanilla environment” (read “no voice recognition”): both the X11 and the Windows-GUI Emacsen work just fine under cygwin, but the Windows version is noticeably snappier. There is no issue with the Julia modes with either one.

---

<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:** [November 28, 2019, 5:50pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/14 "2019-11-28T17:50:37Z")

</div>

Maybe the issue is that Magit is having some trouble with finding the correct binary for `emacsclient`? When you do `which emacsclient`, do you get `/usr/bin/emacsclient` ?

Maybe there is some more info [here](https://github.com/magit/with-editor/issues?q=is%3Aissue+is%3Aclosed), [here](https://magit.vc/manual/with-editor/Configuring-With_002dEditor.html) or [here](https://magit.vc/manual/with-editor/Debugging.html#Debugging)

As far as I gather from the internet magit should work with cygwin.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 5:54pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/15 "2019-11-28T17:54:44Z")

</div>

> [@orialb](#):
>
> Maybe the issue is that Magit is having some trouble with finding the correct binary for `emacsclient` ? When you do `which emacsclient` , do you get `/usr/bin/emacsclient` ?

Indeed.

> [@orialb](#):
>
> As far as I gather from the internet magit should work with cygwin.

Well, it does not. Sorry to be the wet rag.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 5:58pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/16 "2019-11-28T17:58:17Z")

</div>

The detailed error message is:

```julia
File Edit Options Buffers Tools Magit YASnippet Help
  1 git … commit --
/usr/bin/emacsclient --socket-name=/tmp/emacs197609/server: /usr/bin/emacsclient: No such file or directory
error: There was a problem with the editor '/usr/bin/emacsclient --socket-name=/tmp/emacs197609/server'.
Please supply the message using either -m or -F option.

```

Which is weird because this is what I get when running it at the command line:

```julia
PK@Pigwidgeon ~
$ /usr/bin/emacsclient
/usr/bin/emacsclient: file name or argument required
Try '/usr/bin/emacsclient --help' for more information

```

---

<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:** [November 28, 2019, 6:04pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/17 "2019-11-28T18:04:56Z")

</div>

> [@PetrKryslUCSD](#):
>
> Well, it does not. Sorry to be the wet rag.

I’m not doubting that it doesn’t work on your machine. I was just saying that it seems that there are people out there using it with cygwin so it should be possible in principle (it could also be that what you are seeing is an issue with magit, I don’t know). I personally find the knowledge that someone else could make something work encouraging when dealing with those kind of problems, that’s why I pointed it out.

---

<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:** [November 28, 2019, 6:27pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/18 "2019-11-28T18:27:06Z")

</div>

If you are interested you might want to open an issue in the magit repo. Seems people opened similar issues in the past and they got resolved.  
I think they also need the output of `M-x with-editor-debug` to debug this problem (if I understand correctly).

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 28, 2019, 6:51pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/19 "2019-11-28T18:51:27Z")

</div>

Thank you very much for your help. I posted an issue.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 29, 2019, 12:49pm UTC](https://discourse.julialang.org/t/emacs-with-julia-on-windows/31612/20 "2019-11-29T12:49:36Z")

</div>

The issue has been resolved: the problem was the substitution of the Windows git for the one expected by Emacs under cygwin. So now magit works fine and the guide has been switched over to it.
