Start killing Perl
This commit is contained in:
parent
780128f55f
commit
3aa6845583
7 changed files with 4 additions and 66 deletions
10
README.md
10
README.md
|
|
@ -81,12 +81,10 @@ I spawn Acme by running `a` script.
|
|||
|
||||
Who is who in **bin** directory:
|
||||
|
||||
- `+ EXP` lisp-style polish notation calculator; example: `+ '(+ 1 2 3)'`
|
||||
- `F`, `lne`, `lpe`, `ne`, `pe` perl one-liners shortcuts
|
||||
- `a` start Acme
|
||||
- `a+ SYMBOL` alignment (default is fat comma: `|a+ '=>'`, erlang proplist: `|a+ ' '`)
|
||||
- `c+ SYMBOL` add comment (perl: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
|
||||
- `c- SYMBOL` delete comment (perl/erlang: `|c-`, js: `|c- //`)
|
||||
- `c+ SYMBOL` add comment (python: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
|
||||
- `c- SYMBOL` delete comment (python/erlang: `|c-`, js: `|c- //`)
|
||||
- `cc+` snake_case to CamelCase
|
||||
- `cc-` CamelCase to snake_case
|
||||
- `d` works like `Edit , d`
|
||||
|
|
@ -120,7 +118,7 @@ Put these guys in your **$path**.
|
|||
- `Edit , d` clear window
|
||||
- `Edit , < echo hello world` replace window body with some text
|
||||
- `Edit , < erl -man maps` replace window body with erlang manual
|
||||
- `Edit , s/text/TEXT/g` or `Edit , | perl -pe 's/text/TEXT/g'` global replace
|
||||
- `Edit , s/text/TEXT/g` or `Edit , | sed 's/text/TEXT/g'` global replace
|
||||
- `$%` or `$samfile` current file name
|
||||
- `$winid` current window id
|
||||
- `echo some text | 9p write acme/$winid/body` append to the end of current window
|
||||
|
|
@ -145,7 +143,7 @@ Put these guys in your **$path**.
|
|||
- `:/^b/,/^e/` regexp match: lines between starting with 'b' and starting with 'e'
|
||||
- `Dump` write the state of acme to the file
|
||||
- `Load` restore from the dump
|
||||
- `Edit , > perl` pipe window body through perl interpreter (better than `perl -e ...`)
|
||||
- `Edit , > python` pipe window body through python interpreter
|
||||
- three-finger tap emulates middle click (macOS)
|
||||
|
||||
## Sam commands
|
||||
|
|
|
|||
33
bin/+
33
bin/+
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
|
||||
sub do_calc {
|
||||
my ($op, $acc, @args) = @_;
|
||||
for my $arg (@args) {
|
||||
$acc += $arg if $op eq '+';
|
||||
$acc -= $arg if $op eq '-';
|
||||
$acc *= $arg if $op eq '*';
|
||||
$acc /= $arg if $op eq '/';
|
||||
}
|
||||
return $acc;
|
||||
}
|
||||
|
||||
sub calc {
|
||||
my $exp = shift;
|
||||
die 'oops!' unless $exp =~ m/\(([\+-\/\*])([0-9 \.-]+)\)/;
|
||||
return do_calc($1, split ' ', $2);
|
||||
}
|
||||
|
||||
sub pn {
|
||||
my $exp = shift;
|
||||
my $old = $exp;
|
||||
$exp =~ s/(\([\+-\/\*] [0-9 \.-]+\))/calc($1)/eg;
|
||||
die "oops! i'm stuck" if $exp eq $old;
|
||||
return $exp if $exp =~ m/^[0-9 \.-]+$/;
|
||||
return pn($exp);
|
||||
}
|
||||
|
||||
say pn($ARGV[0]);
|
||||
15
bin/F
15
bin/F
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
perl -C -Mutf8 -lanE "$1"
|
||||
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
if [[ -f "$2" ]]; then
|
||||
perl -C -Mutf8 -lanE "$1" "$2"
|
||||
else
|
||||
perl -C -Mutf8 -F''"$1"'' -lanE "$2"
|
||||
fi
|
||||
|
||||
elif [[ $# -eq 3 && -f "$3" ]]; then
|
||||
perl -C -Mutf8 -F''"$1"'' -lanE "$2" "$3"
|
||||
fi
|
||||
3
bin/lne
3
bin/lne
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -lnE "$@"
|
||||
3
bin/lpe
3
bin/lpe
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -lpE "$@"
|
||||
3
bin/ne
3
bin/ne
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -nE "$@"
|
||||
3
bin/pe
3
bin/pe
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
perl -C -Mutf8 -pE "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue