[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ignore-error?
From: |
Lars Ingebrigtsen |
Subject: |
Re: ignore-error? |
Date: |
Mon, 15 Jul 2019 15:36:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> It seems like people like writing `ignore-errors' a lot more than
>> `condition-case', and I think `ignore-errors' is the wrong thing to say
>> 90% of the time.
>
> I agree, but I think in 99% of those cases, the author has no idea which
> error might need to be caught.
That's true. If only Emacs Lisp had... checked exceptions. *runs
away*
*then returns*
But it sure would be nice if we had some way of telling at least some of
the errors that a function can raise...
>> So would it be a good idea to add a new convenience macro `ignore-error'
>> to entice people to not use `ignore-errors' so much? It would take an
>> error condition as its parameter, so:
>>
>> (ignore-error 'file-error
>> (directory-files dir))
>
> [ I think the argument shouldn't be quoted. ]
True.
> More importantly, if you want me to use this, you'll have to improve
> elisp-mode's completion so it DTRT for the error symbol, like it does in
> condition-case.
Let's see... It this stuff?
((and (or 'condition-case 'condition-case-unless-debug)
(guard (save-excursion
(ignore-errors
(forward-sexp 2)
(< (point) beg)))))
(list t obarray
:predicate (lambda (sym) (get sym
'error-conditions))))
Sure, that should be simple enough to cargo cult for the new macro, I
think.
The parameter should perhaps also be allowed to be a list of symbols:
(ignore-error (file-error some-other-error)
(foo))
?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no