49c0a1381a7bd48464a1c33cac6e09770749f795

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

Message

- Fix pass of parameters
- Add new function `ecd'.

Diff

 1diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
 2index 62d9fbccc72bd2fe3aa84c889aeafeed425e72ea..58043040e2edb9360b2a286f5f2ce8958a5b2aa8 100644
 3--- a/plugins/emacs/emacs.plugin.zsh
 4+++ b/plugins/emacs/emacs.plugin.zsh
 5@@ -1,6 +1,6 @@
 6 # Emacs 23 daemon capability is a killing feature.
 7 # One emacs process handles all your frames whether
 8-# you use a frame opened in a terminal via a ssh connection or X frames 
 9+# you use a frame opened in a terminal via a ssh connection or X frames
10 # opened on the same host.
11 
12 # Benefits are multiple
13@@ -23,8 +23,24 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
14     # to code all night long
15     alias emasc=emacs
16     alias emcas=emacs
17+
18+    # jump to the directory of the current buffer
19+    function ecd {
20+        local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
21+               (if buf-name
22+                 (file-name-directory buf-name)))"
23+
24+        local dir=`$EDITOR --eval "$cmd" | tr -d \"`
25+        if [ -n "$dir" ] ;then
26+            cd "$dir"
27+        else
28+            echo "can not deduce current buffer filename." >/dev/stderr
29+            return 1
30+        fi
31+    }
32 fi
33 
34+
35 ## Local Variables:
36 ## mode: sh
37 ## End:
38diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
39index b098fd24ad49ee3190bb5f9f877390cf0ce5ab58..7fc2ad2025ca4ba7b20580af9e33692107f3dfef 100755
40--- a/plugins/emacs/emacsclient.sh
41+++ b/plugins/emacs/emacsclient.sh
42@@ -4,8 +4,8 @@
43 
44 x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
45 if [ -z "$x" ] ;then
46-    emacsclient --alternate-editor "" --create-frame $@
47+    emacsclient --alternate-editor "" --create-frame "$@"
48 else
49     # prevent creating another X frame if there is at least one present.
50-    emacsclient --alternate-editor "" $@
51+    emacsclient --alternate-editor "" "$@"
52 fi