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 you requested). It executes one command after another.
I'm pretty sure there are other solutions, but you can do this using --eval instead of -f (--funcall):
emacs --eval '(ediff-files "file1" "file2")'
In fact, the Emacs manual on "Command Line Arguments for Emacs Invocation" says that -f function and --funcall function
Call Lisp function function. If it is an interactive function (a command), it reads the ...
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 implies the -q option.
The --load=FILE loads the FILE library using the load function (and tries to find that library in load-path if FILE is not an absolute path)...
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 --file option and --find-file option, so I figured it is executing find-file when you put the filename on the command line, and would call these in order. So ...
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 non-interactively, use the following:
emacs --batch -l ~/.emacs.d/init.el --eval="(configuration-layer/update-packages t)"
The key here is the --batch switch ...
What I recommend you to try is to start Isearch first and then yank your word to the search string, effectively doing the same what you would do manually to add words in isearch-mode:
(defun my-search-word ()
(isearch-forward nil 1)
If you need to match word boundaries, then try this:
In you progn, you do load org-babel, but don't load any extra languages:
It does work in your regular Emacs session because these are obviously loaded somewhere in your init.el
So I've saved your script and edited it like this:
# -*- mode: shell-script -*-
# Call named code ...
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-presentation.org") (org-beamer-export-to-pdf))'
Here's a generic solution to eval some elisp expression after launching emacs
For your example, that will be
emacs -nw --eval="(goto-line 20)" FILE
Also check out the --load option from the below referenced link if you want to load an elisp file instead of writing elisp at command line.
Solution specific for ...
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 init file to declare additional options.
To run something before the init file, you can force a different load order:
# emacs --no-init-file --eval '(defvar ...
Arguments are deleted after being processed at startup, you can either handle them like sds specified or if you'd like the list of args given after start up, save the contents of command-line-args at the start of your init.
(setq my-save-args command-line-args)
Though if you're planning on passing custom args, you'll need to handle them during startup.
--script expands to load, see lisp/startup.el in Emacs sources:
;; This is used to handle -script. It's not clear
;; we need to document it (it is totally internal).
((member argi '("-scriptload"))
(let* ((file (command-line-normalize-file-name
(or argval (pop command-line-args-left))))
;; Take file from default dir.
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")' '(setq def 456)'
Surprisingly (at least to me), the -f flag means different things to emacs and emacsclient. To emacs, it means:
Call Lisp function FUNCTION. If it is an interactive function (a
command), it reads the arguments interactively just as if you had
called the same function with a key sequence. Otherwise, ...
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 solution is to use the scripts suggested by MJ Wall. These have explicit raise-frame actions.
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 print a string (e.g., "[foo\n bar]"), so to see it on the screen you will need
echo -e $(emacsclient ...)
You can control the behavior of pp with many ...
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 alias if you want. This will open the files on the existing server and frame if there is one, and will otherwise run emacs as usual. The --no-wait is optional and ...
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 precisely what I would have used to explain why:
-q (aka --no-init-file) tells Emacs not to load your init file, so trying to set that option in your init file does ...
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 two places: in the C startup code, and in startup.el. The C startup code processes arguments before it executes any Lisp code, so there's no way to influence ...
I suggest you introduce an option --mylog with the two required arguments.
You write a function my-log-file that processes the command line arguments after --mylog and register it in command-line-functions.
The function my-log-file checks argi whether it currently processes the option --mylog and moves the two required arguments from command-line-args-left ...
You can pass options to Emacs to make it run code when it starts: -l /path/to/file.el, -f function-called-without-arguments, --eval "(some-lisp-code 'taking-care-of \"quoting for the shell\")".
The function gdb is autoloaded, so you don't need to load a package explicitly. It takes an argument. You'll have to write some Lisp code to grab it from the command ...
man emacs gives the following - perhaps one of these invocations would help:
The following options are Lisp-oriented (these options are processed in the order encountered):
-f function, --funcall=function
Execute the lisp function function.
-l file, --load=file
Load the lisp code in the file file.
I don't use ledger-mode but I am pretty sure that the following advice-add will help you. The code is only partially tested (up to make-process in ledger-flymake). Please test whether it is working for you.
It converts the drive specification \`[[:alpha:]]: in buffer-file-name of your ledger buffer selective for function ledger-flymake into /cygdrive/\1 ...
The path you passed (c:/Users/USERNAME/Dropbox/Priv/2018.ledger) is not a valid cygwin file-path, it is a MS-windows file-path:
It will look like a relative file-path to cygwin, so will be appended to the present working directory. I assume that /cygdrive/c/Users/USERNAME/Dropbox/Priv/ | c:/Users/USERNAME/Dropbox/Priv is your present working directory.
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/"))
(message "Atlternate conf"))
(message "Regular conf"))
It works, at the cost of a command-line-1: Unknown option -alt warning ...
Just set your EDITOR to run emacsclient -a "" -c (yours will be at /Applications/Emacs.app/Contents/MacOS/bin/emacsclient, I personally use some symbolic links to make life easier). Problem solved. The global-git-commit-mode is nice but not necessary. When you're done editing the message, save and C-x # to close the buffer and stop the emacsclient process.