From 3aa68455836096c4e8a287bb7909a5b2064d898e Mon Sep 17 00:00:00 2001 From: Ev Bogdanov Date: Wed, 16 Aug 2017 13:26:49 +0300 Subject: [PATCH] Start killing Perl --- README.md | 10 ++++------ bin/+ | 33 --------------------------------- bin/F | 15 --------------- bin/lne | 3 --- bin/lpe | 3 --- bin/ne | 3 --- bin/pe | 3 --- 7 files changed, 4 insertions(+), 66 deletions(-) delete mode 100755 bin/+ delete mode 100755 bin/F delete mode 100755 bin/lne delete mode 100755 bin/lpe delete mode 100755 bin/ne delete mode 100755 bin/pe diff --git a/README.md b/README.md index 3577acb..eab02c2 100644 --- a/README.md +++ b/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 diff --git a/bin/+ b/bin/+ deleted file mode 100755 index c9eddaa..0000000 --- a/bin/+ +++ /dev/null @@ -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]); diff --git a/bin/F b/bin/F deleted file mode 100755 index b748162..0000000 --- a/bin/F +++ /dev/null @@ -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 diff --git a/bin/lne b/bin/lne deleted file mode 100755 index 35f79e5..0000000 --- a/bin/lne +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -perl -C -Mutf8 -lnE "$@" diff --git a/bin/lpe b/bin/lpe deleted file mode 100755 index 09d671b..0000000 --- a/bin/lpe +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -perl -C -Mutf8 -lpE "$@" diff --git a/bin/ne b/bin/ne deleted file mode 100755 index 02b1223..0000000 --- a/bin/ne +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -perl -C -Mutf8 -nE "$@" diff --git a/bin/pe b/bin/pe deleted file mode 100755 index 93ddc38..0000000 --- a/bin/pe +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -perl -C -Mutf8 -pE "$@"