Skip to content

Instantly share code, notes, and snippets.

@DaniruKun
Created January 15, 2022 17:29
Show Gist options
  • Save DaniruKun/2af40cb1fe8ee5bac82b281f1102820d to your computer and use it in GitHub Desktop.
Save DaniruKun/2af40cb1fe8ee5bac82b281f1102820d to your computer and use it in GitHub Desktop.
Example of a universal Emacs Package script
#!/usr/bin/env emacs --script
;;; foo.el --- Foo development and productivity utils -*- lexical-binding: t; -*-
;;;;; Commands
;;;###autoload
(defun bar ()
"Print foo bar."
(interactive)
(message "Foo Bar!"))
;;;; CLI
(defun foo-running-as-script-p ()
"Return truthy if running as Elisp script."
(member "-scriptload" command-line-args))
(defun main ()
"Entrypoint for foo"
(pprint command-line-args-left)
(message "Do stuff here"))
(when (foo-running-as-script-p)
(main))
(provide 'foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment