I'm playing with Paul Graham's arc, and it's getting really annoying that the up arrow inserts ^[[A instead of the previous command, and ^R doesn't work as in shell. I vaguely remember there being a simple way to run Arc's REPL in a program which will remember the input history - does anyone know what it is?
Perhaps you're thinking of rlwrap?
I like rlwrap too, but other options include:
Emacs modes:
shell
term
comint
Slime (works with Common Lisps and Clojure, probably not with Arc)
ssfe (the frontend part of sirc)
jline (especially if the REPL is written in Java, which arc is not)
nex3's arc on github comes with a script arc.sh which calls rlwrap by default, and an emacs mode to use the history with alt+P and alt+N.
Related
Setup: I am running a fairly vanilla version of Emacs Prelude after I quit using Spacemacs some days ago (mainly because the usual evil-mode-incompatibities were grinding my gears).
Problem: I am having issues with the Emacs' movement commands, in particular because I am already getting a bit of an 'Emacs Pinky'. My current workaround is using modalka-mode with h/j/k/l bindings. What I would love is a direct mapping of <SPC>-h/j/k/l to the corresponding Emacs commands C-b/n/p/f. This would require the space-key to be some sort of modifier when held down. Is my desired behavior achievable in Emacs, and if yes, how?
Remark: I do not want to use evil-mode, since I found the incompatibilities with other packages to be overly annoying.
If I understand your question correctly you are looking for mode called "space-chord".
It is installable with melpa or here:
https://www.emacswiki.org/emacs/space-chord.el
You might want to look into key chords also:
https://www.emacswiki.org/emacs/KeyChord
They are awesome, especially with evil mode. For example I have "jk" bound to normal mode instead of escape or C-[.
I'm using OSX 10.9, iTerm2, Emacs Prelude, and Clojure with all the modes that entails most relevantly, smartparens. Good so far.
The short version is: has anybody out there found a harmonious way to use all of this together with OSX Mission Control?
The longer version goes: I want to be able to use commands like sp-forward-slurp-sexp, which has a default keybinding of C-<right>, better known as the default OS-level shortcut for "switch Spaces right via Mission Control." I can re-map that fairly easily (say, to C-Shift-<right>) -- but now, I discover that C-<right> actually seems to be sending something like M-[1;4A. Instead of triggering sp-forward-slurp-sexp, you get sp-wrap-with-pair "[". Uhm.
I dug up this dissertation on re-mapping keys, which is very thorough, but also involves re-mapping rather a deal of stuff, then disabling the parts of paredit that are listening for the M-[ command. While this technically seems to work, I actually rather like having sp-wrap-with-pair enabled. Perhaps a better option would be to embrace the theoretically equivalent C-( -- except iTerm2 only interprets that as a literal 9, and C-) as 0. This SO post chews on this problem, and gets as far as a tantalizing comment suggesting that C-( and C-) simply be re-mapped to escape sequences that emacs can map back to C-( and C-) -- but frankly, I haven't a clue how to figure out what escape sequences those should be.
Bringing it all home: has anybody found a way to use all of these tools (Mission Control, iTerm2, Emacs Prelude, smartparens) together without having to re-wire or disable parts of some or most of them? Or: who has the most elegant re-wiring? Anybody figured out the C-)-to-escape-sequence-back-to-C-) trick yet?
Edit
Stabbing in the dark, I've done the following:
1. Set iTerm to send an escape sequence for the keyboard shortcut Ctrl-Shift-0 (C-S-)) of SPRTPRN.
2. Put this in my emacs config:
(define-key input-decode-map "\eSPRTPRN" [C-right-paren])
(global-set-key [C-right-paren] (kbd "C-)"))
...it does not work, but I've a hunch I'm getting closer. I think.
Edit, Again
I realized something: the notion that Shift doesn't work here doesn't make sense to me. At least on my emacs install, M-< and M-> jump to the beginning and end of a buffer, respectively -- and to use those commands, I have to actually press Meta-Shift-<. Huh.
I have a small GTK python application that imports a package (Twisted) that may not be loaded twice.
If I run my application in emacs with python-mode.el and press C-c C-c, the application gets executed in a python shell window.
If I now close the application, the python shell stays up and running. If I now press C-c C-c again, emacs "reuses" the old python process and thus I run into problems because I'm installing a Twisted reactor twice.
Is it possible to have python-mode.el open a new shell window each time I execute a buffer?
python-mode.el comes with a command py-execute-buffer-dedicated,
opening a new and reserved process for it
In python.el, a new inferior process is launched in a new buffer if the python-buffer variable is set to nil. Therefore, it's possible to advise the python-send-buffer function to reset that variable to nil after every invocation, thereby forcing a new Python process to be executed for every subsequent python-send-buffer command. Something like the following should work:
(defadvice
python-send-buffer
(after python-send-buffer-new-proc activate)
(setq python-buffer nil))
(ad-activate python-send-buffer)
I know that your post was asking for help with python-mode.el, but I thought it might be helpful to mention this anyway, as I'd surprised if python-mode.el doesn't use a similar mechanism. If I have time, I'll try to look into it.
Edit: the python-mode.el package uses the command py-shell to initiate a new inferior Python process. I found a mailing list posting in which a user provides an ad hoc function that appears to do what you need.
By the way, it might be worth considering that trying to alter the default behavior of python-mode isn't the best approach to this problem. I don't know what your code does, and I'm not particularly familiar with Twisted, but it seems to me that experiencing major errors when evaluating your code a second time within the same session could be a sign of a more fundamental design problem. I fail to see how it could be a matter of multiple imports of the same module being the issue, as Python modules are only loaded once, with successive import statements having no effect (for that, an explicit reload or execfile() is required). If I'm completely off-base here, I apologize, but I felt this possibility might merit mention.
I like to do my Scala development in Emacs, and from time to time, I use the REPL to test out snippets of code or to load and test some code I've just written. I'm using Scala 2.9.1, and I've noticed that when I open the REPL in a terminal buffer, things are substantially broken. In particular, I am unable to remove any characters from the current line, and cannot move the cursor backward on the current line. This is highly frustrating as any time I mistype something, I have to begin the command anew. I was wondering if anyone else is having this problem using the Scala REPL under Emacs, and if anyone has a potential solution.
I find that rlwrap (readline wrapper) plays well with emacs' ansi-term and scala. Just call "rlwrap scala", and you'll have the usual bash line editing, as well as history, working properly. As a bonus, your history will span multiple invocations of scala, so you won't lose everything you've typed after exiting the Scala REPL.
If rlwrap doesn't work for you, just switching to line-mode in ansi-term (C-x C-j by default) will allow you to use emacs-style editing on the line, but without the shell niceties like history and completion.
Ensime has already been mentioned, so I'll just second that as a great option if you don't mind the setup involved.
You may install ENSIME and follow instructions. I don't know about your way to invoke REPL, but REPL called from ENSIME works (it allows moving the cursor backward and deleting symbols, I've checked).
You could try using the ammonite repl, amm. I can confirm tab completion works in the emacs ansi-term. This is true for its default mode (based on stty) or you can use JLine3 with amm. Note that the Dotty (tentative Scala 3) repl, dotr, is also based on amm and also has working tab-completion in ansi-term.
I have recently started to learn lisp, and have mainly bin using clisp and vim. I wanted to try sbcl as well, since this is often recommended as one of the best, free lisp compilers. There is one thing, though, which makes sbcl more difficult to use for me: I can not get autocomplete in the REPL, which I do have in clisp. That is, when I start sbcl and type the following (as an example),
* (requi<tab>
where <tab> is the literal tab character, I do not get a list of completions, but rather a verbose tab character. In clisp, <tab> will complete the previous line to * (require.
As I am fairly new to lisp, the autocomplete functionality in clisp is really handy, so it would really be very convenient if anyone could explain how to get it in sbcl as well.
One way of getting an autocompleting repl in SBCL is to use linedit, from http://common-lisp.net/project/linedit/. A second is to use rlwrap, a readline wrapper, with a suitable completions file. (I think it's fair to say that neither of these is as commonly used as emacs, which of course also provides a completing REPL with a number of other useful features.)
I don't know of a way to get an auto-completing REPL in SBCL, but I find that interfacing with my lisp environment from within SLIME is quite handy and at that point, you can use C-c C-i for auto-completion.
Actually it's completely possible. Yes, You want to work with Common Lisp via Emacs and Slime (I prefer SLY). But it's another wall beginners hit.
You want to just play from the REPL?
The following instructions allow autocomplete in SBCL with rlwrap.
https://www.cliki.net/CMUCL%20Hints
1) install rlwrap
2) create shell alias, for example putting text like
alias rs="rlwrap sbcl"
into your ~/.bashrc (or ~/.profile or whatever).
(or you can continue calling sbcl rlwrapped via "rlwrap sbcl")
3)Edi Weitz created a completion list file that is now gone from his website, so i'm linking to the Internet Archive. save this wordlist into a file "sbcl"
https://web.archive.org/web/20031207221537/http://weitz.de/files/cmucl_completions
4)You can try putting the file according to the instructions on Cliki, this will only apply for the user you are logged in under. I wanted it to work for all users, so I put the "sbcl" file into my rlwrap completion directory, which is in
/usr/share/rlwrap/completions/
So now I have a file /usr/share/rlwrap/completions/sbcl
That contains the words.
5)Create / adjust
~/.inputrc file add the line
TAB: complete
5) Done, now in a new terminal (or after reloading .bashrc)
I can launch SBCL via rlwrap with the alias "rs"
start typing (def (or whatever) and hit TAB, and get auto-completion suggestions.
Beginner Bonus - if you want to edit lisp in the terminal, from the REPL, in say, vim with parinfer, try magic-ed, which will allow you to edit files from the repl. Configuring SBCL to use ED is esoteric. This solves that issue for You.
https://github.com/sanel/magic-ed
With tab auto-completion and convenient way to edit lisp from the terminal, one can start learning Common Lisp in the terminal.
If you want to use sbcl, emacs and slime, follow this Modern Common Lisp on Linux tutorial. The tutorial mentions installing quicklisp and especially (ql:quickload "quicklisp-slime-helper"), an elispscript which getting slime to do autocomplete and more.