Passage local: → var (2)
This commit is contained in:
parent
81ab7d87ed
commit
a49f17bc35
@ -1,4 +1,4 @@
|
||||
local:dir = ~/.config/elvish/aliases
|
||||
var dir = ~/.config/elvish/aliases
|
||||
|
||||
for file [(_ = ?(put $dir/*.elv))] {
|
||||
content = (cat $file | slurp)
|
||||
|
@ -1,7 +1,7 @@
|
||||
use moi/util/condition
|
||||
use moi/util/file
|
||||
|
||||
commands = [
|
||||
var commands = [
|
||||
help
|
||||
archive
|
||||
unarchive
|
||||
@ -9,12 +9,12 @@ commands = [
|
||||
ls
|
||||
]
|
||||
|
||||
extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
var extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
|
||||
fn -comp-commands { all $commands }
|
||||
|
||||
fn -comp-archive-files [m]{
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
var type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
@ -27,8 +27,7 @@ fn -comp-inline-files [archive]{
|
||||
}
|
||||
|
||||
fn complete [@argv]{
|
||||
local:c = (count $argv)
|
||||
local:cmd = $argv[1]
|
||||
var c cmd = (count $argv) $argv[1]
|
||||
if (== $c 2) {
|
||||
-comp-commands
|
||||
} elif (== $c 3) {
|
||||
@ -39,7 +38,7 @@ fn complete [@argv]{
|
||||
if (eq $cmd archive) {
|
||||
edit:complete-filename $@argv
|
||||
} elif (eq $cmd extract) {
|
||||
local:archive = $argv[2]
|
||||
var archive = $argv[2]
|
||||
-comp-inline-files $archive
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
use moi/util/condition
|
||||
use moi/util/file
|
||||
|
||||
extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
var extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
|
||||
fn complete [@argv]{
|
||||
local:m = $argv[-1]
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
var m = $argv[-1]
|
||||
var type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn -remotes-packages { kcp -lN }
|
||||
|
||||
options = [
|
||||
var options = [
|
||||
-h
|
||||
-v
|
||||
-i
|
||||
@ -21,7 +21,7 @@ options = [
|
||||
-V
|
||||
]
|
||||
|
||||
np = [
|
||||
var np = [
|
||||
-i
|
||||
-di
|
||||
-s
|
||||
@ -30,7 +30,7 @@ np = [
|
||||
]
|
||||
|
||||
fn complete [@argv]{
|
||||
local:c = (count $argv)
|
||||
var c = (count $argv)
|
||||
if (== $c 2) {
|
||||
all $options
|
||||
} elif (and (== $c 3) (has-value $np $argv[-2])) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use moi/util/condition
|
||||
use moi/util/file
|
||||
|
||||
extensions = [
|
||||
var extensions = [
|
||||
aac
|
||||
ape
|
||||
avi
|
||||
@ -36,12 +36,12 @@ extensions = [
|
||||
]
|
||||
|
||||
fn -files [m]{
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
var type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
fn complete [@argv]{
|
||||
c = (count $argv)
|
||||
var c = (count $argv)
|
||||
if (== $c 2) {
|
||||
put --speed
|
||||
-files $argv[-1]
|
||||
|
@ -5,12 +5,12 @@ use moi/util/list
|
||||
fn -local-packages { pacman -Q | eawk [_ p @_]{ put $p } }
|
||||
|
||||
fn -repo-packages {
|
||||
local:packages = [(pacman -Ss | list:ploop &step=2 [_ v]{
|
||||
var packages = [(pacman -Ss | list:ploop &step=2 [_ v]{
|
||||
put $v
|
||||
} | eawk [_ p @_]{
|
||||
put $p
|
||||
})]
|
||||
local:spackages = [&]
|
||||
var spackages = [&]
|
||||
use str
|
||||
peach [p]{
|
||||
str:split '/' $p
|
||||
@ -22,13 +22,13 @@ fn -repo-packages {
|
||||
}
|
||||
|
||||
fn -downloaded-packages [m]{
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
var type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m tar.zst tar.xz tar.gz tar.bz2
|
||||
}
|
||||
|
||||
fn -local-file [m]{ edit:complete-filename $m }
|
||||
|
||||
options = [
|
||||
var options = [
|
||||
-h
|
||||
-V
|
||||
-Q
|
||||
@ -50,13 +50,13 @@ options = [
|
||||
-D
|
||||
]
|
||||
|
||||
asdeps = [
|
||||
var asdeps = [
|
||||
-S
|
||||
-U
|
||||
-D
|
||||
]
|
||||
|
||||
lpack = [
|
||||
var lpack = [
|
||||
-Q
|
||||
-Qs
|
||||
-Ql
|
||||
@ -66,27 +66,27 @@ lpack = [
|
||||
-Rsn
|
||||
]
|
||||
|
||||
rpack = [
|
||||
var rpack = [
|
||||
-S
|
||||
-Ss
|
||||
-Si
|
||||
-Sii
|
||||
]
|
||||
|
||||
dpack = [
|
||||
var dpack = [
|
||||
-U
|
||||
]
|
||||
|
||||
fpack = [
|
||||
var fpack = [
|
||||
-Qo
|
||||
]
|
||||
|
||||
fn complete [@argv]{
|
||||
local:c = (count $argv)
|
||||
var c = (count $argv)
|
||||
if (< $c 3) {
|
||||
all $options
|
||||
} else {
|
||||
local:cmd = $argv[1]
|
||||
var cmd = $argv[1]
|
||||
if (and (== $c 3) (has-value $asdeps $cmd)) {
|
||||
put --asdeps --asexplicit
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ use moi/util/list
|
||||
use moi/util/map
|
||||
use moi/util/option
|
||||
|
||||
options-ssh = [ 1 2 4 6 A D f g I i L l m o v a b C c e F k N n p q R s T t X x ]
|
||||
options-scp = [ 3 4 6 B C p q r v c F i l o P S ]
|
||||
var options-ssh = [ 1 2 4 6 A D f g I i L l m o v a b C c e F k N n p q R s T t X x ]
|
||||
var options-scp = [ 3 4 6 B C p q r v c F i l o P S ]
|
||||
|
||||
names = [
|
||||
var names = [
|
||||
benjamin
|
||||
luence
|
||||
]
|
||||
@ -19,15 +19,15 @@ fn -kh {
|
||||
cat ~/.ssh/known_hosts | peach [l]{
|
||||
put [(str:split ' ' $l)]
|
||||
} | peach [e]{
|
||||
local:domains @_ = $@e
|
||||
var domains @_ = $@e
|
||||
str:split ',' $domains
|
||||
}
|
||||
}
|
||||
|
||||
fn -port [cmd @argv]{
|
||||
local:o = (condition:cset (eq $cmd 'ssh') '-p' '-P')
|
||||
local:margs = (option:map $argv)
|
||||
local:p = (map:value-of $margs $o &default=[])
|
||||
var o = (condition:cset (eq $cmd 'ssh') '-p' '-P')
|
||||
var margs = (option:map $argv)
|
||||
var p = (map:value-of $margs $o &default=[])
|
||||
if (list:empty $p) {
|
||||
put 22
|
||||
} else {
|
||||
@ -53,8 +53,8 @@ fn -complete-remote-dir [port address dir]{
|
||||
}
|
||||
|
||||
fn -complete-args [hosts cmd @argv]{
|
||||
local:arg = $argv[-1]
|
||||
local:i = (str:index $arg @)
|
||||
var arg = $argv[-1]
|
||||
var i = (str:index $arg @)
|
||||
if (< $i 0) {
|
||||
-complete-names
|
||||
all $hosts
|
||||
@ -63,15 +63,15 @@ fn -complete-args [hosts cmd @argv]{
|
||||
}
|
||||
return
|
||||
}
|
||||
local:n local:h = $arg[..$i] $arg[(+ $i 1)..]
|
||||
var n h = $arg[..$i] $arg[(+ $i 1)..]
|
||||
if (eq $cmd scp) {
|
||||
i = (str:index $h :)
|
||||
if (>= $i 0) {
|
||||
local:d = $h[(+ $i 1)..]
|
||||
var d = $h[(+ $i 1)..]
|
||||
h = $h[..$i]
|
||||
if (list:includes $h $hosts) {
|
||||
local:p = (-port $cmd @argv)
|
||||
local:e = [ (str:split / $d) ]
|
||||
var p = (-port $cmd @argv)
|
||||
var e = [ (str:split / $d) ]
|
||||
if (not-eq $e[-1] '') {
|
||||
d = (str:join / $e[..-1])
|
||||
if (eq $d '') {
|
||||
@ -88,10 +88,10 @@ fn -complete-args [hosts cmd @argv]{
|
||||
}
|
||||
|
||||
fn complete [@argv]{
|
||||
@hosts = (-kh)
|
||||
local:cmd = $argv[0]
|
||||
local:is-ssh = (eq $cmd ssh)
|
||||
local:po = (condition:cset $is-ssh -p -P)
|
||||
var @hosts = (-kh)
|
||||
var cmd = $argv[0]
|
||||
var is-ssh = (eq $cmd ssh)
|
||||
var po = (condition:cset $is-ssh -p -P)
|
||||
if (<= (count $argv) 2) {
|
||||
all (condition:cset $is-ssh $options-ssh $options-scp)
|
||||
-complete-args $hosts $@argv
|
||||
|
@ -1,5 +1,5 @@
|
||||
local:libdir = $E:HOME/.config/elvish/lib
|
||||
local:builtin_modules = [
|
||||
var libdir = $E:HOME/.config/elvish/lib
|
||||
var builtin_modules = [
|
||||
builtin
|
||||
epm
|
||||
file
|
||||
|
@ -20,16 +20,16 @@ edit:add-var abs~ [n]{
|
||||
}
|
||||
|
||||
edit:add-var sum~ [@numbers]{
|
||||
local:s = 0
|
||||
var s = 0
|
||||
each [e]{ s = (+ $s e) } (to-list $numbers)
|
||||
}
|
||||
|
||||
fn -minmax [t @numbers]{
|
||||
local:l = (to-list $@numbers)
|
||||
var l = (to-list $@numbers)
|
||||
if (== (count $l) 0) {
|
||||
return
|
||||
}
|
||||
local:m = $l[0]
|
||||
var m = $l[0]
|
||||
each [n]{
|
||||
if ($t $n $m) {
|
||||
m = $n
|
||||
|
@ -11,7 +11,7 @@ fn mset [c t f]{
|
||||
}
|
||||
|
||||
fn call [c t f @argv]{
|
||||
local:v = (cset $c $t $f)
|
||||
var v = (cset $c $t $f)
|
||||
if (is (kind-of $v) fn) {
|
||||
$v $@argv
|
||||
} else {
|
||||
|
@ -13,8 +13,8 @@ search-type = [
|
||||
]
|
||||
|
||||
fn -less [f1 f2]{
|
||||
local:fl1 local:fl2 = (str:to-lower $f1) (str:to-lower $f2)
|
||||
local:c = (str:compare $fl1 $fl2)
|
||||
var fl1 fl2 = (str:to-lower $f1) (str:to-lower $f2)
|
||||
var c = (str:compare $fl1 $fl2)
|
||||
if (== $c 0) {
|
||||
c = (str:compare $f1 $f2)
|
||||
}
|
||||
@ -30,16 +30,15 @@ fn -get-results [sort result]{
|
||||
}
|
||||
|
||||
fn -search [&sort=$false &type=exact @motive]{
|
||||
local:f = $search-type[$type]
|
||||
local:result = [&]
|
||||
var f result = $search-type[$type] [&]
|
||||
if (list:empty $motive) {
|
||||
result = (put * | map:to-set)
|
||||
} else {
|
||||
peach [m]{
|
||||
local:m = $m
|
||||
var m = $m
|
||||
try {
|
||||
$f $m | peach [e]{
|
||||
local:e = $e
|
||||
var e = $e
|
||||
result[$e] = $nil
|
||||
}
|
||||
} except e { }
|
||||
@ -53,7 +52,7 @@ fn match-files [&sort=$false &type=prefix @motive]{ -search &sort=$sort &type=$t
|
||||
fn match-extensions [&sort=$false &type=deep-prefix motive @extensions]{
|
||||
result = [&]
|
||||
-search &type=$type $motive | peach [f]{
|
||||
local:f = $f
|
||||
var f = $f
|
||||
if (list:contains [e]{ str:has-suffix $f .$e } $extensions) {
|
||||
result[$f] = $nil
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ fn is-ipv4 [arg]{
|
||||
}
|
||||
|
||||
fn is-ipv6 [arg]{
|
||||
local:p = '[0-9a-fA-F]{1,4}'
|
||||
local:g1 local:g2 = '('$p':)' '(:'$p')'
|
||||
local:cases = [
|
||||
var p = '[0-9a-fA-F]{1,4}'
|
||||
var g1 g2 = '('$p':)' '(:'$p')'
|
||||
var cases = [
|
||||
$g1'{7,7}'$p
|
||||
$g1'{1,7}:'
|
||||
$g1'{1,6}:'$p
|
||||
@ -25,7 +25,7 @@ fn is-ipv6 [arg]{
|
||||
':'$g2'{1,7}'
|
||||
'::'
|
||||
]
|
||||
local:r = '^('(str:join '|' $cases)')$'
|
||||
var r = '^('(str:join '|' $cases)')$'
|
||||
put (re:match $r $arg)
|
||||
}
|
||||
|
||||
@ -47,8 +47,8 @@ fn -middle-part6 [p]{
|
||||
|
||||
fn -find-max0 [parts]{
|
||||
use ./list
|
||||
local:idx local:s = -1 1
|
||||
local:ci local:cs local:f = -1 0 $false
|
||||
var idx s = -1 1
|
||||
var ci cs f = -1 0 $false
|
||||
list:loop [i p]{
|
||||
if (eq $p 0) {
|
||||
condition:call $f { cs = (+ $cs 1) } { ci cs f = $i 1 $true }
|
||||
@ -73,11 +73,11 @@ fn long6 [ip]{
|
||||
repeat 8 '0000' | str:join ':'
|
||||
return
|
||||
}
|
||||
local:c = (- 7 (str:count $ip ':'))
|
||||
var c = (- 7 (str:count $ip ':'))
|
||||
if (> $c 0) {
|
||||
local:i = (str:index $ip '::')
|
||||
local:z = (repeat $c ':' | str:join '')
|
||||
ip = (str:join '' [$ip[..$i] $z $ip[{$i}..]])
|
||||
var i = (str:index $ip '::')
|
||||
var z = (repeat $c ':' | str:join '')
|
||||
ip = (str:join '' [$ip[..$i] $z $ip[{$i}..]])
|
||||
}
|
||||
str:split ':' $ip | each $-long-part6~ | str:join ':'
|
||||
}
|
||||
@ -87,10 +87,10 @@ fn middle6 [ip]{
|
||||
}
|
||||
|
||||
fn short6 [ip]{
|
||||
local:parts = [(str:split ':' (middle6 $ip))]
|
||||
local:i local:s = (-find-max0 $parts)
|
||||
var parts = [(str:split ':' (middle6 $ip))]
|
||||
var i s = (-find-max0 $parts)
|
||||
if (>= $i 0) {
|
||||
local:left local:right = $parts[..$i] $parts[(+ $i $s)..]
|
||||
var left right = $parts[..$i] $parts[(+ $i $s)..]
|
||||
if (== (count $left) 0) {
|
||||
left = ['']
|
||||
}
|
||||
@ -107,9 +107,9 @@ fn is-ip [arg]{ or (is-ipv4 $arg) (is-ipv6 $arg) }
|
||||
fn -cmp [e1 e2]{
|
||||
use ./list
|
||||
use ./condition
|
||||
local:c = 0
|
||||
var c = 0
|
||||
list:loop [i p1]{
|
||||
local:p2 = $e2[$i]
|
||||
var p2 = $e2[$i]
|
||||
c = (condition:cset (< $p1 $p2) -1 (condition:cset (> $p1 $p2) 1 0))
|
||||
if (!= $c 0) {
|
||||
break
|
||||
|
@ -12,21 +12,21 @@ fn value-of [container k &default=$nil]{
|
||||
}
|
||||
|
||||
fn unzip [container]{
|
||||
local:lkeys local:lvalues = [] []
|
||||
var lkeys lvalues = [] []
|
||||
keys $container | each [k]{
|
||||
lkeys = [(all $lkeys) $k]
|
||||
lkeys = [(all $lkeys) $k]
|
||||
lvalues = [(all $lvalues) $container[$k]]
|
||||
}
|
||||
put $lkeys $lvalues
|
||||
}
|
||||
|
||||
fn zip [lkeys lvalues]{
|
||||
local:ck local:cv = (count $lkeys) (count $lvalues)
|
||||
local:c = $ck
|
||||
var ck cv = (count $lkeys) (count $lvalues)
|
||||
var c = $ck
|
||||
if (> $ck $cv) {
|
||||
c = $cv
|
||||
}
|
||||
local:result = [&]
|
||||
var result = [&]
|
||||
range $c | peach [i]{
|
||||
put [&k=$lkeys[$i] &i=$i]
|
||||
} | peach [e]{
|
||||
@ -39,13 +39,13 @@ fn zip [lkeys lvalues]{
|
||||
|
||||
fn to-map [@argv]{
|
||||
use ./list
|
||||
local:container = (list:to-list $@argv)
|
||||
var container = (list:to-list $@argv)
|
||||
zip [(range (count $container))] $container
|
||||
}
|
||||
|
||||
fn to-set [@argv]{
|
||||
use ./list
|
||||
local:m = [&]
|
||||
var m = [&]
|
||||
each [k]{ m[$k] = $nil } (list:to-list $@argv)
|
||||
put $m
|
||||
}
|
||||
@ -59,7 +59,7 @@ fn mdissoc [container @argv]{
|
||||
|
||||
fn massoc [&replace=$true container @argv]{
|
||||
each [e]{
|
||||
local:k local:v = $@e
|
||||
var k v = $@e
|
||||
if (or $replace (not (has-key $container $k))) {
|
||||
container[$k] = $v
|
||||
}
|
||||
@ -69,7 +69,7 @@ fn massoc [&replace=$true container @argv]{
|
||||
|
||||
fn add [container key @values]{
|
||||
use ./list
|
||||
local:values = (list:to-list $values)
|
||||
var values = (list:to-list $values)
|
||||
if (has-key $container $key) {
|
||||
container[$key] = [(all $container[$key]) $@values]
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@ fn -splitm [o]{ each [e]{ put -$e } $o[1:] }
|
||||
|
||||
fn -splitl [o]{
|
||||
if (str:contains $o '=') {
|
||||
local:opt @local:value = (str:split '=' $o)
|
||||
var opt @value = (str:split '=' $o)
|
||||
put $opt
|
||||
str:join '=' $value
|
||||
} else {
|
||||
@ -30,15 +30,15 @@ fn split [o]{
|
||||
}
|
||||
|
||||
fn -joins [opt]{
|
||||
local:o = (each [o]{ put $o[1:] } $opt | str:join '')
|
||||
var o = (each [o]{ put $o[1:] } $opt | str:join '')
|
||||
if (not-eq $o '') { put -$o }
|
||||
}
|
||||
|
||||
fn join [@opt]{
|
||||
local:opt = (list:-p $@opt)
|
||||
local:cb = [o]{ or (is-soption $o) (is-moptions $o) }
|
||||
local:idx = [(list:filter-index-not $cb $opt)]
|
||||
local:i0 = 0
|
||||
var opt = (list:-p $@opt)
|
||||
var cb = [o]{ or (is-soption $o) (is-moptions $o) }
|
||||
var idx = [(list:filter-index-not $cb $opt)]
|
||||
var i0 = 0
|
||||
each [i]{
|
||||
-joins $opt[{$i0}:$i]
|
||||
put $opt[$i]
|
||||
@ -52,14 +52,13 @@ fn expand [@argv]{ each $split~ (list:-p $@argv) }
|
||||
fn map [@argv]{
|
||||
use ./map
|
||||
argv = [(expand $@argv)]
|
||||
local:result = [&]
|
||||
local:i local:c = 0 (count $argv)
|
||||
var result i c = [&] 0 (count $argv)
|
||||
while (< $i $c) {
|
||||
local:o = $argv[$i]
|
||||
var o = $argv[$i]
|
||||
if (is-option $o) {
|
||||
local:k local:v = $o []
|
||||
var k v = $o []
|
||||
if (< $i (- $c 1)) {
|
||||
local:e = $argv[(+ $i 1)]
|
||||
var e = $argv[(+ $i 1)]
|
||||
if (not (is-option $e)) {
|
||||
v = [$@v $e]
|
||||
i = (+ $i 1)
|
||||
|
@ -6,8 +6,8 @@ fn -repeat [n s]{
|
||||
}
|
||||
|
||||
fn left [size s]{
|
||||
local:ss = (count $s)
|
||||
local:d = (- $size $ss)
|
||||
var ss = (count $s)
|
||||
var d = (- $size $ss)
|
||||
if (<= $d 0) {
|
||||
put $s[:$size]
|
||||
} else {
|
||||
@ -16,8 +16,8 @@ fn left [size s]{
|
||||
}
|
||||
|
||||
fn right [size s]{
|
||||
local:ss = (count $s)
|
||||
local:d = (- $size $ss)
|
||||
var ss = (count $s)
|
||||
var d = (- $size $ss)
|
||||
if (<= $d 0) {
|
||||
put $s[:$size]
|
||||
} else {
|
||||
@ -27,15 +27,15 @@ fn right [size s]{
|
||||
|
||||
fn center [size s]{
|
||||
use math
|
||||
local:ss = (count $s)
|
||||
local:d = (- $size $ss)
|
||||
var ss = (count $s)
|
||||
var d = (- $size $ss)
|
||||
if (<= $d 0) {
|
||||
local:l = (math:ceil (/ -$d 2))
|
||||
local:r = (- (+ $ss $d) $l)
|
||||
var l = (math:ceil (/ -$d 2))
|
||||
var r = (- (+ $ss $d) $l)
|
||||
put $s[$l':'$r]
|
||||
} else {
|
||||
local:l = (math:ceil (/ $d 2))
|
||||
local:r = (- $d $l)
|
||||
var l = (math:ceil (/ $d 2))
|
||||
var r = (- $d $l)
|
||||
put (-repeat $l ' ')$s(-repeat $r ' ')
|
||||
}
|
||||
}
|
||||
@ -46,8 +46,8 @@ fn -c2map [col]{
|
||||
return
|
||||
}
|
||||
list:loop [i c]{
|
||||
local:k = (kind-of $c)
|
||||
local:cf = [&min=0]
|
||||
var k = (kind-of $c)
|
||||
var cf = [&min=0]
|
||||
if (is $k string) {
|
||||
cf[min] = $c
|
||||
} elif (is $k map) {
|
||||
@ -65,19 +65,18 @@ fn -c2map [col]{
|
||||
|
||||
fn -parsecols [col &split=$false lst]{
|
||||
col = (-c2map $col)
|
||||
local:cc = (count $col)
|
||||
local:lines = $lst
|
||||
var cc lines = (count $col) $lst
|
||||
if $split {
|
||||
lines = [ (eawk [_ @args]{ put $args } $lst) ]
|
||||
}
|
||||
each [l]{
|
||||
local:cl = (count $l)
|
||||
var cl = (count $l)
|
||||
if (> $cl $cc) {
|
||||
col = [ $@col (range (- $cl $cc) | each [_]{ put [&align=left &min=0] }) ]
|
||||
cc = $cl
|
||||
cc = $cl
|
||||
}
|
||||
list:loop [i c]{
|
||||
local:ccl = (+ (count $c) 1)
|
||||
var ccl = (+ (count $c) 1)
|
||||
if (> $ccl $col[$i][min]) {
|
||||
col[$i][min] = $ccl
|
||||
}
|
||||
@ -87,9 +86,9 @@ fn -parsecols [col &split=$false lst]{
|
||||
}
|
||||
|
||||
fn -format [f e]{
|
||||
local:cb = $left~
|
||||
var cb = $left~
|
||||
if (has-key $f align) {
|
||||
local:a = $f[align]
|
||||
var a = $f[align]
|
||||
if (is $a right) {
|
||||
cb = $right~
|
||||
} elif (is $a center) {
|
||||
@ -106,7 +105,7 @@ fn -formatline [col line]{
|
||||
}
|
||||
|
||||
fn format [&col=[] &split=$false @lst]{
|
||||
local:lines = (list:-p $@lst)
|
||||
var lines = (list:-p $@lst)
|
||||
if $split {
|
||||
lines = [ (eawk [l @args]{ put $args } $lines) ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user