Reputation: 178
Is there a way to launch Emacs from terminal and execute some Emacs command automatically soon after Emacs is launched (the command to be executed inside of emacs is provided along with the Emacs-launching command executed from the shell.)
What I want to do exactly is to have a command to launch Emacs and then open a new empty buffer and activate org mode inside of this buffer. I want something that might look like this
emacs -fs --command="evil-buffer-new && org-mode"
I want the -fs
flag because I want Emacs to open in full-screen in this case.
--eval
flag didn't work. Forget about evil-buffer-new
, I have tried something as simple as:
emacs --eval="(org-mode)" txt.txt
txt.txt
is an empty text file created before executing the above command (and please don't ask me why I didn't use .org
file extension).
after Emacs opened, org-mode wasn't active. I had to run pp-eval-expression
then (org-mode)
to activate it, and then it worked.
Am I missing something here? How about rephrasing the question like this:
How to open an empty text file (having .txt
file extension) with Emacs from the terminal and have org-mode activated in that buffer automatically?
Upvotes: 0
Views: 674
Reputation: 10648
You told an empty file is created before emacs is started. But instead of an empty file could you create a file with file-local mode variable specifying the org mode ? For example with bash:
#!/bin/bash
cat <<EOF >> "$1"
; -*- mode: Org;-*-
EOF
emacs "$1" &
Now the mode is always resolved correctly with normal major mode selection procedure.
Upvotes: 0
Reputation: 73274
See C-hig (emacs)Action Arguments
or even just run emacs --help
-- there are several options for loading and evaluating arbitrary code.
--command="evil-buffer-new && org-mode"
More like:
--eval="(progn (evil-buffer-new) (org-mode))"
But you'll have to figure it out for yourself, because I don't know what evil-buffer-new
is specifically.
Upvotes: 1