Emacs with Julia on Windows

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
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.)

5 Likes

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

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

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

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

1 Like

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.

  (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
)
3 Likes

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.

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 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.

2 Likes

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.

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 that got fixed.

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

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

1 Like

I have seen reports of using Emacs in the WSL:

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

1 Like

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


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.

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.

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.

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.

1 Like

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, here or here

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

Indeed.

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

The detailed error message is:

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:

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

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.

1 Like

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).

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

2 Likes

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.

3 Likes