Jump to content

using Emacs and SLIME with Opusmodus

Recommended Posts

If you want to use Emacs and SLIME with Opusmodus, that is possible.


Here are steps that work:

  1. If you haven't already done so, install Quicklisp.
  2. Evaluate (ql:quickload "quicklisp-slime-helper"). Follow its instructions and put
    (load (expand-file-name "~/quicklisp/slime-helper.el"))
    into your ~/.emacs file.
  3. Start Opusmodus, and evaluate (cl-user::start-swank). This should print something like ";; Swank started at port: 4005".
  4. Now, start your Emacs.  Type M-x slime-connect and you'll be prompted for a host (use the default, which is and then a port. The port needs to match the port (default 4005) that was printed out earlier.
  5. You are now connected to Opusmodus. You should be able to say stuff like (list-plot '(1 2 3)) from the SLIME repl and have it work.


The function cl-user::start-swank basically does (load "home:quicklisp;setup") and then (ql:quickload :swank) and then (swank:create-server :port 4005 :dont-close t), so there's no magic going on there.


If you run into trouble, let me know and I'll try to help out.


Link to post
Share on other sites

Thank you Matthew for the instructions.

All is working fine.


Alternatively you could put

(ql:quickload "quicklisp-slime-helper")

into the 'Quicklisp Start.lisp' file which you find in the Opusmodus/Extension folder.

This way all you need to do is to start Opusmodus then Emacs and finally type M-x slime-connect

Link to post
Share on other sites
  • opmo pinned this topic

With the setup above, Opusmodus also works from within Org Babel (http://orgmode.org/org.html#Working-with-source-code) -- in case anyone of you wants to do Literate Programming with Opusmodus :)  I like using Emacs Orgmode for writing documentation, papers, slides for classes etc., and having code "live" in your text is great. 




Link to post
Share on other sites

Using Opusmodus with autocompletion is fun:



Emacs auto-complete plugin for Slime symbols. Contribute to purcell/ac-slime development by creating an account on GitHub.


After installing (simply with M-x package-list-packages, and then selecting ac-slime) and configuring it as described at the website link above, I additionally enforced that autocompletion is loaded whenever I load a Lisp file in Emacs with the following line in my .emacs file. 


(add-hook 'lisp-mode-hook (function (lambda () (auto-complete-mode 1))))





Screen Shot 2017-08-26 at 15.40.55.png

Link to post
Share on other sites

Slime provides convenient ways to access documentation, e.g., by calling describe with a shortcut (^C ^D ^D). However, for some reason calling describe on functions and variables in Clozure CL (the Lisp compiler of Opusmodus) does not show their actual documentation string (other Lisp compilers include such information).


So, I added that myself. If you use the Emacs+Slime interface for Opusmodus, consider putting the definitions below in a file that is automatically loaded by Opusmodus (e.g., any file in ~/Opusmodus/Extensions/). 





;;; Extend describe output 
(defmethod describe-object :after ((thing symbol) stream)
  "Add documentation string of functions and variables at end of describe output."
  (declare (ignore stream))
  (let ((fbound (fboundp thing)))
    (when fbound
      (let ((doc (ccl::%get-documentation fbound t)))
        (when doc
          (format T "DOCUMENTATION:~%")
          (format T doc)))))
  (when (boundp thing)
    (format T "DOCUMENTATION:~%")
    (format T (ccl::%get-documentation thing 'variable)))

(defmethod describe-object :after ((thing function) stream)
  (declare (ignore stream))
  (format T (ccl::%get-documentation thing t)))


Link to post
Share on other sites
On 8/26/2017 at 3:51 PM, torstenanders said:

No -- no extra setup required, only the setup above. Then you can open an Org file with Common Lisp snippets and evaluate them as explained in the Org mode doc.





Edit: The setup can be improved by adding the following line to your ~/.emacs file. Without this added setting, you can evaluated Lisp in an Org buffer Lisp code block when opening the code block in Lisp mode (C-c '). With the addition, you can also evaluated the code blocks directly in the Org buffer with C-c C-c.

(require 'ob-lisp)



 - Start Opusmodus and Emacs and get them talking to each other as explained above

 - Open/create an Org file in Emacs and add a Lisp code block, e.g., the following

#+begin_src lisp
(+ 1 2)


 - Evaluate this code block by moving the cursor somewhere inside and then press C-c C-c -- the result is added to the buffer.

 - Open this code block by moving the cursor somewhere inside and then press C-c ' -- a temporary buffer in Lisp mode with the code is shown, with all bells and whistles of the Emacs Lisp environment you set up


For more information on code blocks, how to export them, communication between code block, the various customisations etc. see the Org manual:



Org: an Emacs Mode for Notes, Planning, and Authoring





Link to post
Share on other sites
  • opmo unpinned this topic
  • opmo pinned this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Terms of Use Privacy Policy