Skip to main content
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 ...
dmg's user avatar
  • 669
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 ...
David Antaramian's user avatar
8 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's user avatar
  • 33.2k
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-...
Justin Abrahms's user avatar
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 ...
Raydot's user avatar
  • 186
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 ...
Roman Grazhdan's user avatar
6 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 ...
tarsius's user avatar
  • 25.8k
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 --...
shoshin's user avatar
  • 914
6 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 ...
J C Gonzalez's user avatar
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 ...
Tyler's user avatar
  • 22.4k
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 ...
xuchunyang's user avatar
  • 14.6k
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/...
ghoetker's user avatar
4 votes
Accepted

Update spacemacs packages from the command line

I ended up with the following: emacs --daemon -f configuration-layer/update-packages
Sid Raval's user avatar
  • 191
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, ...
Thomas Schietinger's user avatar
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* ...
Stefan's user avatar
  • 26.5k
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 ...
sds's user avatar
  • 6,134
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 ...
Gilles 'SO- stop being evil''s user avatar
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-...
yPhil's user avatar
  • 983
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 ...
David Robért's user avatar
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. "...
rpluim's user avatar
  • 5,365
3 votes
Accepted

How to setq a variable for a script in the command line?

The immediate cause is that the --script file is loaded before --eval expressions. (--eval expressions, --funcall calls and --load files are evaluated in the order they appear on the command line.) % ...
Gilles 'SO- stop being evil''s user avatar
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 ...
Tianxiang Xiong's user avatar
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 ...
phils's user avatar
  • 51.8k
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 ...
Drainful's user avatar
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....
Melioratus's user avatar
  • 4,688
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: ...
1u1u's user avatar
  • 21
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 ...
phils's user avatar
  • 51.8k
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 ...
NickD's user avatar
  • 31.4k
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 ...
Gilles 'SO- stop being evil''s user avatar
2 votes
Accepted

How can I start emacs in "headless" mode?

In general, you can invoke Emacs with the --batch flag and pass Elisp code to evaluate using either --eval (-e) if you have an expression you'd like to evaluate, such as (package-install 'foo) or you ...
Philip K.'s user avatar
  • 156

Only top scored, non community-wiki answers of a minimum length are eligible