unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Hi-Angel <hiangel999@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to navigate to next git conflict?
Date: Thu, 7 Feb 2019 00:22:39 +0300	[thread overview]
Message-ID: <CAHGDjgCphLt4ojfSMuzLqRydQqeQL-uhW2O0VfEnHonEgt6=FA@mail.gmail.com> (raw)
In-Reply-To: <jwvd0o57xbk.fsf-monnier+emacs@gnu.org>

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	other threads:[~2019-02-06 21:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  7:51 How to navigate to next git conflict? Hi-Angel
2019-01-29  9:42 ` Stefan Monnier
2019-02-06 11:37   ` Hi-Angel
2019-02-06 14:11     ` Stefan Monnier
2019-02-06 14:47       ` Hi-Angel
2019-02-06 15:30         ` Stefan Monnier
2019-02-06 21:22           ` Hi-Angel [this message]
2019-02-06 21:34             ` tomas
2019-02-10 22:00               ` Hi-Angel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHGDjgCphLt4ojfSMuzLqRydQqeQL-uhW2O0VfEnHonEgt6=FA@mail.gmail.com' \
    --to=hiangel999@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).