help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to navigate to next git conflict?


From: Hi-Angel
Subject: Re: How to navigate to next git conflict?
Date: Thu, 7 Feb 2019 00:22:39 +0300

On Wed, 6 Feb 2019 at 18:30, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> >> >   (condition-case err
> >> >       (not (smerge-next))
> >> >     ('error
> >> This catches both the `error` and the `quote` conditions.
> > What is "quote condition"?
>
> I don't know of any `quote` condition, indeed.  Yet that's what you
> wrote in your code by placing a spurious ' in front of `error`.
>
> When you write
>
>     'error
>
> it is 100% indistinguishable from writing
>
>     (quote error)
>
> so this is the list of conditions your code catches.  If you only want
> to catch `error` then you can write
>
>      (condition-case ...
>          ...
>        (error ...))
> or
>      (condition-case ...
>          ...
>        ((error) ...))
>
> > FWIW, it's very hard to find how to catch some "error".
>
> Have you looked in the Emacs Lisp documentation included in Emacs,
> e.g. in the Emacs Lisp Introduction?

Hmm, yes. Now that I look back at the docs, there is an example of
that, right at beginning. It is on this page
https://www.gnu.org/software/emacs/manual/html_node/elisp/Handling-Errors.html

I guess the problem is that catching an error by writing "error" on
one of condition branches looks like magic, because it the word
"error" supposed to evaluate to something.

So, what happened, is that I read the example, it didn't make any
sense (even more so because I didn't know at that moment about
existence of "error", and thought smerge is using "throw"), and then I
scrolled down (and completely discarded the example from my memory as
useless) through other code examples on this page, found
condition-case use for catching arithmetic error, and figured I need
to use this construction (somewhere then I found that smerge is using
"error" and not "throw"). However the part of docs for the
condition-case don't have examples beside arithmetic error, so I went
googling.

When I found on someone's blog use of "quote error" in condition, it
made sense, because 'error does not evaluate to anything.

In retrospective I guess this "magic error" branch is simply a macro,
that's why it looks so magical.

> > I managed to find this way of doing that in someone's blog post.
>
> Could you warn this blogger about his mistake so it doesn't spread
> yet further?

Sure, I left a comment. FTR the post is here
https://curiousprogrammer.wordpress.com/2009/06/08/error-handling-in-emacs-lisp/



reply via email to

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