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
Related
I've seen hits all around this basic issue, but nothing to help with, in particular, plai-typed. So, I can start a racket REPL in geiser, then type (require typed/racket) and it seems to take, i.e., I'm ready to go with basic typed racket. Normally, typed/racket is activated by having #lang typed/racket at the top of a source code file, then loading it. Likewise #lang plai-typed is how to use the specific "Programming Languages Applications Interpretations" racket language in source code. But then how can I switch to the plai-typed language in a running geiser racket REPL? Even better would be how to do this in an org-mode babel source code block.
In a Geiser REPL buffer, you could do C-c C-m plai-typed to get access to the plai-typed language. Additionally, if you're working with a Racket file, you could open that file in Emacs with C-x C-f /path/to/foo.rkt and then do C-c C-a to load the file into a Geiser REPL (it will create a new one if there is no existing REPL). This has the same effect as C-c C-m, but it will also run any code in the file. Note that the C-c C-a approach won't work in non-file buffers because the geiser-mode-switch-to-repl-and-enter function uses the Geiser ,enter command and it tries to supply ,enter with a path, which obviously won't work if you're in a buffer that's not associated with a file.
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.
I know that you can do
M-x load-theme RET
and get a list of available themes for auto-complete, of which you could select one.
What I'm looking for, is a way to get this list of themes through Emacs LISP, so that I can cycle through it with a custom key-binding, without having to look at all the available themes and switch to one manually.
The function custom-available-themes should give you the list of themes.
I did not know this “off the top of my head”, but Emacs is a fairly discoverable system once one is comfortable digging about in the Emacs Lisp code. Here is how I found this answer:
Started a non-customized instance of Emacs:
% emacs -q
I wanted to make sure none of my normal customizations (installed packages, et cetera) would interfere with my investigation.
Since the list is available during autocomplete after M-x load-theme RET, I started with that function:
C-h f load-theme RET
Switched to the *Help* buffer and hit Enter on the link to the definition of load-theme in custom.el.
Scanned the definition of load-theme to see if it was arranging a custom completion handler. Its (interactive …) form uses the function completing-read, giving it the output of this form:
(mapcar 'symbol-name (custom-available-themes))
A quick C-h f RET on custom-availabe-themes verified that this is the source of the list of available themes.
I am following the guide here for emacs lisp interface.
C-c q is supposed to quit scheme mode. However this shows C-c q is undefined error. Typing (exit) on REPL works fine. Why is this key not bound in my emacs?
I see "Note that in any given implementation, only a subset of the following keys is available", but more importantly I don't believe that documentation is talking about Emacs bindings.
My impression is that those are the bindings recognised by the REPL if you were to run it outside of Emacs.
Inside Emacs you possibly need a prefix to say "send the next sequence to the REPL". e.g. in Emacs' term you have to type C-c C-c instead of just C-c to send an interrupt to the terminal. However as it's not listed in the other page which listed interrupts in Emacs, I suspect there actually isn't an equivalent binding. Or at least not by default.
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