summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2014-06-25 10:51:43 +0100
committerAlan Pearce2014-06-25 10:51:43 +0100
commit27c017fe0991a28f6a326cf32bdf1e8b11a539a8 (patch)
treeaee77a73e4371f90ffb77fd33cb37454f76d20de
parent16f7ed19544f4a6e25bd314bd7adbaa0cab174f8 (diff)
downloaddotfiles-27c017fe0991a28f6a326cf32bdf1e8b11a539a8.tar.lz
dotfiles-27c017fe0991a28f6a326cf32bdf1e8b11a539a8.tar.zst
dotfiles-27c017fe0991a28f6a326cf32bdf1e8b11a539a8.zip
zsh: Generalise ec function to work outside daemon
-rwxr-xr-xtag-zsh/config/zsh/zshrc6
1 files changed, 3 insertions, 3 deletions
diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc
index 9d2da84..451f212 100755
--- a/tag-zsh/config/zsh/zshrc
+++ b/tag-zsh/config/zsh/zshrc
@@ -341,14 +341,14 @@ emacs_change_focus () {
 }
 
 ec () {
-	local visibleFrames
-	visibleFrames=`emacsclient -e '(length (visible-frame-list))'`
+	local frameNeeded
+	frameNeeded=`emacsclient -e '(>= (if (daemonp) 2 1) (length (visible-frame-list)))'`
 	if [[ $? -ne 0 ]]; then
 		print "Daemon not running"
 		return 1
 	fi
 
-	if [[ $visibleFrames -eq 1 ]]; then
+	if [[ $frameNeeded == 't' ]]; then
 		emacsclient -n -c "$@" && emacs_change_focus
 	else
 		emacs_change_focus