Creating universal Emacs Lisp packages and scripts
source : Creating universal Emacs Lisp packages and scripts | DanPetrov
Notes
You can add a [[shebang]] to the top of an [[Emacs Lisp]] script to have it evaluated in batch mode:
#!/usr/bin/env emacs --script
Secondly, you can determine if a script is running in batch mode with the following predicate:
(defun foo-running-as-script-p ()
"Return truthy if running as Elisp script."
(member "-scriptload" command-line-args))
Finally, itβs worth adding some kind of βmainβ function:
(defun main ()
"Entrypoint for foo"
(pprint command-line-args-left)
(message "Do stuff here"))
(when (foo-running-as-script-p)
(main))
Refs
Loading context... (requires JavaScript)
ποΈ Stoas for [[creating universal emacs lisp packages and scripts]]
π Open document (Hedgedoc) at https://doc.anagora.org/creating-universal-emacs-lisp-packages-and-scripts
π Open document (Etherpad) at https://stoa.anagora.org/p/creating-universal-emacs-lisp-packages-and-scripts
πΉ Video conferencing space (Jitsi Meet) at https://meet.jit.si/creating-universal-emacs-lisp-packages-and-scripts
π Full text search for [[creating universal emacs lisp packages and scripts]]