[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

add-relative-load-path ?

From: Andy Wingo
Subject: add-relative-load-path ?
Date: Sun, 08 Jan 2012 16:14:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Hi all,

In the following thread:

there was a concern that it's difficult to set up the load path for
simple one-off scripts.

I had a proposal that we add something like this:

   (define-syntax add-relative-load-path
     (lambda (x)
       (syntax-case x ()
         ((_ path) (string? (syntax->datum #'path))
          (let* ((src (syntax-source #'x))
                 (current-file (or (and src (assq-ref src 'filename))
                                   (error "Could not determine current file 
                 (vicinity (dirname (canonicalize-path current-file)))
                 (path-elt (in-vicinity vicinity (syntax->datum #'path))))
            #`(eval-when (compile load eval)
                (set! %load-path (cons #,path-elt %load-path))))))))

Then in your script you would (add-relative-load-path ".").

Maybe we need an `add-to-load-path' form that handles the eval-when,
actually, so it would be

  (add-to-load-path (dirname (current-source-filename)))

or something like that.  (We'd have to define current-source-filename as
well, in terms of current-source-location.)

What do folks think?  Is it work it?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]