I've just set up Racket and have been trying out the interpreter.
However, I can't seem to go up and down the command history using the arrows (or Ctrlp/Ctrln for that matter) or use Ctrlr to search through it.
Is that even supported? Can I build it with that feature in?
Coming from a Python background I'm very used to these features and would like to have them available for Racket too.
DrRacket IDE
In the Racket IDE you can hold CTRL with arrow keys to get to previously written statements in the interactions window.
Racket in terminal
eXtended REPL
Extended REPL gives read-line features like using arrows to go back in history as well as you can search with CTRL+r. It has in addition REPL-commands like ,apropos. By entering ,help you get a list of commands you can use or you can consult the documentation. To use it you can:
enter (require xrepl) to activate it
run racket with racket -il xrepl
install it once and for all from xrepl by evaluating ,install!
Standard readline
You have normal readline which you can activate by:
enter (require readline/rep) to activate it
run racket with racket -il readline
install in once and for all by evaluating (install-readline!).
Related
I very often open Racket in bash shell, however in order for it to support xrepl, I need to execute (require xrepl) command first.
Is there any way to start racket and execute command above automatically?
See Installing XREPL, especially the part I bolded below:
To use XREPL, start racket and enter (require xrepl). You will know that it works when the prompt changes to a ->, and, if you’re working on a capable terminal, you will now have readline editing. You can also start racket and ask for XREPL to be loaded using command-line arguments:
racket -il xrepl
If you want to enable XREPL automatically, add this expression to your Racket initialization file. An easy way to do the necessary editing is to enter ,install!, which will inspect and edit your initialization file (it will describe the change and ask for your permission). Alternatively, you can edit the file directly: on Unix, it is ~/.racketrc, and for other platforms evaluate (find-system-path 'init-file) to see where it is.
How do I create/issue compilation command on Emacs, so I don't need to switch back and forth between it and console? My usual compilation procedure I'd like to see as Emacs command:
$ export PATH=/toolchain/gcc-linaro-arm-linux-gnueabihf-4.7/bin:$PATH
$ cd my/project
$ make CROSS_COMPILE=arm-linux-gnueabihf- all
I tried to make my own version of M-x compile command following instructions, but failed as I'm not familiar with Lisp and Emacs internals enough. Please note, that projects in question are big (i.e. kernel) with multi directories and Makefiles, so the approaches (closest Makefile, default directory etc.) described in the previous link are not a solution. Bonus points if you could bind it to a single key, like Fx key on modern IDEs.
P.S. I'm aware that there's similar question, but it's outdated and doesn't cover cross compile issue, I hope there's a better solution nowadays.
You can create a custom function that runs a specific compile command in a specific directory, like this:
(defun my-compile ()
(interactive)
(let ((default-directory "~/my/project"))
(compile "export PATH=/toolchain/gcc-linaro-arm-linux-gnueabihf-4.7/bin:$PATH && make CROSS_COMPILE=arm-linux-gnueabihf- all")))
And then bind it to some convenient key:
(global-set-key [f12] 'my-compile)
Ctrl U Meta x compile should ask you what compilation command to use. You could type make CROSS_COMPILE=arm-linux-gnueabi all
Otherwise, configure your compilation-command Emacs variable, perhaps in your ~/.emacs; and you might make that a file-local variable.
You could put in your ~/.emacs the following untested lines
(load-library "compile")
(global-set-key [f12] 'recompile)
(setq compilation-command "make CROSS_COMPILE=arm-linux-gnueabihf all")
BTW, your export PATH=... could be added e.g. in your ~/.bashrc, or you could have a shell script running that exact make with the appropriate PATH and have that script be your Emacs compilation-command (perhaps even "temporarily", i.e. just in your emacs session)
I'm using Geiser in Emacs on Windows as a Racket programming environment. I'm working on the file "d:/code/racket/foo.rkt". "d:/code/racket/foo.rkt" is a module (it starts with #lang racket).
I can use ,enter "d:/code/racket/foo.rkt" at the Racket REPL to enter the module, and having done so I can successfully execute functions from the file.
However, if I change the file and re-run ,enter "d:/code/racket/foo.rkt", the file is not re-loaded: changes to functions in my file are not reflected when I re-execute them in the REPL.
I have tried re-compiling my buffer with C-c C-k before re-running ,enter, but this makes no difference.
I've also tried executing ,enter #f to exit the foo.rkt module, then re-running ,enter "d:/code/racket/foo.rkt"; this still doesn't reload the module.
I've also observed that running (enter! (file "d:/code/racket/foo.rkt")) instead of ,enter "d:/code/racket/foo.rkt" does reload the file.
Is this a known limitation of Geiser's ,enter form, or am I missing a trick?
(Versions are: Geiser 0.5, Emacs 24.3.1, Racket 6.0, Windows 8)
When using emacs for writing erlang source code, I have made the following configuration.
In the emacs, 6 windows are open at the same time, 4 windows for source code writing, 1 windows for terminal shell, 1 windows for erlang shell.
After one source code modification, I have use command "m-x ter" to switch "terminal shell", then using "m-p" for recovering last history command, then pressing "enter" to run.
Then using "c-x, left " to switch to erlang shell, then press m-p to repeat last command.
The above two switch process seems a little long, could you have better solution?
The compile function is the general mechanism for such things, and the compile-command variable tells it what to do (as a shell command to run).
By default, the command is make, so if you have a Makefile, you're already sorted.
If not, and writing one isn't appropriate, then you can customise compile-command for your files, perhaps using local variables.
File-local variables for this purpose are covered in the linked Q&A.
You can also use Directory-local variables if you want it to automatically apply to all files under a given directory.
Or if there's a general pattern which can be applied to all erlang files, everywhere, then you might set up compile-command using the erlang mode hook.
Finally, you can just supply the command on demand. Called interactively, M-x compile prompts you for the command to run, and uses the previous command as the default for the next time.
I have been a VIM user for 4 years, but have been trying to learn emacs. My project is fully written in perl and I am trying to get the cscope working in emacs for perl.
I don't have any problem navigating perl from VIM.“cs add cscope.out” from vim command mode does the job for me. In emacs though, with the same cscope database (which has both C++ and perl symbols) emacs perfectly recognizes my C symbols (M-x M-x cscope-find-global-definition). But for perl symbols, I am getting the below error .
Error:
Finding global definition: somePerlFunction Search complete.
Search time = 0.92 seconds.
No matches were found.
Does emacs supports perl code navigation? If not, isn't it a major drawback? Can someone please help?
Yes, Emacs supports cscope, there are several options:
http://www.emacswiki.org/emacs/CScopeAndEmacs
I've just tested xcscope.el on GNU Emacs 24 and it seems to be working fine.
If you already have a cscope database, I suggest you run cscope from the command line, using the -d flag:
cscope -d
Use the 'Find this global definition' option to search for your symbol, if you don't get any results then the issue is with cscope, not Emacs. If you do find results, please provide more detail, e.g. which method of integrating cscope with Emacs you are using, which version of Emacs, and provide sample perl code which can be used to reproduce the problem.
You may also want to investigate cedet:
http://cedet.sourceforge.net/