Highlight julia code in emacs - emacs

I would like to write julialang code in emacs. Is there an easy way to do it like, for example, when you do python code (all these reserved words in colors and indentation)?
Here is what I have done so far:
I created the file
~/.emacs.d/init.el
with the line (after cloning https://github.com/emacs-ess/ESS/wiki/Julia):
(load "/path-to-ESS/ESS/lisp/ess-site.el")
julia is in my path also. Still, emacs does not recognize julia code

I think that this may help. It seems to be emacs support for Julia.
emacs-ess / ESS
Julia
Overview
ESS support for julia language, among other things, includes
font-lock, indentation, sending code to sub-process, interactive
documentation, imenu, completion and eldoc.
Usage
Start
To start julia type M-x julia RET. You can start multiple julia
processes if you so desire.
To autostart or switch form script to julia subprocess use C-c C-z. To
switch from process buffer to the most recent script buffer also use
C-c C-z. To associate a buffer with a different julia process press
C-c C-s.
Evaluation
To send chunks of code from your script use C-c C-c, C-M-x, C-RET etc.
To load the whole file: C-c C-l. See evaluating code section in ESS
manual. (tip: look up the documentation string of these commands with
for example C-h k C-c C-c)
Help
To access documentation for any help topic or object use C-c C-d C-d.
To call apropos: C-c C-d C-a. To look up for a topic in julia standard
library reference: C-c C-d C-r. To look up a topic in the julia
manual: C-c C-d m. To search julia website: C-c C-d C-w.
To see all help commands defined in ess-doc-map: C-c C-d C-h. See Help
section in ESS documentation.

Related

emacs - Kill the buffer with terminal emulator

I am aware of this option:
Kill the *terminal* buffer with C-d
But I am still a newbie in emacs, what is the original method to do this? I tried C-x k but it doesn't like it, C-x C-c kills all my windows and buffers...
I assume you're using a buffer in term-mode (M-x term). term-mode is a bit different than most modes in that it has two submodes, char and line. In char mode it acts more like a terminal than emacs, as in a lot of normal keybinds are not available. Put it in line mode with C-c C-j to put it in line mode, then you can run most normal keybinds including C-x k. You can put it back into char mode with C-c C-k.
I use the multi-term package, which I think has better defaults than plain term-mode and as the name suggests makes it easy to have many terminal buffers.

Slime Autocompletion when editing file

I am new to Lisp. I installed LIsp in a box to learn Common Lisp. In the slime-repl I can use autocompletion using the tab key. However I want to do so in other buffers - files - I edit. For instance I want to do the following:
C-x b ;; Here I switch to the buffer corresponding to my file. S I am not in the repl anymore.
(remove-i ;; Here I use the tab key, but nothing occurs.
In the repl buffer, I can type (remove-i and I will see matching functions such as remove-if and remove-if-not.
How can I add lisp autocompletion while editing any other file?
C-M-i (translated from <M-tab>) runs the command slime-complete-symbol (found
in slime-mode-indirect-map), which is an interactive compiled Lisp function in
‘slime.el’.
It is bound to C-c TAB, C-M-i, <menu-bar> <SLIME> <Complete Symbol>.
(slime-complete-symbol)
Complete the symbol at point.
Completion is performed by ‘slime-completion-at-point-functions’.
You can bind this function to TAB, if you want.
Peter

Clojure documentation in Emacs

Is it possible to view Clojure function documentation in Emacs? Namely, can I configure Emacs to lookup Clojure functions under the cursor?
I'm using clojure-mode and SLIME. Oddly, I can't even use apropos or dir in SLIME's repl, although they're automatically loaded by lein repl.
Try the function slime-describe-symbol, which is usually bound to C-c C-d d.
Place the point somewhere near the function name and hit C-c, then C-d, and then d.
There's also slime-describe-function, bound to C-c C-d f, but I rarely use it, as it's less general than the aforementioned symbol-related lookup function.
To see all the documentation-related functions, press C-c C-d C-h. These bindings are not specific to Clojure; they are instead defined by SLIME, and will work as well if not better for other Lisp dialects.
I find the combination of slime-apropos and eldoc minor mode (make sure you have swank-clojure 1.4.0 as it fixes both of those) better than the slime-describe-symbol/function commands mentioned above.
From SLIME REPL you can run (use 'clojure.repl). This will make functions like apropos and doc available

Is there a way to go back to a keyboard macro from elisp?

I have been creating macros and saving them for later use with the following process.
Create keyboard macro
Edit the macro: C-x C-k C-e
Name the macro: M-x name-last-kbd-macro
Create an .el file then insert the macro definition: M-x insert-kbd-macro
With the lisp code saved for later, I'll load it up in my .emacs file. Perhaps it is my unfamiliarity with elisp, but the elisp code which is generated seems quite unwieldy. I much prefer the syntax in the macro editor, and I'd like to make updates and refinements to the code that I've created, so I ask:
Is there a way to take my elisp code back to a reasonable rendition in the macro editor?
You can use C-x C-k e M-x followed by the name of the macro you want to edit. (Or C-x C-k e (edit-kbd-macro) followed by the key sequence a macro is bound to; M-x here is just a kind of mnemonic, as the help for the command explains).
Maybe it's also helpful to know that all the keyboard macros you've run are saved in a global ring, so you can cycle backwards and forwards through them using C-x C-k C-n and C-x C-k C-p.
BTW, it's not just unfamiliarity with Elisp that makes those macro definitions hard to read; insert-kbd-macro basically just writes out the macro as a vector of key sequences. Elisp written by humans is a much pleasanter language ;-)

Emacs C-h c doesn't seem to work for chords 3 combinations long?

I'm trying to use C-h c in emacs to figure out what a key combination is bound to. The combination is C-u C-c C-q, which realigns tags in org-mode. However, Emacs just tries to look up C-u C-c and then fails. What am I doing wrong? I realize I could easily look at the orgmode source or something to figure this out, but for future reference what would I do to figure out what function something like this is bound to?
Edit: OK, so it's actually C-u followed by C-c C-q, and according to emacs this is what that combination is bound to:
(org-set-tags-command &optional arg just-align)
Call the set-tags command for the current entry.
So what exactly does it mean to give this command the argument 4?
Oh, just to give an explanation: I'm trying to start learning emacs-lisp and customization and one of the things I wanted to do was to have this command added to the before-save-hook so that when I save an org file, the tags get automatically aligned.
Final edit: I figured out why this command behaves as it does; given the prefix argument it changes its behavior. How can I set the prefix argument when calling the function in elisp?
It's not a general problem with combinations that are three keys long: For example, C-h c ESC ESC ESC (keyboard-escape-quit) or C-h c C-x r t (string-rectangle) both work fine.
When I try C-h c C-u C-c C-q in org-mode, the command interrupts after C-u and shows:
C-u runs the command universal-argument
in the minibuffer, which is correct. So, in fact, "C-u C-c C-q" is not a command, it's the command "C-c C-q" (org-table-wrap-region) started with an additional argument (4 -- see C-h k C-u for an explanation).