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 -S
requires the-S
flag. Without it,env
would treatemacs -Q --script
as a single command rather than separate command and arguments. - The
-Q
flag foremacs
ensures it starts without loading any user configuration files, providing a clean slate. - The
--script
flag tellsemacs
to 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!