Marek Kubica <ma...@xivilization.net> writes: > What about "the same directory that the file is in"? The point is, when > writing scripts that become larger than one file, splitting them into > modules becomes immensely painful because the modules cannot find each > other.
I agree that this is a bit awkward. My current solution is (load "setup-load-path.scm") at the start of each top-level script - which relies on the fact that `load' will look in the same directory as the script file - with setup-load-path.scm containing: (cond-expand (guile-2 (eval-when (load compile) (let* ((bindir (dirname (car (command-line)))) (absdir (cond ((string=? bindir ".") (getcwd)) ((string-match "^/" bindir) bindir) (else (in-vicinity (getcwd) bindir))))) (set! %load-path (cons (in-vicinity absdir "..") %load-path))))) (else (let* ((bindir (dirname (car (command-line)))) (absdir (cond ((string=? bindir ".") (getcwd)) ((string-match "^/" bindir) bindir) (else (in-vicinity (getcwd) bindir))))) (set! %load-path (cons (in-vicinity absdir "..") %load-path))))) This has the effect of adding the parent of the script-containing directory to the load path. Part of the complexity is supporting both 1.8 and 1.9/2.0. For 1.9/2.0 support only, I believe it could be simplified by changing `load' to `include', and retaining only the body of the `eval-when'. Regards, Neil