mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 14:21:10 +02:00
current-filename canonicalizes path, remove add-to-path
* module/ice-9/boot-9.scm (current-filename): Canonicalize the path, so that the result is independent of the current directory, and so that `dirname' can traverse up the file system, as in the add-to-load-path example. (add-to-path): Remove. The eval-when semantics make this macro too tricky to explain -- people will start using it on other path-like things, in lexical contours, whereas it only really makes sense with load-like paths at the toplevel. * doc/ref/api-evaluation.texi (Loading): Fix link to load-with-path docs, and remove add-to-path docs.
This commit is contained in:
parent
73c080f9c0
commit
21ad60a1d2
2 changed files with 5 additions and 16 deletions
|
@ -781,7 +781,7 @@ change occurs at the right time.
|
||||||
A procedure to be called @code{(%load-hook @var{filename})} whenever a
|
A procedure to be called @code{(%load-hook @var{filename})} whenever a
|
||||||
file is loaded, or @code{#f} for no such call. @code{%load-hook} is
|
file is loaded, or @code{#f} for no such call. @code{%load-hook} is
|
||||||
used by all of the loading functions (@code{load} and
|
used by all of the loading functions (@code{load} and
|
||||||
@code{primitive-load}, and @code{load-path} and
|
@code{primitive-load}, and @code{load-from-path} and
|
||||||
@code{primitive-load-path} documented in the next section).
|
@code{primitive-load-path} documented in the next section).
|
||||||
|
|
||||||
For example an application can set this to show what's loaded,
|
For example an application can set this to show what's loaded,
|
||||||
|
@ -832,13 +832,6 @@ It's better to use @code{add-to-load-path} than to modify
|
||||||
@code{%load-path} directly, because @code{add-to-load-path} takes care
|
@code{%load-path} directly, because @code{add-to-load-path} takes care
|
||||||
of modifying the path both at compile-time and at run-time.
|
of modifying the path both at compile-time and at run-time.
|
||||||
|
|
||||||
There is a more general version for use with other paths, like
|
|
||||||
@code{%load-compiled-path}:
|
|
||||||
|
|
||||||
@deffn {Scheme Syntax} add-to-path path dir
|
|
||||||
Add @var{dir} to @var{path}.
|
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@deffn {Scheme Procedure} primitive-load-path filename [exception-on-not-found]
|
@deffn {Scheme Procedure} primitive-load-path filename [exception-on-not-found]
|
||||||
@deffnx {C Function} scm_primitive_load_path (filename)
|
@deffnx {C Function} scm_primitive_load_path (filename)
|
||||||
Search @code{%load-path} for the file named @var{filename} and
|
Search @code{%load-path} for the file named @var{filename} and
|
||||||
|
|
|
@ -521,8 +521,8 @@ If there is no handler at all, Guile prints an error and then exits."
|
||||||
"A macro that expands to the current filename: the filename that
|
"A macro that expands to the current filename: the filename that
|
||||||
the (current-filename) form appears in. Expands to #f if this
|
the (current-filename) form appears in. Expands to #f if this
|
||||||
information is unavailable."
|
information is unavailable."
|
||||||
(and=> (syntax-source x)
|
(false-if-exception
|
||||||
(lambda (s) (assq-ref s 'filename)))))
|
(canonicalize-path (assq-ref (syntax-source x) 'filename)))))
|
||||||
|
|
||||||
(define-syntax-rule (define-once sym val)
|
(define-syntax-rule (define-once sym val)
|
||||||
(define sym
|
(define sym
|
||||||
|
@ -1402,14 +1402,10 @@ VALUE."
|
||||||
(start-stack 'load-stack
|
(start-stack 'load-stack
|
||||||
(primitive-load-path name)))
|
(primitive-load-path name)))
|
||||||
|
|
||||||
(define-syntax-rule (add-to-path path elt)
|
|
||||||
"Add ELT to PATH, at compile-time and at run-time."
|
|
||||||
(eval-when (compile load eval)
|
|
||||||
(set! path (cons elt path))))
|
|
||||||
|
|
||||||
(define-syntax-rule (add-to-load-path elt)
|
(define-syntax-rule (add-to-load-path elt)
|
||||||
"Add ELT to Guile's load path, at compile-time and at run-time."
|
"Add ELT to Guile's load path, at compile-time and at run-time."
|
||||||
(add-to-path %load-path elt))
|
(eval-when (compile load eval)
|
||||||
|
(set! %load-path (cons elt %load-path))))
|
||||||
|
|
||||||
(define %load-verbosely #f)
|
(define %load-verbosely #f)
|
||||||
(define (assert-load-verbosity v) (set! %load-verbosely v))
|
(define (assert-load-verbosity v) (set! %load-verbosely v))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue