Running Emacs Lisp Scripts
Take a look at this script (hello.el):
#!/usr/bin/env -S emacs -Q --script
(message "Hello, Emacs!")
- The first line
#!/usr/bin/env -Srequires the-Sflag. Without it,envwould treatemacs -Q --scriptas a single command rather than separate command and arguments. - The
-Qflag foremacsensures it starts without loading any user configuration files, providing a clean slate. - The
--scriptflag tellsemacsto execute the script. If running directly from the command line, you would useemacs -Q --script hello.el.
Execution result of the above script:
Hello, Emacs!