Getting the source file pathname
Chaitanya Gupta <[email protected]> Sun, 10 Dec 2017 00:34:02 +0530
| Newsgroups | gmane.lisp.slime.devel |
|---|---|
| Message-ID | <CANOhSryvqDrCZrBw2ttkqsJtpRefRMSUCx-AOeefcXJZM7h2vA@mail.gmail.com> |
Hi,
I need the path of the source file from which a particular form is
loaded (similar to __FILE__ in C). Currently I have the following
macros in place:
(defmacro source-pathname ()
(let ((compile-file-pathname *compile-file-pathname*))
`(or ,compile-file-pathname (load-time-value *load-pathname*))))
(defmacro source-truename ()
(let ((compile-file-truename *compile-file-truename*))
`(or ,compile-file-truename (load-time-value *load-truename*))))
(defmacro source-directory ()
`(make-pathname :defaults (source-truename)
:name nil :type nil))
This works fine when I use (LOAD ...), (LOAD (COMPILE-FILE ...)),
slime-load-file or slime-compile-and-load-file.
However it fails when I use slime-compile-defun, slime-eval-defun or
slime-eval-last-expression. Shouldn't slime bind
*compile-file-pathname*, *load-pathname*, etc. when these functions
are run?
Thanks,
Chaitanya