Update emacs plugin. (#5201)
- Updated minimal version from 23 to 24.
- Added new aliases that fix unexpected close with -nw option.
- Removed some old aliases.
- Fixed line that detects open frames.
Diff
1diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
2index a3f0085a826ba7817e47bc46f814fb931bd9011e..c102a5a1e2816a1ee60e31661262a3dea215cc30 100644
3--- a/plugins/emacs/emacs.plugin.zsh
4+++ b/plugins/emacs/emacs.plugin.zsh
5@@ -10,7 +10,7 @@
6 # - Configuration changes made at runtime are applied to all frames.
7 8 9-if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
10+if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then
11 export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
1213 # set EDITOR if not already defined.
14@@ -18,15 +18,14 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
1516 alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
17 alias e=emacs
18+ # open terminal emacsclient
19+ alias te="$EMACS_PLUGIN_LAUNCHER -nw"
2021 # same than M-x eval but from outside Emacs.
22 alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
23 # create a new X frame
24 alias eframe='emacsclient --alternate-editor "" --create-frame'
2526- # to code all night long
27- alias emasc=emacs
28- alias emcas=emacs
2930 # Write to standard output the path to the file
31 # opened in the current buffer.
32diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
33index 41682512ddd6e1d5da70ce8e785f954c3918a260..26b28d495b6a63a8b88c1b0c056864a200a7e8d3 100755
34--- a/plugins/emacs/emacsclient.sh
35+++ b/plugins/emacs/emacsclient.sh
36@@ -2,15 +2,15 @@
3738 _emacsfun()
39 {
40- # get list of available X windows.
41- x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
42+ # get list of emacs frames.
43+ frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'`
4445- if [ -z "$x" ] || [ "$x" = "nil" ] ;then
46- # Create one if there is no X window yet.
47- emacsclient --alternate-editor "" --create-frame "$@"
48- else
49+ if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then
50 # prevent creating another X frame if there is at least one present.
51 emacsclient --alternate-editor "" "$@"
52+ else
53+ # Create one if there is no X window yet.
54+ emacsclient --alternate-editor "" --create-frame "$@"
55 fi
56 }
57