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 127.0.0.1) 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")
(cl-user::start-swank)

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. 

 

Torsten

 

Link to post
Share on other sites

Using Opusmodus with autocompletion is fun:

 

5636?s=400&v=4
GITHUB.COM

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))))

 

Best,

Torsten

 

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/). 

 

Best,

Torsten

 

;;; 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.

 

Best,

Torsten

 

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)

 

Example:

 - 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)
#+end_src

 

 - 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:

 

ORGMODE.ORG

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

 

Best,

Torsten

 

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.

Guest
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.

  • Similar Topics

    • By opmo
      2.1.25893
       
      – Addition:
      COUNTERPOINT - methods on bars and events.
    • By opmo
      2.1.25892
       
      – Fixed:
      Stop playback with <Cmd>-<Escape>, will no longer append MIDI entry input as if you were in a chord or the sustain pedal was down.
       
      – Changes:
      Revised attributes list entry.
      Pitch-Bend Down-Half is now assign to attributes.
      Pitch-Bend Up-Half is now assign to velocities.
       
      – Documentation
      Revised MIDI Entry document.
       

       
      Best wishes,
      Janusz
    • By torstenanders
      Opusmodus 1.2 can be used from within the Emacs editor as well (see the post at the link below for details). For me as a programmer having additionally access to the Emacs Lisp IDE SLIME is greatly preferable due to various advanced features provided by Slime when compared with the more easy-to-use native IDE of Opusmodus. 
       
      For more information on SLIME see its website:
      https://common-lisp.net/project/slime
       
      Unfortunately, the SLIME link is seemingly broken in Opusmodus 1.3, which I just started for the first time. For those who have no SLIME installed (but have Quicklisp set up), SLIME can be installed with the following command.
      (ql:quickload "quicklisp-slime-helper")  
      Unfortunately, this results now in an error.
       
      To load "quicklisp-slime-helper":   Load 1 ASDF system:     quicklisp-slime-helper ; Loading "quicklisp-slime-helper" .. > Error: Undefined function asdf/interface::operation-forced called with arguments (#<load-op>) . > While executing: #<standard-method asdf/action:perform (asdf/lisp-action:load-op swank-loader::swank-loader-file)>, in process Listener-2(9). > Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts. > If continued: Retry applying asdf/interface::operation-forced to (#<load-op>). > Type :? for other options.
      I already had SLIME installed, but simply running it does not work either and results in the same error.
      (cl-user::start-swank)  ? To load "swank":   Load 1 ASDF system:     swank ; Loading "swank" . > Error: Undefined function asdf/interface::operation-forced called with arguments (#<load-op>) . > While executing: #<standard-method asdf/action:perform (asdf/lisp-action:load-op swank-loader::swank-loader-file)>, in process Listener-2(9). > Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts. > If continued: Retry applying asdf/interface::operation-forced to (#<load-op>). > Type :? for other options.  
      Any help? Thanks a lot! 
       
      Best,
      Torsten
×
×
  • Create New...