vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] help with macro


From: Matthew White
Subject: Re: [vile] help with macro
Date: Mon, 18 Aug 2014 10:38:00 -0700

On Fri, Aug 15, 2014 at 11:19 PM, Brendan O'Dea <address@hidden> wrote:
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)...

OK so I'm trying to get fancy.

I've found the LoadErrorExprs macro to load the following _expression_ into '[Error Expresions]'

^<standard input>:%L:%C:%T

(I've also tried simply ':%L:%C:' and that didn't work either)

I've verified that the _expression_ is actually showing up in the buffer. I've verified that the sterr from gofmt is making it into the buffer marked as error-buffer (called [gofmt errors])

However, I'm getting this error when I execute my macro:

'[No more errors in [gofmt errors] buffer]'

I'm guessing that the _expression_ isn't matching the error string, but I can't see what I'm doing wrong.

For reference the error strings look like this:

<standard input>:7:1: expected _expression_

/home/mtw/src/test.go:7:1:expected _expression_

Cheers,

-mtw


 

--bod


reply via email to

[Prev in Thread] Current Thread [Next in Thread]