Permalink
Browse files

convert dotto functions to default (zsh) style

  • Loading branch information...
1 parent 5a33b8d commit 649adb5714564b05a111af24c497eacdfbbade78 @rsanders committed Feb 12, 2012
Showing with 48 additions and 108 deletions.
  1. +1 −1 zsh/core/zshenv
  2. +0 −2 zsh/functions/add-zsh-hook
  3. +0 −2 zsh/functions/age_greater_than
  4. +3 −2 zsh/functions/array~mapformat
  5. +2 −2 zsh/functions/array~sort
  6. +1 −3 zsh/functions/autoload_from
  7. +2 −3 zsh/functions/display_dimensions
  8. +1 −2 zsh/functions/dotto_session_id
  9. +3 −1 zsh/functions/dotto_version
  10. +1 −2 zsh/functions/dotto~autoload_paths
  11. +1 −2 zsh/functions/dotto~clear_caches
  12. +2 −2 zsh/functions/dotto~compinit
  13. +0 −2 zsh/functions/dotto~compinit_if_needed
  14. +1 −2 zsh/functions/dotto~if_cache
  15. +0 −2 zsh/functions/dotto~plugin_cache_dir
  16. +0 −2 zsh/functions/dotto~plugin_path
  17. +0 −2 zsh/functions/dotto~zsh_plugin_list
  18. +1 −2 zsh/functions/dotto~zsh_plugin_paths
  19. +1 −4 zsh/functions/file~age
  20. +0 −2 zsh/functions/newer_than
  21. +2 −2 zsh/functions/path~glob_in_dirs
  22. +0 −2 zsh/functions/profiling_dot
  23. +0 −3 zsh/functions/profiling_source
  24. +1 −2 zsh/functions/prompt~rtab
  25. +1 −2 zsh/functions/request
  26. +1 −2 zsh/functions/set~add
  27. +1 −2 zsh/functions/set~contains
  28. +1 −2 zsh/functions/set~prepend
  29. +1 −2 zsh/functions/set~remove
  30. +1 −2 zsh/functions/unshift
  31. +1 −1 zsh/functions/uselib
  32. +1 −2 zsh/functions/useplugin
  33. +0 −2 zsh/functions/zalwhich
  34. +1 −0 zsh/functions/zavp
  35. +0 −2 zsh/functions/zcapture
  36. +0 −2 zsh/functions/zchomp
  37. +0 −2 zsh/functions/zcompilesystem
  38. +1 −2 zsh/functions/zctrace
  39. +1 −2 zsh/functions/zdirname
  40. +1 −2 zsh/functions/zdomainname
  41. +1 −2 zsh/functions/zinclude
  42. +0 −2 zsh/functions/zinvoke
  43. +0 −4 zsh/functions/zlog
  44. +0 −2 zsh/functions/zmd5
  45. +1 −0 zsh/functions/zmemcache
  46. +2 −0 zsh/functions/zmemoize
  47. +1 −2 zsh/functions/zraketargets
  48. +0 −2 zsh/functions/zrealpath
  49. +1 −2 zsh/functions/zrequire
  50. +2 −0 zsh/functions/zrunsystem
  51. +0 −2 zsh/functions/zshellfunc_exists
  52. +0 −2 zsh/functions/zshellfunc_rename
  53. +1 −2 zsh/functions/zshellfunc_type
  54. +1 −2 zsh/functions/zsource
  55. +0 −2 zsh/functions/zsourcedir
  56. +1 −0 zsh/functions/zsystemroots
  57. +2 −0 zsh/functions/ztmpfile
  58. +0 −2 zsh/functions/ztrim
