Passing arguments to elisp script. Again

后端 未结 4 1994
自闭症患者
自闭症患者 2020-12-21 08:31

How can I pass arguments -q -d -Q -t -L -fg -bg --color etc?

Doing something like emacs --script -Q definetely wil

4条回答
  •  悲&欢浪女
    2020-12-21 08:58

    If you run emacs in script mode, I would recommend to reset "argv" variable to nil in the end of your script, otherwise emacs will try interpret "argv" after script is finished.

    Let's assuming you have a file named "test-emacs-script.el" with the following content:

    #!/usr/bin/emacs --script
    (print argv)
    (setq argv nil)
    

    Try running this script as "./test-emacs-script.el -a". If you run this script without resettings "argv" (last line in the script) then the output will be:

    ("-a")
    Unknown option `-a'
    

    Resetting "argv" gets rid of "unknown option" error message

提交回复
热议问题