If 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.
doombox@gmail.com wrote:
If 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")
If 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")
Ah, thanks. Yes, this does it:
#!/usr/bin/emacs --script
(setq script-file-name (nth 2 command-line-args))
Or to put it another way: do defuns know what file they were
defined inside of?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 465 |
Nodes: | 16 (2 / 14) |
Uptime: | 06:12:01 |
Calls: | 9,390 |
Calls today: | 5 |
Files: | 13,565 |
Messages: | 6,096,101 |