summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorTristan Carel <tcarel@exalead.com>2011-04-15 18:13:01 +0200
committerTristan Carel <tcarel@exalead.com>2011-04-15 18:13:01 +0200
commit49c0a1381a7bd48464a1c33cac6e09770749f795 (patch)
tree20cf2a0ef2be1a5ae44da5b351387b7ffa4d1095 /plugins
parenta183bcbc6d8d61bd9c1077b45d1c5b3239e96a71 (diff)
downloadzsh-49c0a1381a7bd48464a1c33cac6e09770749f795.tar.gz
zsh-49c0a1381a7bd48464a1c33cac6e09770749f795.tar.bz2
zsh-49c0a1381a7bd48464a1c33cac6e09770749f795.zip
- Fix pass of parameters
- Add new function `ecd'.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/emacs/emacs.plugin.zsh18
-rwxr-xr-xplugins/emacs/emacsclient.sh4
2 files changed, 19 insertions, 3 deletions
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index 62d9fbccc..58043040e 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -1,6 +1,6 @@
# Emacs 23 daemon capability is a killing feature.
# One emacs process handles all your frames whether
-# you use a frame opened in a terminal via a ssh connection or X frames
+# you use a frame opened in a terminal via a ssh connection or X frames
# opened on the same host.
# Benefits are multiple
@@ -23,8 +23,24 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
# to code all night long
alias emasc=emacs
alias emcas=emacs
+
+ # jump to the directory of the current buffer
+ function ecd {
+ local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
+ (if buf-name
+ (file-name-directory buf-name)))"
+
+ local dir=`$EDITOR --eval "$cmd" | tr -d \"`
+ if [ -n "$dir" ] ;then
+ cd "$dir"
+ else
+ echo "can not deduce current buffer filename." >/dev/stderr
+ return 1
+ fi
+ }
fi
+
## Local Variables:
## mode: sh
## End:
diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
index b098fd24a..7fc2ad202 100755
--- a/plugins/emacs/emacsclient.sh
+++ b/plugins/emacs/emacsclient.sh
@@ -4,8 +4,8 @@
x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null`
if [ -z "$x" ] ;then
- emacsclient --alternate-editor "" --create-frame $@
+ emacsclient --alternate-editor "" --create-frame "$@"
else
# prevent creating another X frame if there is at least one present.
- emacsclient --alternate-editor "" $@
+ emacsclient --alternate-editor "" "$@"
fi