From 5d90f58b37fd67184c4aed3d81a1d3703f8fe832 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 20:21:13 +0200 Subject: [PATCH 1/9] I should not have merged this here. --- plugins/git-svn/.gitignore | 1 - plugins/git-svn/git-svn.plugin.zsh | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 plugins/git-svn/.gitignore delete mode 100644 plugins/git-svn/git-svn.plugin.zsh diff --git a/plugins/git-svn/.gitignore b/plugins/git-svn/.gitignore deleted file mode 100644 index bf5e1a14..00000000 --- a/plugins/git-svn/.gitignore +++ /dev/null @@ -1 +0,0 @@ -git-svn-clone-externals diff --git a/plugins/git-svn/git-svn.plugin.zsh b/plugins/git-svn/git-svn.plugin.zsh deleted file mode 100644 index 062d63e0..00000000 --- a/plugins/git-svn/git-svn.plugin.zsh +++ /dev/null @@ -1,10 +0,0 @@ - -if ! [ -d "$ZSH/plugins/git-svn/git-svn-clone-externals" ] ;then - git clone https://github.com/andrep/git-svn-clone-externals.git -fi -export PATH="$ZSH/plugins/git-svn/git-svn-clone-externals:$PATH" - -function git_svn_update { - (cd "$ZSH/plugins/git-svn/git-svn-clone-externals" && \ - git pull origin master) -} From a183bcbc6d8d61bd9c1077b45d1c5b3239e96a71 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Thu, 14 Apr 2011 07:17:10 +0200 Subject: [PATCH 2/9] More comments --- plugins/emacs/emacs.plugin.zsh | 25 ++++++++++++++++++++++--- plugins/emacs/emacsclient.sh | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index bca79e70..62d9fbcc 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -1,11 +1,30 @@ -# Use daemon capabilities of emacs 23 +# 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 +# opened on the same host. + +# Benefits are multiple +# - You don't have the cost of starting Emacs all the time anymore +# - Opening a file is as fast as Emacs does not have anything else to do. +# - You can share opened buffered across opened frames. +# - Configuration changes made at runtime are applied to all frames. + + if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then export EDITOR="$ZSH/plugins/emacs/emacsclient.sh" alias emacs="$EDITOR --no-wait" alias e=emacs + # same than M-x eval but from outside Emacs. + alias eeval="emacs --eval" + # create a new X frame + alias eframe='emacsclient --alternate-editor "" --create-frame' + + # to code all night long alias emasc=emacs alias emcas=emacs - # create a new X frame - alias emacs_frame='emacsclient --alternate-editor "" --create-frame' fi + +## Local Variables: +## mode: sh +## End: diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 3475926a..b098fd24 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -6,5 +6,6 @@ x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` if [ -z "$x" ] ;then emacsclient --alternate-editor "" --create-frame $@ else + # prevent creating another X frame if there is at least one present. emacsclient --alternate-editor "" $@ fi From 49c0a1381a7bd48464a1c33cac6e09770749f795 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Fri, 15 Apr 2011 18:13:01 +0200 Subject: [PATCH 3/9] - Fix pass of parameters - Add new function `ecd'. --- plugins/emacs/emacs.plugin.zsh | 18 +++++++++++++++++- plugins/emacs/emacsclient.sh | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 62d9fbcc..58043040 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 b098fd24..7fc2ad20 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 From 9b29136ec65953004f064ec4a834ae7b1f2949e7 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Fri, 15 Apr 2011 18:21:22 +0200 Subject: [PATCH 4/9] Fix alias `eeval' --- plugins/emacs/emacs.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 58043040..fc6b8865 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -16,7 +16,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then alias e=emacs # same than M-x eval but from outside Emacs. - alias eeval="emacs --eval" + alias eeval="$EDITOR --eval" # create a new X frame alias eframe='emacsclient --alternate-editor "" --create-frame' From 6f1929f822d24c6cfc9cecf574cb21c6b3817bb5 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Fri, 15 Apr 2011 18:22:27 +0200 Subject: [PATCH 5/9] Fix indentation --- plugins/emacs/emacs.plugin.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index fc6b8865..3e45e54d 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -27,8 +27,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then # 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)))" + (if buf-name (file-name-directory buf-name)))" local dir=`$EDITOR --eval "$cmd" | tr -d \"` if [ -n "$dir" ] ;then From 574de93efbba22db0ec816ecec717d502dfa333e Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Tue, 6 Sep 2011 10:50:53 +0200 Subject: [PATCH 6/9] New function `efile` --- plugins/emacs/emacs.plugin.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 3e45e54d..737abe9d 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: From 7066bf7c6b522af9147ebf03c00361c4c6490d42 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Mon, 10 Oct 2011 14:54:20 +0200 Subject: [PATCH 7/9] Fix builtin `ecd' when file path contains space characters. --- plugins/emacs/emacs.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index 737abe9d..e22f1074 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -31,13 +31,13 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then $EDITOR --eval "$cmd" | tr -d \" } - # display the directory of the file + # Write to standard output 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 \"` + local dir="$($EDITOR --eval $cmd | tr -d \")" if [ -n "$dir" ] ;then echo "$dir" else From 3a408f326f1436a81ae481610c76c8938903df4f Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Mon, 10 Oct 2011 18:04:13 +0200 Subject: [PATCH 8/9] Comment --- plugins/emacs/emacsclient.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh index 7fc2ad20..38d41981 100755 --- a/plugins/emacs/emacsclient.sh +++ b/plugins/emacs/emacsclient.sh @@ -1,9 +1,10 @@ #!/bin/sh -# Starts emacs daemon if not already started. - +# get list of available X windows. x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` + if [ -z "$x" ] ;then + # Create one if there is no X window yet. emacsclient --alternate-editor "" --create-frame "$@" else # prevent creating another X frame if there is at least one present. From a01b1fefe63101fdc36291d0ec2097bdc3994f22 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Mon, 10 Oct 2011 18:04:24 +0200 Subject: [PATCH 9/9] Do not overwrite EDITOR environment variable if already defined. --- plugins/emacs/emacs.plugin.zsh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index e22f1074..a3f0085a 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -11,12 +11,16 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then - export EDITOR="$ZSH/plugins/emacs/emacsclient.sh" - alias emacs="$EDITOR --no-wait" + export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" + + # set EDITOR if not already defined. + export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}" + + alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait" alias e=emacs # same than M-x eval but from outside Emacs. - alias eeval="$EDITOR --eval" + alias eeval="$EMACS_PLUGIN_LAUNCHER --eval" # create a new X frame alias eframe='emacsclient --alternate-editor "" --create-frame' @@ -28,7 +32,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then # opened in the current buffer. function efile { local cmd="(buffer-file-name (window-buffer))" - $EDITOR --eval "$cmd" | tr -d \" + "$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \" } # Write to standard output the directory of the file @@ -37,7 +41,7 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then 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 \")" + local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")" if [ -n "$dir" ] ;then echo "$dir" else