Skip to content

Commit

Permalink
acme/Watch: dump first command
Browse files Browse the repository at this point in the history
  • Loading branch information
rakoo committed May 14, 2024
1 parent 03bb196 commit 125f060
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions acme/Watch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ func main() {
win.Name(pwdSlash + "+watch")
win.Ctl("clean")
win.Ctl("dumpdir " + pwd)
cmd := "dump Watch"
if *recursive {
cmd += " -r"
}
win.Ctl(cmd)
win.Fprintf("tag", "Get Kill Quit ")
win.Fprintf("body", "%% %s\n", strings.Join(args, " "))

Expand Down Expand Up @@ -183,6 +178,13 @@ func runSetup(id int) {
win.Addr(",")
win.Write("data", nil)
win.Write("body", []byte(fmt.Sprintf("%% %s\n", strings.Join(args, " "))))

prefix := "dump Watch"
if *recursive {
prefix += " -r"
}
cmd := fmt.Sprintf("%s %s", prefix, strings.Join(args, " "))
win.Ctl(cmd)
} else {
end, endByte := utf8.RuneCount(data), len(data)
for i := len(matches) - 1; i >= 0; i-- {
Expand All @@ -197,6 +199,17 @@ func runSetup(id int) {
win.Write("data", nil)
}
end, endByte = mStart, m[0]

// Remember first command only
if i == 0 {
c := strings.TrimSpace(string(data[m[0]+1 : m[1]])) // skip %
prefix := "dump Watch"
if *recursive {
prefix += " -r"
}
cmd := fmt.Sprintf("prefix %s", prefix, c)
win.Ctl(cmd)
}
}
if end > 0 {
win.Addr(",#%d", end)
Expand Down

0 comments on commit 125f060

Please sign in to comment.