Quesstion about Alt-. navigation to function definitions

Zach Beane xach at xach.com
Wed Oct 30 23:06:34 UTC 2013


Jeffrey Cunningham <jeffrey at jkcunningham.com> writes:

> On 10/30/2013 02:22 PM, Christophe Rhodes wrote:
>> As I have said in other mails, this is not the normal way of using
>> the system. Using REQUIRE in source files is unusual; so too is not
>> having the depended-on systems already compiled, which perhaps
>> explains why it's taken this long just to understand your
>> problem. (In general triggering a file compilation from within LOAD
>> or COMPILE-FILE is hazardous; it doesn't completely surprise me that
>> not everything is actually totally correct). You would make your
>> life easier by writing your own defsystem forms which declare the
>> relevant dependencies on other systems. Christophe 
>
>
> Okay, I tried the following in a new source file test2.lisp with a
> fresh emacs and slime environment.
>
> (asdf:defsystem #:test2 :depends-on (:cl-ppcre)))
> (asdf:load-system "test2")
> (describe 'cl-ppcre:regex-apropos)
>
>
> I compiled each of these lines with C-c C-c. The behavior is the same
> as before:
>
> Source file: /home/jcunningham/slime/test1.lisp
>
> If I am not implementing this in the "normal" way of using the system,
> perhaps you could give me some guidance here. What is the minimal code
> I need to write in a file so I can load, say, cl-ppcre, write a line
> of code that calls one of its functions, and allows me to navigate to
> it by Alt-. ?
>
> I thought I was doing it the normal way.

That code should go in test2.asd:

    ;;;; test2.asd

    (asdf:defsystem #:test2
      :depends-on (#:cl-ppcre)
      :serial t
      :components ((:file "package")
                   (:file "test2")))

Then you have package.lisp:

    (defpackage #:test2
      (:use #:cl)
      (:export #:my-great-test))

Then you can put this in test2.lisp:

   ;;;; test2.lisp

   (in-package #:test2)

   (defun my-great-test ()
     (describe 'cl-ppcre:regex-apropos))

Put those files somewhere ASDF knows about. I like to put it in
something like ~/quicklisp/local-projects/test2/, so you can, from the
repl, use this:

    (ql:quickload "test2")

Then you should be able to evaluate, in the REPL:

    (test2:my-great-test)

Many people automate the process of setting up project directories,
system files, and initial sources. My automation of it is the
quickproject utility; there are several others.

I don't recommend putting calls to code-loading functions directly in
source files, most of the time.

Zach



More information about the slime-devel mailing list