Skip to content

Commit a6fe3ff

Browse files
deploy: 2516a05
0 parents  commit a6fe3ff

37 files changed

Lines changed: 16364 additions & 0 deletions

.nojekyll

Whitespace-only changes.

04_exhash.html

Lines changed: 738 additions & 0 deletions
Large diffs are not rendered by default.

04_exhash.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
2+
3+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
4+
5+
The quick brown fox jumps over the lazy dog. Jackdaws love my big sphinx
6+
of quartz. Pack my box with five dozen liquor jugs. How vexingly quick
7+
daft zebras jump! The five boxing wizards jump quickly. Sphinx of black
8+
quartz, judge my vow. Two driven jocks help fax my big quiz. Bright
9+
vixens jump; dozy fowl quack.
10+
11+
``` python
12+
msg = await read_msg()
13+
id_ = msg.id
14+
cts = msg.content
15+
```
16+
17+
------------------------------------------------------------------------
18+
19+
<a
20+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L12"
21+
target="_blank" style="float:right; font-size:smaller">source</a>
22+
23+
### msg_lnhashview
24+
25+
``` python
26+
27+
async def msg_lnhashview(
28+
id:str
29+
):
30+
31+
```
32+
33+
*Show lnhash-addressed lines of a message*
34+
35+
------------------------------------------------------------------------
36+
37+
<a
38+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L18"
39+
target="_blank" style="float:right; font-size:smaller">source</a>
40+
41+
### msg_exhash
42+
43+
``` python
44+
45+
async def msg_exhash(
46+
id:str, cmds:list
47+
):
48+
49+
```
50+
51+
*Verified line-addressed editor. Apply commands to msg `id` contents,
52+
return lnhashview(result).* **NB**: *all* exhash commands *must* start
53+
with an address. The *only* allowed addresses are a single lnhash, or a
54+
pair separated by `,`. (I.e no `%`, `.`, etc.) **NB**: hashes are
55+
checked before each command is run. So be sure to have commands go
56+
last-\>first order to avoid changing earlier lines.
57+
58+
Commands are like `ex`, but use lnhash addresses instead of bare line
59+
numbers: `lineno|hash|cmd` where hash is a 4-char hex content hash. Use
60+
`msg_lnhashview(text)` to get addresses before first use.
61+
62+
Addressing: Single: `12|a3f2|cmd` Range: `12|a3f2|,15|b1c3|cmd` Special:
63+
`0|0000|` targets before line 1 (only with a or i)
64+
65+
Commands: s/pat/rep/\[flags\] Substitute (regex). Flags: g=all,
66+
i=case-insensitive d Delete line(s) a Append text after line i Insert
67+
text before line c Change/replace line(s) j Join with next line; with
68+
range, joins all m dest Move line(s) after dest address t dest Copy
69+
line(s) after dest address \>\[n\] Indent n levels (default 1, 4 spaces
70+
each) \<\[n\] Dedent n levels (default 1) sort Sort lines alphabetically
71+
p Print (include in output without changing) g/pat/cmd Global: run cmd
72+
on matching lines g!/pat/cmd Inverted global (also v/pat/cmd)
73+
74+
`cmds` is a required list of command strings. For `a`/`i`/`c`, include
75+
the text block in the same command string after a newline.
76+
77+
------------------------------------------------------------------------
78+
79+
<a
80+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L58"
81+
target="_blank" style="float:right; font-size:smaller">source</a>
82+
83+
### file_lnhashview
84+
85+
``` python
86+
87+
def file_lnhashview(
88+
path:str
89+
):
90+
91+
```
92+
93+
*Show lnhash-addressed lines of a file*
94+
95+
------------------------------------------------------------------------
96+
97+
<a
98+
href="https://github.com/AnswerDotAI/dialoghelper/blob/main/dialoghelper/exhash.py#L63"
99+
target="_blank" style="float:right; font-size:smaller">source</a>
100+
101+
### file_exhash
102+
103+
``` python
104+
105+
def file_exhash(
106+
path:str, cmds:list
107+
):
108+
109+
```
110+
111+
*Verified line-addressed editor for files. Apply commands to file at
112+
`path`, return lnhashview(result).* See `doc(msg_lnhashview)` for
113+
details
114+
115+
``` python
116+
tp = Path('tmp.txt')
117+
tp.write_text(cts)
118+
```
119+
120+
313
121+
122+
Try indenting the first 3 lines of this file with
123+
&`[file_lnhashview,file_exhash]`.
124+
125+
##### 🤖Reply🤖<!-- SOLVEIT_SEPARATOR_7f3a9b2c -->
126+
127+
<details class="tool-usage-details">
128+
129+
<summary>
130+
131+
file_lnhashview(path=‘tmp.txt’)
132+
</summary>
133+
134+
``` json
135+
{
136+
"id": "toolu_01T723e8w3tcYjgdEwNopV18",
137+
"call": {
138+
"function": "file_lnhashview",
139+
"arguments": {
140+
"path": "tmp.txt"
141+
}
142+
},
143+
"result": "1|da2a| The quick brown fox jumps over the lazy dog.\n2|32e4| Jackdaws love my big sphinx of quartz.\n3|04e4| Pack my box with five dozen liquor jugs.\n4|025f| How vexingly quick daft zebras jump!\n5|c720| The five boxing wizards jump quickly.\n6|0666| Sphinx of black quartz, judge my vow.\n7|d61c| Two driven jocks help fax my big quiz.\n8|bc1b| Bright vixens jump; dozy fowl quack."
144+
}
145+
```
146+
147+
</details>
148+
149+
<details class="tool-usage-details">
150+
151+
<summary>
152+
153+
file_exhash(path=‘tmp.txt’, cmds=\[‘1|da2a|,3|04e4|\>\])
154+
</summary>
155+
156+
``` json
157+
{
158+
"id": "toolu_01QdybzYCodQBHB5WKMo7Z92",
159+
"call": {
160+
"function": "file_exhash",
161+
"arguments": {
162+
"path": "tmp.txt",
163+
"cmds": "['1|da2a|,3|04e4|>']"
164+
}
165+
},
166+
"result": "1|dfab| The quick brown fox jumps over the lazy dog.\n2|e110| Jackdaws love my big sphinx of quartz.\n3|a4ce| Pack my box with five dozen liquor jugs.\n4|025f| How vexingly quick daft zebras jump!\n5|c720| The five boxing wizards jump quickly.\n6|0666| Sphinx of black quartz, judge my vow.\n7|d61c| Two driven jocks help fax my big quiz.\n8|bc1b| Bright vixens jump; dozy fowl quack."
167+
}
168+
```
169+
170+
</details>
171+
172+
Done — first 3 lines are now indented. You can see the hashes changed
173+
for those lines (`da2a``dfab`, etc.) since the content now includes
174+
leading spaces.
175+
176+
``` python
177+
print(tp.read_text())
178+
```
179+
180+
The quick brown fox jumps over the lazy dog.
181+
Jackdaws love my big sphinx of quartz.
182+
Pack my box with five dozen liquor jugs.
183+
How vexingly quick daft zebras jump!
184+
The five boxing wizards jump quickly.
185+
Sphinx of black quartz, judge my vow.
186+
Two driven jocks help fax my big quiz.
187+
Bright vixens jump; dozy fowl quack.
188+
189+
``` python
190+
tp.unlink()
191+
```

0 commit comments

Comments
 (0)