unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* add-relative-load-path ?
@ 2012-01-08 15:14 Andy Wingo
  2012-01-14 21:48 ` Neil Jerram
  2012-01-30 20:20 ` add-relative-load-path ? - scm_add_load_path too? Ian Hulin
  0 siblings, 2 replies; 17+ messages in thread
From: Andy Wingo @ 2012-01-08 15:14 UTC (permalink / raw)
  To: guile-devel

Hi all,

In the following thread:

  http://thread.gmane.org/gmane.lisp.guile.user/8298/focus=8403

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 name")))
                 (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?

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-02-01 23:30 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-08 15:14 add-relative-load-path ? Andy Wingo
2012-01-14 21:48 ` Neil Jerram
2012-01-20 23:14   ` Andy Wingo
2012-01-21 23:17     ` Neil Jerram
2012-01-23 10:18       ` Andy Wingo
2012-01-23 15:45         ` Ludovic Courtès
2012-01-23 16:20           ` Andy Wingo
2012-01-23 19:36             ` Neil Jerram
2012-01-25 12:42             ` Ludovic Courtès
2012-01-25 14:31               ` Andy Wingo
2012-01-25 20:41                 ` Ludovic Courtès
2012-01-25 23:08                   ` Andy Wingo
2012-01-23 20:19         ` Neil Jerram
2012-01-30 20:20 ` add-relative-load-path ? - scm_add_load_path too? Ian Hulin
2012-01-31  8:53   ` Mark H Weaver
2012-01-31 16:10     ` Mark H Weaver
2012-02-01 23:30       ` Ian Hulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).