1diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
2index 7fc2ad2025ca4ba7b20580af9e33692107f3dfef..38d419813f8e21d37feb6f032ee250abdc4bf748 100755
3--- a/plugins/emacs/emacsclient.sh
4+++ b/plugins/emacs/emacsclient.sh
5@@ -1,9 +1,10 @@
6 #!/bin/sh
7 8-# Starts emacs daemon if not already started.
9-
10+# get list of available X windows.
11 x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
12+
13 if [ -z "$x" ] ;then
14+ # Create one if there is no X window yet.
15 emacsclient --alternate-editor "" --create-frame "$@"
16 else
17 # prevent creating another X frame if there is at least one present.