View
@@ -79,7 +79,7 @@ function () {
# load post-bootstrap version
unfunction zctrace
- autoload -Uk "${(@)funcnames}"
+ autoload -U "${(@)funcnames}"
# globally used variables
zinclude_path=("$ZCONFIGDIR")
@@ -18,7 +18,6 @@
# autoload if that is given, as are -z and -k. (This is harmless if the
# function is actually defined inline.)
-function add-zsh-hook {
emulate -L zsh
@@ -83,4 +82,3 @@ else
autoload $autoopts -- $fn
fi
-}
@@ -1,6 +1,5 @@
#!/bin/zsh
-function age_greater_than {
local ageseconds=$1 file=
shift 1
@@ -11,4 +10,3 @@ function age_greater_than {
done
return 1
-}
@@ -5,7 +5,6 @@
#
# usage: array~mapformat ARRAY_VARNAME FORMATSTRING
#
-function array~mapformat () {
emulate -L zsh
local name=$1 format=$2 i len=${(P)#name}
@@ -18,9 +17,11 @@ function array~mapformat () {
done
set -A $name $result
-}
+
# v=(a b c d e)
# array~mapformat v "--%s--"
# echo $v
+
+
View
@@ -1,10 +1,10 @@
#!/bin/zsh
-function array~sort() {
emulate -L zsh
local name=$1
shift
set -A $name ${(Po)name}
-}
+
+
@@ -6,8 +6,6 @@
#
# autoload_from <file> <function> [<function> ...]
-function autoload_from
-{
emulate -L zsh
local alf_file=$1
local alf_func
@@ -18,5 +16,5 @@ function autoload_from
if !
eval "function $alf_func () { source $alf_file; $alf_func \$* }"
done
-}
+
@@ -1,6 +1,5 @@
#!/bin/zsh
-function display_dimensions() {
emulate -L zsh
local string="$1" width=${2:-$COLUMNS}
@@ -22,7 +21,7 @@ function display_dimensions() {
REPLY=$lines
printf "%d\n" "$lines"
-}
+
# typeset -g COLUMNS=20
#
@@ -37,4 +36,4 @@ function display_dimensions() {
# display_dimensions "abcdefghijklmno
# c
# d"
-# display_dimensions "abcde"
+# display_dimensions "abcde"
@@ -3,7 +3,7 @@
#
# Return a session identifier which roughly groups together
#
-function dotto_session_id {
+
emulate -L zsh
local var="" val="" dohash=1
@@ -21,4 +21,3 @@ function dotto_session_id {
[[ $dohash == 1 ]] && zmd5 $val >/dev/null && val=$REPLY
REPLY=$val
echo -n -E $REPLY
-}
@@ -48,4 +48,6 @@ function dotto_version {
REPLY=$DOTTO_VERSION
echo $DOTTO_VERSION
[[ -n $DOTTO_VERSION ]]
-}
+}
+
+dotto_version $*
@@ -2,7 +2,6 @@
# given a set of paths, make all the functions inside autoloadable
-function dotto~autoload_paths () {
emulate -L zsh
typeset -g -a fpath
typeset -a plugfuncpaths funcnames
@@ -19,4 +18,4 @@ function dotto~autoload_paths () {
if [ $#funcnames -gt 0 ]; then
autoload -Uk "${(@)funcnames}"
fi
-}
+
@@ -1,6 +1,5 @@
# -*- Mode: shell-script; -*-
-function dotto~clear_caches () {
local dir file
rm -f $HOME/.zcompdump
@@ -14,4 +13,4 @@ function dotto~clear_caches () {
done
compdump
-}
+
@@ -1,10 +1,10 @@
# -*- Mode: shell-script; -*-
# lazy compinit
-function dotto~compinit () {
+
dotto_vars[compinit_needed]=1
if set~contains zsystem_done zcomp; then
dotto~compinit_if_needed
fi
-}
+
@@ -1,6 +1,5 @@
# -*- Mode: shell-script; -*-
-function dotto~compinit_if_needed () {
if [[ $dotto_vars[compinit_needed] = 1 ]]; then
echo "Running lazy compinit..."
@@ -12,4 +11,3 @@ function dotto~compinit_if_needed () {
dotto_vars[compinit_needed]=
fi
-}
@@ -10,7 +10,6 @@
# return 1
# end
-function dotto~if_cache () {
local file=$1 maxage=${2:-86400} age
@@ -22,4 +21,4 @@ function dotto~if_cache () {
rm -f $file
return 1
fi
-}
+
@@ -1,6 +1,5 @@
# -*- Mode: shell-script; -*-
-function dotto~plugin_cache_dir () {
local plugin=$1
if [[ -n $1 ]]; then
REPLY=$dotto_paths[CACHE_DIR]/plugin/$1
@@ -9,4 +8,3 @@ function dotto~plugin_cache_dir () {
REPLY=
return 1
fi
-}
@@ -1,6 +1,5 @@
# -*- Mode: shell-script -*-
-function dotto~plugin_path () {
local dir plugin=$1
typeset -g REPLY
@@ -12,4 +11,3 @@ function dotto~plugin_path () {
fi
done
return 1
-}
@@ -1,6 +1,4 @@
#!/bin/zsh
-function dotto~zsh_plugin_list () {
echo "$0 NOT IMPLEMENTED" >&2
return 1
-}
@@ -1,7 +1,6 @@
# -*- Mode: shell-script; -*-
-function dotto~zsh_plugin_paths () {
emulate -L zsh
local dir plugins glob p
@@ -33,5 +32,5 @@ function dotto~zsh_plugin_paths () {
done
set -A dotto_zsh_plugin_paths $plugin_paths
-}
+
View
@@ -1,13 +1,10 @@
# returns file age in seconds in REPLY variable
-function file~age() {
local file=$1
typeset -A lhash
if zstat -H lhash $file 2>/dev/null; then
REPLY=$(($EPOCHSECONDS - $lhash[mtime]))
else
return 1
- fi
-}
-
+ fi
View
@@ -2,7 +2,6 @@
zmodload zsh/stat
-function newer_than {
emulate -L zsh
local basetime=${1} file
local -A statres
@@ -14,4 +13,3 @@ function newer_than {
fi
done
return 1
-}
@@ -8,7 +8,7 @@
#
# each PATHSPEC may contain globbing characters itself.
#
-function path~glob_in_dirs () {
+
emulate -L zsh
setopt nullglob no_match
@@ -21,7 +21,7 @@ function path~glob_in_dirs () {
array~mapformat funcpaths "%s/$glob"
set -A reply ${~funcpaths}
-}
+
# path~glob_in_dirs '*' "$ZCONFIGDIR/functions" "$DOTTODIR/zsh/plugins/*/functions"
# echo "reply is ${(j:,:)reply}"
@@ -1,6 +1,5 @@
#!/bin/zsh
-function profiling_dot {
local ___ps_funname="" ___ps_file="$1" ___ps_result=0 result
local -a ___sargs
shift
@@ -14,4 +13,3 @@ function profiling_dot {
unfunction $___ps_funname
return $___ps_result
-}
@@ -5,7 +5,6 @@
# per sourced file
#
-function profiling_source {
local ___ps_funname="" ___ps_file="$1" ___ps_result=0 result
local -a ___sargs
shift
@@ -18,5 +17,3 @@ function profiling_source {
unfunction $___ps_funname
return $___ps_result
-}
-
@@ -9,7 +9,6 @@
# sj: taken from http://www.zsh.org/mla/workers/2009/msg00419.html
-function prompt~rtab {
setopt localoptions
setopt rc_quotes null_glob
@@ -104,7 +103,7 @@ function prompt~rtab {
}
REPLY=${result:-/} && echo $REPLY
)
-}
+
# memoize, also depending on current dir as an implicit argument, 2 minute timeout
zmemoize -P -t 120 prompt~rtab
View
@@ -5,9 +5,8 @@
# them if they are missing.
#
-function request () {
local file
for file in $*; do
[[ -r $file || (-h $file && -f ${file:A}) ]] && source $file
done
-}
+
View
@@ -1,6 +1,5 @@
#!/bin/zsh
-function set~add() {
emulate -L zsh
local name=$1 value i max
@@ -23,7 +22,7 @@ function set~add() {
set -A $name $value ${(P)name}
fi
done
-}
+
# # testing
# typeset -a v
@@ -1,6 +1,5 @@
#!/bin/zsh
-function set~contains() {
emulate -L zsh
local name=$1 value i max
@@ -14,7 +13,7 @@ function set~contains() {
return 1
fi
done
-}
+
# # testing
# typeset -a v
@@ -3,12 +3,11 @@
# Removes any existing copies of the elements and adds them to the
# beginning in supplied order
#
-function set~prepend() {
emulate -L zsh
local name=$1
shift
set~remove $name $*
set -A $name $* ${(P)name}
-}
+
Oops, something went wrong.

0 comments on commit 649adb5

Please sign in to comment.