SBCL REPL use up arrow keys to show history - read-eval-print-loop

I have installed SBCL onto OSX through Macports.
When inside the REPL, it would be very convenient to be able to use ↑ and ↓ to iterate through the previous commands (similar to the behavior in bash or Python's REPL).
Is there a way to enable this functionality?

Install rlwrap and then run rlwrap sbcl.
You can get rlwrap through macports or homebrew.
It's pretty much as simple as that.

You could also also use Linedit. This is SBCL REPL specific, so it causes problems in other environments (like SLIME).
Or, you can try the SBCL-Readline project. Not sure how this works in SLIME, haven't tried it personally.
Both Uses UFFI to implement the use of C libraries.
Just make sure to skim through the source code and change the paths to libraries etc for your system, before trying them out!

Related

Autocomplete in golang in emacs

I'm aware a lot is involved in getting autocomplete to work in emacs, including:
auto-complete
company
flymake
I am not sure which components are responsible for which aspects. What is the package that when I start typing...
fmt.P
Would finish with
fmt.Println
?
I believe I have company as my auto-complete, and at present, if I start:
fm
It finishes fmt, but
fmt.
Produces nothing, and
fmt.P
Produces
fmt.package
Which is entirely wrong. What package should I investigate to understand what is going on?
Autocomplete, company-mode, flymake, oh my. I recommend you uninstall all of the above and use Emacs' native completion instead:
install gocode and make sure the binary is in Emacs' PATH;
install the go-complete package in Emacs (I got it from melpa, but you may prefer to install it manually);
add the following to your .emacs:
(add-hook 'completion-at-point-functions 'go-complete-at-point)
press M-TAB in a go-mode buffer.
Since the original answer was written, the original gocode has ceased being maintained. While there exist forks of gocode that work well with recent versions of Go, the recommended replacement is golsp
Install the eglot pakage from ELPA (not necessary if you are running Emacs 29 or later, which includes eglot out of the box).
Install golsp and make sure it is in your path.
Add the following to your .emacs:
(add-hook 'go-mode-hook #'eglot-ensure)
Press M-TAB in a go-mode buffer.

OS X `rlwrap coqtop` not working

rlwrap is a good program handling arrow keys in REPL loop. In most cases it works. For example rlwrap sbcl, rlwrap sml, and so on. But when it comes to rlwrap coqtop, it fails. The error information is below.
rlwrap: error: Couldn't read completions from /usr/local/Cellar/rlwrap/0.41/share/rlwrap/completions/coqtop: No such file or directory
I downloaded coqide from coq website, and installed rlwrap using homebrew. The file /usr/local/Cellar/rlwrap/0.41/share/rlwrap/completions/coqtop is at the right place. So, is there any clue how to fix this? Or is there a replacement software out there?
This is a bug that has been fixed for the upcoming rlwrap 0.42.
If you don't want to wait for an upcoming release, you can always get the newest source from github (https://github.com/hanslub42/rlwrap)

Fail to `(require "COCOA")` with Mac ports Clozure Common Lisp

I have installed the package ccl with Mac ports. Now I want to use the Cocoa bridge.
Welcome to Clozure Common Lisp Version 1.8 (DarwinX8664)!
? (require "COCOA")
> Error: Permission denied : #P"/opt/local/share/ccl/1.8/temp bundle64.app/Contents/252752233492590994.tem"
> While executing: %CREATE-FILE, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
If I start ccl64 with sudo it works all right. But I would like to be able to do this as a normal user. How should I do it?
svn co http://svn.clozure.com/publicsvn/openmcl/release/1.8/darwinx86/ccl
while in ~ is probably the most straightfoward way to achieve what you want.
If you'd like to work with MacPorts to manage ccl (instead of the svn method above), then run
sudo chown -R $USER /opt/local/share/ccl
Note that the latter case does make me a bit uncomfortable, because if you try to sudo port uninstall ccl, MacPorts does not completely remove the share/ccl directory, presumably because the (require :cocoa) call adds compiled binaries to that directory that Macports is not tracking.
To get the MacAppStore version to work, you'd probably need to find the ccl binary buried inside the ccl.app directory, and launch that for slime. Might not be a bad way to go either.
Note that any way you do this, once you (require :cocoa), you'll have a separate cocoa listener pop up while slime is running. I just move it off to the side once it opens. If you find a way to suppress this listener window after (require :cocoa), I'd be interested to know that.
But I'd recommend the first (svn) method. That's the one I use with slimv, and it's the one that Clozure recommends on their downloads page.
If you are on a Mac, the easiest way to run Clozure CL is to load it from Apple's Mac App Store.
https://itunes.apple.com/de/app/clozure-cl/id489900618?mt=12
That way it gets installed in the Applications folder and running the Cocoa-App is no problem, since it is provided. But then you would run the Cocoa-based IDE version of CCL.
If you install CCL from MacPorts, I guess that the App is not existing. You would need to have the rights for the directory to create the necessary files.
Otherwise I would just install a fresh CCL from Clozure's repository:
http://ccl.clozure.com/download.html

Ruby support in vim

If I want to work with Ruby in Vim, how can I add Ruby support to it?
First of all, you would need a Vim version that is compiled with Ruby support enabled. You achieve this with:
./configure <the rest of your options> --enable-rubyinterp
on a Linux system, for example.
The next steps would be installing the plugins of your choice, you probably want NERDTree, snipMate, vim-ruby-debugger....
There are a lot of plugins to make your life easier, but there is always the option to run arbitrary shell commands from within Vim, no extra plugin needed:
!ruby /path/to/script.rb
This will execute script.rb and print the shell output directly in Vim itself.
I would visit https://github.com/ and put "ruby vim" into search box. You should find plenty interesting add-ons for vim this way.

How do I use ruby-debug inside Emacs?

I know Emacs has some sort of integration with gdb (though I never used it) to jump through files as you debug a program. I'd like to do the same with Ruby programs.
As erenon said, use ruby debug, which provides a library for emacs that lets you use it just as gdb.
Install rdebug by issuing this command on your terminal(the sudo is optional, depending on your system):
<sudo> gem install ruby-debug
You then need to download the ruby-debug-extra file from rubyforge, and install it in the standard way.
sh ./configure
make
make test # optional, but a good idea
sudo make install
This gives you the elisp files for the interaction with rdebug, plus documentation for ruby-debug that can be viewed from within emacs.
AJ
There is another emacs to ruby-debug interface. See https://github.com/rocky/emacs-dbgr/wiki .
More generally, it works with other ruby debuggers and other debuggers in general.
You may want use rdebug.
I am getting "Cannot open load file: gdb-ui" in GNU Emacs 23.1.50.1 (x86_64-apple-darwin10.0.0, NS apple-appkit-1038.11) of 2009-10-31
I was stuck with same problem with gdb-ui, but I found the solution: I downloaded gdb-ui.el from here and put it into ruby-debug-extra/emacs dir... then I've adjusted Makefiles to point to this file before any other rdebug*.el files. After this step you'll get make working. Since I'm using emacs-snapshot and gdb mode is available already in my emacs environment, this issue is only about to build rdebug mode. After this I've installed it with "sudo make install" and it works perfectly :) Don't forget to add (require 'rdebug) to your ~/.emacs or whatever else you use to bootstrap your config.
The chosen strategy can be made to work, although texi2html and texinfo were not enough on my system, but I stopped pursuing this strategy without installing the extra packages.
Here's what I did: download ruby-debug-extra-0.10.4.tar.gz from http://rubyforge.org/frs/?group_id=1900&release_id=28306, untar it, but DON'T do the whole configure/make/blah/blah thing. Instead, I simply copied the 'emacs' directory to ~/.emacs.d/rdebug, and then added to my ~/.emacs.d/init.el file (you can also use your ~/.emacs file):
(add-to-list 'load-path "~/.emacs.d/rdebug")
(autoload 'rdebug "rdebug" "ruby-debug interface" t)
This won't byte-compile it, I didn't care. I prefer this solution because I got really annoyed that the packages forces you to install the docs.

Resources