Post by d***@gmail.comPost by GenePost by d***@gmail.comIf you're writing an elisp script using the "#!/usr/bin/emacs --script" hashbang, is there a way to get the name of the script that's running? I'm looking for an analog of perl's $0 variable.
(eww "https://www.gnu.org/software/emacs/manual/html_node/elisp/Command_002dLine-Arguments.html")
#!/usr/bin/emacs --script
(setq script-file-name (nth 2 command-line-args))
Hm... actually that does literally what I asked, but it isn't quite what I want. That's a good way to get code behavior that differs when run from the command line or when executed inside of emacs, but if you'd like the code to know it's file name when run in either context, it's not so useful.
So, I guess really, I'm looking for something like an analog of perl's FindBin.
Or to put it another way: do defuns know what file they were defined inside of?