I'd like to create a Emacs Lisp macro that is able to generate a string literal that contains the name of the .el file into which the macro is expanded. Is this possible?
I am writing a Elisp macro that generate one or several defun forms. Some may be inside conditional forms (if or conditions or whatever) and the macro being expanded may also be inside a conditional block form.
Assuming I have the following code inside a file called
(when some-condition (my-macro lisp arg1 arg2))
I'd like to be able to write a defmacro form that would be able to determine that it is being expanded inside
my-file.el and would be able to generate the string literal "my-file". Something like:
(when some-condition (defun my-lisp-function (some-arg arg1) (some-code-here arg1 whatever)) (declare-function my-lisp-function "my-file") ;; (some-other-code etc etc) ;; (my-lisp-function arg2))
In the example above I'm using the file name string literal inside a declare-function form to prevent the byte-compiler from complaining about the generated my-lisp-function not being defined. And at the same time allow the check-declare package to verify the existence of the function.
I tried to use the variable
byte-compile-current-file from bytecomp.el by accessing it in the non-generated portion of the macro, but that did not work.