Hi Bram!
On Mo, 08 Feb 2016, Bram Moolenaar wrote:
> Anton Lindqvist wrote:
>
> > This is a result of a previous discussion[1] which concluded that a
> > more general Error autocmd event would be a better addition than the
> > proposed TagNotFound event.
> >
> > Questions and comments regarding the patch in no particular order:
> >
> > - Is the addition to the main_loop function at a suitable location?
> >
> > - The error code (emsg_code) is the actual code including the 'E' prefix.
> > Another solution is to use the numerical representation of the error code.
> >
> > - The get_error_pat function is used to translate error codes into something
> > more descriptive. As of writing this only one such mapping is
> > present. We could either ensure that all possible error codes has a
> > mapping or add them on demand. The function is doing a linear search
> > of error_pats. If the error code is represented as an int this could
> > be replaced with a constant lookup if the array index is equal to
> > the error code:
> >
> > static const char *error_pat[] = {
> > [426] = "tagnotfound",
> > }
> >
> > If mappings of all possible error codes is present the array won't end up
> > being that sparse.
> >
> > The existing solution (representing error codes as string) could also be
> > improved by replacing the linear search with a binary search.
> >
> > - If no mapping of the error code to pattern is found the actual error
> > code is used as the amatch argument when triggering the Error event.
> >
> > [1] https://groups.google.com/d/msg/vim_dev/XzhNNjbtfow/u6BWsne4CwAJ
>
> I am wondering if this is really a useful solution.
>
> At least in scripts one can already use try/catch to deal with errors.
> Thus this patch is mainly for when typing commands.
>
> The original reason was to handle an error for a tag lookup. With the
> solution the tag lookup will still fail. It can trigger rebuilding the
> tags file, but for most users it will be quite unexpected that trying to
> jump to the same tag suddenly works a bit later.
But only, if the user did setup the Error autocommand. So he should
expect that, right?
> Can you think of a command or situation where this patch provides a
> nice, useful solution?
I think, it has come up in the past before:
- Catching E482/E484/E485 because /tmp got cleaned out would be
possible.
https://groups.google.com/d/msg/vim_use/qgRob9SWDv8/FAOFVVcDTv0J
- https://groups.google.com/d/msg/vim_dev/EbTWqBl2rdw/vT4fTaGFnMoJ
- and possibly others, which I don't remember currently.
Best,
Christian
--
Treffen sich Kinkel und Hinze im Magen von Kohl.
Sagt Kinkel: "Ich glaube, der Kohl hat mich gefressen."
Darauf Hinze: "Kann ich nichts zu sagen, ich kam von der anderen
Seite rein."
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.