• get name of script file with emacs --script?

    From doomvox@gmail.com@21:1/5 to All on Sat Mar 4 11:50:17 2017
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gene@21:1/5 to doo...@gmail.com on Sun Mar 5 17:36:25 2017
    On Saturday, March 4, 2017 at 2:50:18 PM UTC-5, doo...@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.

    (progn ; eval this in the *scratch* buffer
    (eww "https://www.gnu.org/software/emacs/manual/html_node/elisp/Command_002dLine-Arguments.html")
    (switch-to-buffer "*eww*")
    (occur "command-line-args")
    )

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From doomvox@gmail.com@21:1/5 to Gene on Sun Mar 5 19:24:53 2017
    Gene wrote:
    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")

    Ah, thanks. Yes, this does it:

    #!/usr/bin/emacs --script
    (setq script-file-name (nth 2 command-line-args))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From doomvox@gmail.com@21:1/5 to All on Wed Mar 15 18:45:55 2017
    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))

    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From N. Jackson@21:1/5 to doomvox@gmail.com on Thu Mar 16 12:40:06 2017
    At 18:45 -0700 on Wednesday 2017-03-15, doomvox@gmail.com wrote:

    Or to put it another way: do defuns know what file they were
    defined inside of?

    Not answering your question directly, but nonetheless helpful I
    hope, `describe-function' is able to identify the file containing
    a defun, so maybe have a look at how it does this?

    N.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)