diff options
author | Tristan Carel <tcarel@exalead.com> | 2011-09-06 10:50:53 +0200 |
---|---|---|
committer | Tristan Carel <tcarel@exalead.com> | 2011-09-06 10:50:53 +0200 |
commit | 574de93efbba22db0ec816ecec717d502dfa333e (patch) | |
tree | 62d51b2456d48c5e28bb27923f6d26b035aeacd1 | |
parent | 6f1929f822d24c6cfc9cecf574cb21c6b3817bb5 (diff) | |
download | zsh-574de93efbba22db0ec816ecec717d502dfa333e.tar.gz zsh-574de93efbba22db0ec816ecec717d502dfa333e.tar.bz2 zsh-574de93efbba22db0ec816ecec717d502dfa333e.zip |
New function `efile`
-rw-r--r-- | plugins/emacs/emacs.plugin.zsh | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 3e45e54d0..737abe9d6 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -24,14 +24,22 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then alias emasc=emacs alias emcas=emacs - # jump to the directory of the current buffer + # Write to standard output the path to the file + # opened in the current buffer. + function efile { + local cmd="(buffer-file-name (window-buffer))" + $EDITOR --eval "$cmd" | tr -d \" + } + + # display the directory of the file + # opened in the 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" + echo "$dir" else echo "can not deduce current buffer filename." >/dev/stderr return 1 @@ -39,7 +47,6 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then } fi - ## Local Variables: ## mode: sh ## End: |