From 14a1877311bd0a9cf9c4db0e44e55da0fba77c5c Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 16:48:47 +0200 Subject: [PATCH 1/6] New plugin git-svn installing git project git-svn-clone-externals --- plugins/git-svn/.gitignore | 1 + plugins/git-svn/git-svn.plugin.zsh | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 plugins/git-svn/.gitignore create mode 100644 plugins/git-svn/git-svn.plugin.zsh diff --git a/plugins/git-svn/.gitignore b/plugins/git-svn/.gitignore new file mode 100644 index 000000000..bf5e1a14f --- /dev/null +++ b/plugins/git-svn/.gitignore @@ -0,0 +1 @@ +git-svn-clone-externals diff --git a/plugins/git-svn/git-svn.plugin.zsh b/plugins/git-svn/git-svn.plugin.zsh new file mode 100644 index 000000000..062d63e05 --- /dev/null +++ b/plugins/git-svn/git-svn.plugin.zsh @@ -0,0 +1,10 @@ + +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 ca4dabb45e14d8cd38e07c4ffadf9473ceb2193b Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 17:23:25 +0200 Subject: [PATCH 2/6] New tool require_tool.sh --- tools/require_tool.sh | 161 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100755 tools/require_tool.sh diff --git a/tools/require_tool.sh b/tools/require_tool.sh new file mode 100755 index 000000000..42da2ccf9 --- /dev/null +++ b/tools/require_tool.sh @@ -0,0 +1,161 @@ +__require_tool_version_compare () +{ + ( + # Locally ignore failures, otherwise we'll exit whenever $1 and $2 + # are not equal! + set +e + +awk_strverscmp=' + # Use only awk features that work with 7th edition Unix awk (1978). + # My, what an old awk you have, Mr. Solaris! + END { + while (length(v1) || length(v2)) { + # Set d1 to be the next thing to compare from v1, and likewise for d2. + # Normally this is a single character, but if v1 and v2 contain digits, + # compare them as integers and fractions as strverscmp does. + if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) { + # Split v1 and v2 into their leading digit string components d1 and d2, + # and advance v1 and v2 past the leading digit strings. + for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue + for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue + d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1) + d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1) + if (d1 ~ /^0/) { + if (d2 ~ /^0/) { + # Compare two fractions. + while (d1 ~ /^0/ && d2 ~ /^0/) { + d1 = substr(d1, 2); len1-- + d2 = substr(d2, 2); len2-- + } + if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) { + # The two components differ in length, and the common prefix + # contains only leading zeros. Consider the longer to be less. + d1 = -len1 + d2 = -len2 + } else { + # Otherwise, compare as strings. + d1 = "x" d1 + d2 = "x" d2 + } + } else { + # A fraction is less than an integer. + exit 1 + } + } else { + if (d2 ~ /^0/) { + # An integer is greater than a fraction. + exit 2 + } else { + # Compare two integers. + d1 += 0 + d2 += 0 + } + } + } else { + # The normal case, without worrying about digits. + if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) } + if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) } + } + if (d1 < d2) exit 1 + if (d1 > d2) exit 2 + } + } +' + awk "$awk_strverscmp" v1="$1" v2="$2" /dev/null + case $? in + 1) echo '<';; + 0) echo '=';; + 2) echo '>';; + esac + ) +} + + +__require_tool_fatal () +{ + echo $@ >/dev/stderr + return 1 +} + +# Usage: require_tool program version +# Returns: 0 if $1 version if greater equals than $2, 1 otherwise. +# In case of error, message is written on error output. +# +# Example: require_tool gcc 4.6 +# Use GCC environment variable if defined instead of lookup for the tool +# in the environment. +require_tool () +{ + envvar_name=$(echo $1 | tr '[:lower:]' '[:upper:]') + tool=$(printenv $envvar_name || echo $1) + local version=$($tool --version 2>/dev/null| \ + sed -n 's/.*[^0-9.]\([0-9][0-9.]*\).*/\1/p;q') + if test x"$version" = x ; then + echo "$tool is required" >/dev/stderr + return 1 + fi + case $(__require_tool_version_compare "$2" "$version") in + '>') + echo "$1 $2 or better is required: this is $tool $version" >/dev/stderr + return 1 + ;; + esac +} + +usage() { + cat < Date: Wed, 13 Apr 2011 17:24:44 +0200 Subject: [PATCH 3/6] Fix version parsing. Now working with command $ zsh --version --- tools/require_tool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/require_tool.sh b/tools/require_tool.sh index 42da2ccf9..1fa77f77a 100755 --- a/tools/require_tool.sh +++ b/tools/require_tool.sh @@ -89,7 +89,7 @@ require_tool () envvar_name=$(echo $1 | tr '[:lower:]' '[:upper:]') tool=$(printenv $envvar_name || echo $1) local version=$($tool --version 2>/dev/null| \ - sed -n 's/.*[^0-9.]\([0-9][0-9.]*\).*/\1/p;q') + sed -n 's/.*[^0-9.]\([0-9]*\.[0-9.]*\).*/\1/p;q') if test x"$version" = x ; then echo "$tool is required" >/dev/stderr return 1 From 2fba4486bfa63cf2a4a11a34c94ce123127ef4c9 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 17:34:51 +0200 Subject: [PATCH 4/6] Add new plugin emacs, to take benefit of daemon capabilities of emacs >=23 --- plugins/emacs/emacs.plugin.zsh | 11 +++++++++++ plugins/emacs/emacsclient.sh | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/emacs/emacs.plugin.zsh create mode 100755 plugins/emacs/emacsclient.sh diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh new file mode 100644 index 000000000..bca79e70e --- /dev/null +++ b/plugins/emacs/emacs.plugin.zsh @@ -0,0 +1,11 @@ +# Use daemon capabilities of emacs 23 +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 + + alias emasc=emacs + alias emcas=emacs + # create a new X frame + alias emacs_frame='emacsclient --alternate-editor "" --create-frame' +fi diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh new file mode 100755 index 000000000..3475926a6 --- /dev/null +++ b/plugins/emacs/emacsclient.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Starts emacs daemon if not already started. + +x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` +if [ -z "$x" ] ;then + emacsclient --alternate-editor "" --create-frame $@ +else + emacsclient --alternate-editor "" $@ +fi From df0b37f9db3f8a1d445bebf30d04039eb247ab71 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 17:45:04 +0200 Subject: [PATCH 5/6] Merge branch 'master'; commit 'ca4dabb45e14d8cd38e07c4ffadf9473ceb2193b' into require_tool From 0c032aaf81afcb134668a462a9ea028e6fc64eeb Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Wed, 13 Apr 2011 17:46:36 +0200 Subject: [PATCH 6/6] Removing master stuff --- plugins/emacs/emacs.plugin.zsh | 11 ----------- plugins/emacs/emacsclient.sh | 10 ---------- plugins/git-svn/.gitignore | 1 - plugins/git-svn/git-svn.plugin.zsh | 10 ---------- 4 files changed, 32 deletions(-) delete mode 100644 plugins/emacs/emacs.plugin.zsh delete mode 100755 plugins/emacs/emacsclient.sh delete mode 100644 plugins/git-svn/.gitignore delete mode 100644 plugins/git-svn/git-svn.plugin.zsh diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh deleted file mode 100644 index bca79e70e..000000000 --- a/plugins/emacs/emacs.plugin.zsh +++ /dev/null @@ -1,11 +0,0 @@ -# Use daemon capabilities of emacs 23 -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 - - alias emasc=emacs - alias emcas=emacs - # create a new X frame - alias emacs_frame='emacsclient --alternate-editor "" --create-frame' -fi diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh deleted file mode 100755 index 3475926a6..000000000 --- a/plugins/emacs/emacsclient.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Starts emacs daemon if not already started. - -x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` -if [ -z "$x" ] ;then - emacsclient --alternate-editor "" --create-frame $@ -else - emacsclient --alternate-editor "" $@ -fi diff --git a/plugins/git-svn/.gitignore b/plugins/git-svn/.gitignore deleted file mode 100644 index bf5e1a14f..000000000 --- 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 062d63e05..000000000 --- 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) -}