[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vile] help with macro
From: |
Brendan O'Dea |
Subject: |
Re: [vile] help with macro |
Date: |
Sat, 16 Aug 2014 16:19:01 +1000 |
On 16 August 2014 11:50, Matthew White <address@hidden> wrote:
> I have written a macro to call "gofmt" (a program which formats Go source
> code)
>
> gofmt will either produce formatted code to stdout or print errors to
> stdout.
It appears to send errors to stderr. In any case, I'd be inclined to
do this a bit more simply:
store-procedure goformat
goto-beginning-of-file
filter-til end-of-file "gofmt"
~endm
If your program disappears, replaced with an error message: hit "u" :-)
The gofmt error format seems sufficiently unique, that you could
automate the undo step on error:
store-procedure goformat
goto-beginning-of-file
filter-til end-of-file "gofmt"
~force search-forward "^<standard input>:.*"
~if $status
undo-change
write-message &cat "Error: " &right $match 18
~else
clear-message-line # "Not found" from search
~endif
~endm
Of course if you *really* wanted to get fancy, you could copy the
error output to "[Error buffer]" before the undo, replace "<standard
input>" with the filename, and invoke next-error to locate the cursor
on the problem line(s)...
--bod