a01b1fefe63101fdc36291d0ec2097bdc3994f22

Author
Tristan Carel <tcarel@exalead.com>
Committer
Tristan Carel <tcarel@exalead.com>
Date

Message

Do not overwrite EDITOR environment variable if already defined.

Diff

 1diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
 2index e22f10740609382779da8060b9ebcd150d41a35f..a3f0085a826ba7817e47bc46f814fb931bd9011e 100644
 3--- a/plugins/emacs/emacs.plugin.zsh
 4+++ b/plugins/emacs/emacs.plugin.zsh
 5@@ -11,12 +11,16 @@
 6 
 7 
 8 if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
 9-    export EDITOR="$ZSH/plugins/emacs/emacsclient.sh"
10-    alias emacs="$EDITOR --no-wait"
11+    export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
12+
13+    # set EDITOR if not already defined.
14+    export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
15+
16+    alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
17     alias e=emacs
18 
19     # same than M-x eval but from outside Emacs.
20-    alias eeval="$EDITOR --eval"
21+    alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
22     # create a new X frame
23     alias eframe='emacsclient --alternate-editor "" --create-frame'
24 
25@@ -28,7 +32,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
26     # opened in the current buffer.
27     function efile {
28         local cmd="(buffer-file-name (window-buffer))"
29-        $EDITOR --eval "$cmd" | tr -d \"
30+        "$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \"
31     }
32 
33     # Write to standard output the directory of the file
34@@ -37,7 +41,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
35         local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
36                      (if buf-name (file-name-directory buf-name)))"
37 
38-        local dir="$($EDITOR --eval $cmd | tr -d \")"
39+        local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")"
40         if [ -n "$dir" ] ;then
41             echo "$dir"
42         else