15
votes
Accepted
emacs --eval of multiple functions on command line
Simply use (progn ). This should address your question:
emacs --eval "(progn (toggle-frame-maximized) (sr-speedbar-toggle))"
Please note that this does not execute the commands simultaneously (as ...
10
votes
Update spacemacs packages from the command line
Instead of trying to start emacs in daemon mode first and asking it to execute the package update, I'd recommend doing that after performing a scripted upgrade of the packages. To update the packages ...
9
votes
Accepted
What is the difference between --load vs --script options?
See the documentation within emacs for more information.
The --script FILE option runs emacs in batch mode (See below to know more about this mode) and executes the code in the FILE.
This option ...
7
votes
Accepted
How to run emacs function from the shell
This should do what you want. If you don't have the file open, you may need to replace the switch-to-buffer function to something that opens the file.
emacsclient -e '(progn (switch-to-buffer "my-...
7
votes
Accepted
Run elisp from command line in running emacs
You can either wrap your two forms in a progn:
emacsclient --no-wait --eval '(progn (message "hi") (setq abc 123))'
Or you can send them separately:
emacsclient --no-wait --eval '(message "hi")' '(...

Dan♦
- 32.7k
7
votes
Accepted
How do you run Emacs on mac?
Just to expand on @ghoetker's answer:
Install Emacs into your application folder from https://emacsformacosx.com/
Using the terminal, open the file ~/.zshrc in your favorite text editor.
Somewhere ...
6
votes
Accepted
Why won't `emacs -nw -f org-mode foo` open `foo` in `org-mode`?
I was able to do it by switching the order around
emacs -nw foo -f org-mode
After reading the help, if the function is a command, it is just like pressing a key command to do it. There's also the --...
6
votes
Accepted
How to execute named code blocks written in any language using a shell script?
In you progn, you do load org-babel, but don't load any extra languages:
http://orgmode.org/worg/org-contrib/babel/languages.html#configure
It does work in your regular Emacs session because these ...
5
votes
Launch emacs with ediff-files (of ediff-directories) from command line
I use the following script: it checks in advance if there are differences, and in case there are, it opens Emacs with the appropriate function evaluated. With the -d option, it assumes the items ...
5
votes
Accepted
emacsclient directly start eshell command command line
Surprisingly (at least to me), the -f flag means different things to emacs and emacsclient. To emacs, it means:
-f FUNCTION
--funcall=FUNCTION
Call Lisp function FUNCTION. If it is an ...
5
votes
Accepted
Set an Elisp var on the command line and read it in the init file
This doesn't work because command line options are processed after the init file. This allows the command line to refer to functions and variables defined or loaded in the init file, and allows the ...
5
votes
Accepted
Cannot get Magit to show the commit signatures in the log
The --show-signature argument can be selected in the log popup but it is not actually passed to git log. Instead %G? is added to the value of the --format= argument.
That (%G?) causes some letter to ...
4
votes
Accepted
Update spacemacs packages from the command line
I ended up with the following:
emacs --daemon -f configuration-layer/update-packages
4
votes
How do you run Emacs on mac?
Yes. An alias to the binary within Emacs.app is useful and will allow to call an up-to-date version of emacs from the terminal via “emacs”. I have the following set up
alias emacs='$(/Applications/...
4
votes
How do you run Emacs on mac?
Applying Dave Kanter's recipe, I still run into trouble:
"Emacs" can't be opened because Apple cannot check it for malicious software.
To get it to run, I had to open Settings, Settings, ...
4
votes
Accepted
How to activate diff-mode from command line?
Command line arguments are processed in-order. So your -f diff-mode will put into diff-mode whichever buffer happens to be current right after Emacs has started (most likely it will be the *scratch* ...
3
votes
Accepted
How can I set command-line parameters through `.emacs` file?
You can modify the command line arguments in an init file if you want. But if you do that after Emacs has processed the argument, it won't have any effect.
Emacs processes command line arguments in ...
3
votes
Set an Elisp var on the command line and read it in the init file
I found a hackish way: I start Emacs like this:
# emacs -alt
Then in my init file:
(if (member "-alt" command-line-args)
(let ((default-directory "~/src/elisp-test/"))
(normal-top-level-...
3
votes
Accepted
Pretty print s expressions from the command line
I think you should be able to do something like this:
emacsclient -e '(pp (with-temp-buffer (insert-file-contents "my-file-containing sexp") (read (current-buffer))))'
The problem is that this will ...
3
votes
How do you run Emacs on mac?
I initially used:
alias emacs='$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@")'
allowing me to open Emacs from terminal but not in it even if I used emacs -nw
After finding I couldn't ...
3
votes
Accepted
Invoke emacsclient with a smaller font
The -F flag takes an alist (short for association list), which is a list where each element is a cons cell of the form (parameter . value). One of the available parameters is font, so to specify e.g. "...
2
votes
Emacsclient not focusing if called with --eval argument from terminal
New windows not getting focus seems to be an issue with the OS/window manager, not Emacs.
There are a lot of search results suggesting various hacks at either the Emacs or OS level, but my preferred ...
2
votes
How can I set command-line parameters through `.emacs` file?
Is it possible to set Emacs start-up command-line flags such as -nw and -q in an init file? If it is, how can I do that?
In general, no, you can't do that -- and your second example option is ...
2
votes
Accepted
How to make `emacs` shell command switch to existing emacs process, if it exists?
First you should run (server-start) within emacs. This can be put in your init file.
The command you are looking for is emacsclient --no-wait --alternate-editor=emacs. You can put this behind an ...
2
votes
Accepted
How to call org-lint against org-mode file from command-line
Calling org-lint against org-mode file from command-line
Create an org-mode file
For example, create a new file named org-lint-ex1.org
* Using =org-lint= to Check org-mode Syntax
** Inside emacs
1....
2
votes
Set an Elisp var on the command line and read it in the init file
As I did not get the top voted answer to work (I suppose I have to write additional code to read out the defvar variable) I use environment variables
First I did create a wrapper batch or bash file:
...
2
votes
Accepted
How to send quoted argument to call-process
I would like to run convert - -draw 'rectangle 0,0,100,100' -
Note that you're quoting for the shell there, so that it will not break that argument into two, on account of the space.
For example I ...
2
votes
Accepted
How can I run a subprocess with emacs --script
Basically, Emacs exits before the subprocess has exited. All you have to do is delay the exit until the subprocess has exited. Since Emacs does not have anything useful to do, you can have it sleep ...
2
votes
Accepted
Is there a way to get the name of the current file being opened?
Several variables contain the command line arguments (“arguments” includes both options and file names), in particular command-line-args-left which contains the arguments that haven't been processed ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
command-line-arguments × 55start-up × 10
emacsclient × 8
org-mode × 4
init-file × 3
buffers × 3
major-mode × 3
git × 3
invocation × 3
spacemacs × 2
magit × 2
python × 2
osx × 2
frames × 2
fonts × 2
files × 2
customize × 2
emacs-daemon × 2
server × 2
eval × 2
eval-expression × 2
org-babel × 1
elisp × 1
window × 1
shell × 1