all repos — nixfiles @ 4cac4e8b64f52a05837f1f40af9fba355370d5ee

System and user configuration, managed by nix and home-manager

Add ec and et commands to launch emacsclient in a terminal and GUI respectively

Alan Pearce
commit

4cac4e8b64f52a05837f1f40af9fba355370d5ee

parent

c0633cd67a4a6bfd40cf3eea146cbdc5679916d3

1 file changed, 24 insertions(+), 0 deletions(-)

jump to
M zsh/zshrczsh/zshrc
@@ -310,6 +310,8 @@ /^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print}
/^WM_NAME/{sub(/.* =/, "title:"); print} /^WM_WINDOW_ROLE/{sub(/.* =/, "role:"); print}'\''' +alias et="emacsclient -t" + alias -g ...='../..' #Suffix aliases
@@ -371,6 +373,28 @@ zrecompile -q -p $zcompargs $1
fi if [[ -n $2 ]]; then . $1 + fi +} + +emacs_change_focus () { + emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null +} + +ec () { + local visibleFrames + visibleFrames=`emacsclient -e '(length (visible-frame-list))'` + if [[ $? -ne 0 ]]; then + print "Daemon not running" + return 1 + fi + + if [[ $visibleFrames -eq 1 ]]; then + emacsclient -n -c "$@" && emacs_change_focus + else + emacs_change_focus + if [[ $# -gt 0 ]]; then + emacsclient -n "$@" + fi fi }