I hope someone can help me with a few things I'm confused on. I've trying to write a slime contrib (for the first time).
I have already written the common-lisp function which works fine. But I want to write the elisp front-end to this function. The elisp function should get the symbol at the point create a temporary file name, then it should call the common lisp function passing those two arguments. After the CL function returns, emacs should open the file named by the tmp file name.
There are several issues I'm not sure how to answer.
1. the symbol at the point has an implicit package name, I want the CL function to receive the correct symbol. E.g. suppose the symbol is xyzzy which is CL parses as abc::xyzzy (because if an in-package earlier in the file), I want the CL function called with 'abc::xyzzy not with 'CL::xyzzy.
2. If I try to call the CL function using slime-eval with a string, then CL understand the correct symbol, but slime-eval returns t before the CL function returns, and when I call find-file, the file is not ready to open yet.
3. If I try to call the CL function with slime-eval-async, then the CL function receives the wrong symbol: CL::xyzzy rather than abc::xyzzy.
4. I would like to put the .lisp file also in the contrib directory, but the CL code depends on c2mop. Does this pose a problem? What do I need to assure that if a user loads the file that c2mop has already been loaded? I.e., is there an asd file I need to create or modify?
If someone could point me in the right direction, it would be great.
BTW here is the elisp function as I currently have it.
(defun class-graph (class-name) (interactive "P") (let* ((class-name (or class-name (slime-symbol-at-point))) (tmp-file (make-temp-file (format "%s-" class-name) nil ".png"))) (cond ((slime-eval (format "(class-graph:class-graph-for-slime '%s %S)" class-name tmp-file)) ;; this does not work, becasue tmp-file is not ready as class-graph-for-slime has not yet finished. (find-file tmp-file) (image-mode-fit-frame)) (t (error "failed to create graph in %s" tmp-file)))))
Hi Jim,
I would say that using `slime-eval' with a string won't work: you're asking CL to evaluate a string, which it complies with happily, but won't actually call the function. That's why it returns immediately (shound't return t, though).
The solution is to stick with passing an actual symbolic expression, and, to fix your symbol problem, pass the result of `slime-symbol-at-point' as a quoted string ("%S" I believe). Then, in the CL side, pass it to the function
SWANK:FIND-DEFINITIONS-FIND-SYMBOL-OR-PACKAGE
which should "do the right thing" and return the symbol interned in the correct package be it the qualifier package, or the one implicit in `in-package`.
Regarding problem 4, you need a system that lets you create contribs that are fully independent of SLIME which SLIME doesn't provide afaik, but my fork of it, SLY, does. See http://github.com/capitaomorte/sly if you're interested.
I'm interested in this contrib, can you share the code you have for the CL side as well?
João