|
From: | Matthew White |
Subject: | Re: [vile] help with macro |
Date: | Mon, 18 Aug 2014 10:38:00 -0700 |
On 16 August 2014 11:50, Matthew White <address@hidden> wrote:It appears to send errors to stderr. In any case, I'd be inclined to
> 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.
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
[Prev in Thread] | Current Thread | [Next in Thread] |