added this-expression-file-name
original commit: 106388724f571e96062423fed9ec65e9aeda3ccd
This commit is contained in:
parent
1e3fd3bb9a
commit
d3eb73d989
|
@ -36,6 +36,7 @@
|
|||
|
||||
namespace-defined?
|
||||
this-expression-source-directory
|
||||
this-expression-file-name
|
||||
define-syntax-set
|
||||
|
||||
hash-table
|
||||
|
@ -466,6 +467,14 @@
|
|||
(with-syntax ([d (if (bytes? dir) dir (path->bytes dir))])
|
||||
(syntax (bytes->path d)))))]))
|
||||
|
||||
(define-syntax (this-expression-file-name stx)
|
||||
(syntax-case stx ()
|
||||
[(_)
|
||||
(let* ([f (syntax-source stx)]
|
||||
[f (and f (string? f) (file-exists? f)
|
||||
(let-values ([(base file dir?) (split-path f)]) file))])
|
||||
(datum->syntax-object (quote-syntax here) f stx))]))
|
||||
|
||||
;; This is a macro-generating macro that wants to expand
|
||||
;; expressions used in the generated macro. So it's weird,
|
||||
;; and we put much of the work in a helper macro,
|
||||
|
|
Loading…
Reference in New Issue
Block a user