Skip to content

Commit c2271ba

Browse files
committed
acme
0 parents  commit c2271ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+886
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.DS_Store

LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2017, Ev Bogdanov
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of the copyright holder nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Acme text editor
2+
3+
![Acme text editor](./acme.png)
4+
5+
Acme is a Zen-style text editor.
6+
7+
Using Acme you sacrifice:
8+
- configuration files
9+
- themes
10+
- syntax highlighting
11+
- autocompletion
12+
- specific language support
13+
- *your favourite Vim/Emacs/Sublime feature* :trollface:
14+
15+
What you gain is that instead of spending too much time configuring your editor, you will focus on actual working.
16+
17+
The killer feature of Acme is how it integrates into surrounding system. Acme is not trying to be a complete environment by itself. Acme acts as a glue which links together other programs and tools. With Acme the OS becomes your IDE.
18+
19+
## Install
20+
21+
### FreeBSD
22+
```
23+
pkg install plan9port
24+
```
25+
26+
### macOS
27+
```
28+
brew install plan9port
29+
```
30+
31+
### Debian
32+
```
33+
sudo apt-get install gcc libx11-dev libxt-dev libxext-dev libfontconfig1-dev
34+
git clone https://github.com/9fans/plan9port $HOME/plan9
35+
cd $HOME/plan9/plan9port
36+
./INSTALL -r $HOME/plan9
37+
```
38+
39+
## Environment setup
40+
41+
### Bash
42+
```
43+
export PLAN9="/path/to/plan9port"
44+
export PATH="$PATH:$PLAN9/bin"
45+
```
46+
47+
### Tcsh
48+
```
49+
setenv PLAN9 /path/to/plan9port
50+
set path = ($path $PLAN9/bin)
51+
```
52+
53+
## Font
54+
55+
Run font server:
56+
```
57+
fontsrv
58+
```
59+
60+
In case it's not installed:
61+
```
62+
cd /path/to/plan9port/src/cmd/fontsrv/
63+
9 mk install
64+
```
65+
66+
Have a look at all available fonts:
67+
```
68+
9p ls font
69+
```
70+
71+
Try one of them:
72+
```
73+
acme -f /mnt/font/'Droid Sans Mono'/13a/font
74+
```
75+
76+
## Run
77+
78+
I spawn Acme by running `a` script.
79+
80+
## Scripts
81+
82+
Who is who in **bin** directory:
83+
84+
- `+ EXP` lisp-style polish notation calculator; example: `+ '(+ 1 2 3)'`
85+
- `F`, `lne`, `lpe`, `ne`, `pe` perl one-liners shortcuts
86+
- `a` start Acme
87+
- `a+ SYMBOL` alignment (default is fat comma: `|a+ '=>'`, erlang proplist: `|a+ ' '`)
88+
- `c+ SYMBOL` add comment (perl: `|c+` or `|c+ '#'`, erlang: `|c+ %`, js: `|c+ //`)
89+
- `c- SYMBOL` delete comment (perl/erlang: `|c-`, js: `|c- //`)
90+
- `cc+` snake_case to CamelCase
91+
- `cc-` CamelCase to snake_case
92+
- `d` works like `Edit , d`
93+
- `eman MODULE` shortcut for `erl -man MODULE` (displays the manual page for the Erlang module MODULE)
94+
- `g+ WHAT` recursively grep current directory
95+
- `git+ MESSAGE` git: commit and push to master
96+
- `h+` transform line to heading
97+
- `hg+ MESSAGE` hg: commit and push to master
98+
- `html+` html boilerplate
99+
- `lc+` to lowercase
100+
- `nobs+` is taken from plan9 `nobs` (it removes all backspace characters and the characters that precede them)
101+
- `perl+` perl boilerplate (shebang, `use strict` etc)
102+
- `put+ BROWSER` regular `Put` plus reload active tab in browser: `ff` | `ch` | `sa`
103+
- `s-` remove leading whitespace
104+
- `s2t N_SPACES` spaces to tabs (default: 4 spaces to 1 tab)
105+
- `t2s N_SPACES` tabs to spaces (default: 1 tab to 4 spaces)
106+
- `t+` add tab
107+
- `t-` delete tab
108+
- `uc+` to uppercase
109+
- `w+ WIDTH` (hello, `fmt -w WIDTH`)
110+
111+
Put these guys in your **$path**.
112+
113+
## Random notes
114+
115+
- `Edit =` find out the current line number
116+
- `:13` goto 13th line
117+
- `:0` goto file beginning
118+
- `:$` goto file end
119+
- `:0,$` or `:,` or `Edit ,` select the whole file
120+
- `:1,5` select lines 1..5
121+
- `Edit , d` clear window
122+
- `Edit , < echo hello world` replace window body with some text
123+
- `Edit , < erl -man maps` replace window body with erlang manual
124+
- `Edit , s/text/TEXT/g` or `Edit , | perl -pe 's/text/TEXT/g'` global replace
125+
- `$%` or `$samfile` current file name
126+
- `$winid` current window id
127+
- `echo some text | 9p write acme/$winid/body` append to the end of current window
128+
- keyboard shortcuts:
129+
- `ctrl-u` delete from cursor to start of line
130+
- `ctrl-w` delete word before the cursor
131+
- `ctrl-h` delete character before the cursor
132+
- `ctrl-a` move cursor to start of the line
133+
- `ctrl-e` move cursor to end of the line
134+
- `ctrl-i` tab
135+
- `ctrl-j` enter
136+
- `ctrl-f` filepath autocompletion
137+
- `fn-*left arrow*` go home (macOS)
138+
- `fn-*right arrow*` go end (macOS)
139+
- `:foobar` search forward
140+
- `:-/foobar` search backwards
141+
- press `esc` to select the last typed text
142+
- press `esc` again to delete any selected text
143+
- `Font` switch between fonts
144+
- `:/^hel` regexp match: lines starting with 'hel'
145+
- `:/lo\n/` regexp match: lines ending with 'lo'
146+
- `:/^b/,/^e/` regexp match: lines between starting with 'b' and starting with 'e'
147+
- `Dump` write the state of acme to the file
148+
- `Load` restore from the dump
149+
- `Edit , > perl` pipe window body through perl interpreter (better than `perl -e ...`)
150+
151+
## Sam commands
152+
153+
- `Edit +/hello/` search 'hello' forward
154+
- `Edit -/hello/` search 'hello' backward
155+
- `Edit , > wc -l` count lines in file
156+
- `Edit , | sort` sort lines
157+
- `Edit 3,5p` print lines 3..5 in new window
158+
- `Edit 3,5 |uc+` lines 3..5 upper cased
159+
- `Edit 3,5 s/HE/he/g` replace on 3..5 lines only
160+
- `Edit 2 d` delete second line
161+
- `Edit 2 a/new\n/` append text after 2nd line
162+
- `Edit 2 i/new\n/` insert text before 2nd line
163+
164+
## Cut / Copy selection to a file
165+
166+
- select some text
167+
- cut: `| sed '' > file.txt`
168+
- copy: `> sed '' > file.txt`
169+
- pipe selection to a file: `> awk '{ print(toupper($1)) }' | sort | nl > file.txt`
170+
171+
## Other Plan9 goodies
172+
173+
- `win` start shell in a new window
174+
- `page FILE` view graphics files
175+
- `web URL` open url in your browser
176+
177+
## Resources
178+
179+
- [Acme homepage](http://acme.cat-v.org/)
180+
- [A Tour of the Acme Editor](http://www.youtube.com/watch?v=dP1xVpMPn8M)
181+
- [Plan 9 Acme Intro](http://www.youtube.com/watch?v=dopu3ZtdCsg)
182+
- [On using Acme as a day-to-day text editor](http://jlouisramblings.blogspot.ru/2013/04/acme-as-editor_20.html)
183+
- [Let’s Try Acme](http://echosa.github.io/blog/categories/acme/)
184+
- [Plan 9 configuration](https://github.com/jlouis/plan9-setup)
185+
- [Extensibility in the Acme text editor](http://www.mostlymaths.net/2013/03/extensibility-programming-acme-text-editor.html)
186+
- [Plan 9 from User Space](https://github.com/9fans/plan9port)
187+
- [Community: 9fans](http://plan9.bell-labs.com/wiki/plan9/9fans/index.html)
188+
- [Google group: plan9port-dev](https://groups.google.com/forum/#forum/plan9port-dev)
189+
- [Plan 9 and FreeBSD](https://forums.freebsd.org/threads/rio.29736/)

acme.png

425 KB
Loading

bin/+

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use feature 'say';
6+
7+
sub do_calc {
8+
my ($op, $acc, @args) = @_;
9+
for my $arg (@args) {
10+
$acc += $arg if $op eq '+';
11+
$acc -= $arg if $op eq '-';
12+
$acc *= $arg if $op eq '*';
13+
$acc /= $arg if $op eq '/';
14+
}
15+
return $acc;
16+
}
17+
18+
sub calc {
19+
my $exp = shift;
20+
die 'oops!' unless $exp =~ m/\(([\+-\/\*])([0-9 \.-]+)\)/;
21+
return do_calc($1, split ' ', $2);
22+
}
23+
24+
sub pn {
25+
my $exp = shift;
26+
my $old = $exp;
27+
$exp =~ s/(\([\+-\/\*] [0-9 \.-]+\))/calc($1)/eg;
28+
die "oops! i'm stuck" if $exp eq $old;
29+
return $exp if $exp =~ m/^[0-9 \.-]+$/;
30+
return pn($exp);
31+
}
32+
33+
say pn($ARGV[0]);

bin/F

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ $# -eq 1 ]]; then
4+
perl -C -Mutf8 -lanE "$1"
5+
6+
elif [[ $# -eq 2 ]]; then
7+
if [[ -f "$2" ]]; then
8+
perl -C -Mutf8 -lanE "$1" "$2"
9+
else
10+
perl -C -Mutf8 -F''"$1"'' -lanE "$2"
11+
fi
12+
13+
elif [[ $# -eq 3 && -f "$3" ]]; then
14+
perl -C -Mutf8 -F''"$1"'' -lanE "$2" "$3"
15+
fi

bin/a

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
export SHELL="$PLAN9/bin/rc"
4+
export acmeshell="$PLAN9/bin/rc"
5+
export BROWSER=safari
6+
export tabstop=4
7+
export TERM=dumb
8+
export PAGER=nobs
9+
10+
if [ "$(pgrep plumber)" ]; then
11+
echo plumber is running
12+
else
13+
echo starting plumber
14+
plumber
15+
cat "$HOME/acme/plumbing" "$PLAN9/plumb/basic" | 9p write plumb/rules
16+
fi
17+
18+
acme -a -f /mnt/font/Menlo-Regular/12a/font $1

bin/a+

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use utf8;
6+
use open qw(:std :utf8);
7+
8+
my ($d) = @ARGV;
9+
$d = "=>" unless $d;
10+
11+
my $max = 0;
12+
my @ls = ();
13+
my @rs = ();
14+
my $i = 1;
15+
my $t = "";
16+
17+
while (<STDIN>) {
18+
if ($i == 1) {
19+
$t = $1 if /^(\s+)/;
20+
$i += 1;
21+
}
22+
$_ =~ s/^\s+|\s+$//g;
23+
my @ls_rs = split $d, $_, 2;
24+
my $len = length $ls_rs[0];
25+
$max = $len if $len > $max;
26+
push @ls, $ls_rs[0];
27+
push @rs, $ls_rs[1];
28+
}
29+
30+
for (my $i = 0; $i < @ls; $i += 1) {
31+
my $l = $ls[$i];
32+
my $r = $rs[$i];
33+
my $n = $max - length $l;
34+
my $s = " " x $n;
35+
$l .= $s;
36+
print $t, $l, $d, $r;
37+
print "\n" unless $i + 1 == @ls;
38+
}

bin/c+

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env perl
2+
3+
my ($symbol) = @ARGV;
4+
5+
# default: | c+ '#'
6+
$symbol = '#' unless $symbol;
7+
8+
while (<STDIN>) {
9+
print "$symbol$_";
10+
}

bin/c-

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env perl
2+
3+
# default: 1 symbol comment: #, %
4+
# need ARGV for comments like this: //
5+
6+
my ($symbol) = @ARGV;
7+
8+
my $offset = $symbol ? length $symbol : 1;
9+
10+
while (<STDIN>) {
11+
print substr $_, $offset;
12+
}

bin/cc+

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env perl
2+
3+
while (<STDIN>) {
4+
print join "", map { ucfirst $_ } (split "_", $_);
5+
}

bin/cc-

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env perl
2+
3+
while (<STDIN>) {
4+
s/([A-Z]+)([A-Z][a-z])/$1_$2/g;
5+
s/([a-z\d])([A-Z])/$1_$2/g;
6+
print lc;
7+
}

bin/d

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env perl
2+
3+
open FH, "| 9p write acme/$ENV{winid}/addr";
4+
print FH ",";
5+
system "9p write acme/$ENV{winid}/data </dev/null";

bin/eman

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if [ $# -ne 1 ]
4+
then
5+
echo 'gimme erlang module, pls'
6+
exit 1
7+
fi
8+
9+
erl -man "$1" | nobs+

0 commit comments

Comments
 (0)