Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 29 lines (23 sloc) 1.15 KB
#!/bin/bash -eux
# Wrapper script to invoke interactive emacs commands in a daemon instance.
# These days many people don't suspect it,
# but Emacs got server ('emacs' binary) and client ('emacsclient') parts.
# Launching server (i.e. default 'emacs' command) evaluates the config
# and could potentially take seconds if it's very heavy
# Launching the client however is lightning fast. It's just a matter of creating a window.
ARGS=(
# This trick gives you best of two worlds: if there is an Emacs daemon running,
# it just connects to it. Otherwise, it spawns a daemon first and then connects to it.
# Without this setting if you didn't have a daemon running, the command would fail.
-a ''
# spawn new GUI window, otherwise it tries to launch client in terminal
--create-frame
--frame-parameters="'(fullscreen . maximized)"
# process rest of arguments as elisp code
--eval
# bring focus to the window
'(select-frame-set-input-focus (selected-frame))'
)
# without any extra args it just invokes the daemon instance, otherwise executes the args
exec emacsclient "${ARGS[@]}" \
"$@" # pass through whatever else you are trying to run
You can’t perform that action at this time.