Common Lisp: How do i use swank functions in a library

Discussion of Common Lisp

Common Lisp: How do i use swank functions in a library

Postby joeish80829 » Fri Oct 18, 2013 3:39 am

(I use SLIME/SBCL/Emacs and Quicklisp on Ubuntu Raring) i have the function defined below i would like to add to my lisp library's top .lisp file the one every other one depends on, so i can use it in all the functions i write with my library by just adding (update-swank) to a function instead of having to add the entire funtion below to each piece of code that uses it.

Code: Select all
(defun update-swank ()
   "Grabs SWANK connections and tells it to handle requests.
    Call this every loop in the main loop of your program"
   (continuable
     (let ((connection (or swank::*emacs-connection*
               (swank::default-connection))))
       (when connection
     (swank::handle-requests connection t)))))


but when i do and restart emacs loading my library in the process because i have the asdf:load-op in my .sbclrc file (I am using slime/sbcl on ubuntu raring) i get a

Code: Select all
READ error during COMPILE-FILE:
;   
   ;     Package SWANK does not exist.

in inferior lisp, and slime is stuck polling because the library doesnt load because in my current setup slime/sbcl doesnt know what swank is at the time the .lisp file that update-swank is in is loaded. i tried adding '(in-package :swank)' to that file that update-swank is in but get
Code: Select all
The name "SWANK" does not designate any package.


in inferior lisp when my library is loaded at emacs startup.

I searched through CEPL (where i got update-swank from https://github.com/cbaggers/cepl/blob/m ... utils.lisp) and then copied what the creator of CEPL did and exported the function in my packages.lisp. I made sure the function was added like he did on line 20 of cepl-utils here https://github.com/cbaggers/cepl/blob/m ... isp......I load my library btw with
Code: Select all
(asdf:operate 'asdf:load-op :cl-test)
(in-package #:cl-test)


in my .sbclrc file which i assume is loaded before my .emacs file loads slime at emacs start up (i have (slime) in my .emacs file) ...I just tested removing the adsf:load-op and in-package and from my .sbclrc and running the asdf:load-op after slime/swank has been loaded and what i've been trying to do here worked with no error....but i would like to be able load my library automatically at emacs startup and the way i usually do that is by adding the asdf:load-op to my .sbclrc....If someone could tell me another way to load my library automatically at emacs startup after swank has been loaded that would answer this ?...BTW Thanks Baggers for all your prompt responses the last couple of days
joeish80829
 
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am

Re: Common Lisp: How do i use swank functions in a library

Postby pjstirling » Tue Oct 22, 2013 6:22 am

From the emacs buff *inferior-lisp*

Code: Select all
(progn
  (load "/PATH/TO/slime/swank-loader.lisp" :verbose t)
  (funcall (read-from-string "swank-loader:init"))
  (funcall (read-from-string "swank:start-server") "/tmp/slime.6119"))
pjstirling
 
Posts: 79
Joined: Sun Nov 28, 2010 4:21 pm


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

cron