all repos — nixfiles @ 27c017fe0991a28f6a326cf32bdf1e8b11a539a8

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

zsh: Generalise ec function to work outside daemon
Alan Pearce alan@alanpearce.co.uk
Wed, 25 Jun 2014 10:51:43 +0100
commit

27c017fe0991a28f6a326cf32bdf1e8b11a539a8

parent

16f7ed19544f4a6e25bd314bd7adbaa0cab174f8

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M tag-zsh/config/zsh/zshrctag-zsh/config/zsh/zshrc
@@ -341,14 +341,14 @@ emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null }
 
 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