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

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

Re: prevent hook vanishing


From: John Mastro
Subject: Re: prevent hook vanishing
Date: Fri, 18 May 2018 08:59:39 -0700

akrl <akrl@sdf.org> wrote:
> > Why not use `condition-case' in your hook function to catch the error
> > and respond appropriately? (There are also `with-demoted-errors' and
> > `ignore-errors', if there's nothing that needs to be except to suppress
> > the error)

> Doesn't quite work. I wrap the hooked code around using ignore-errors,
> then for instance if I get the following error (from *Messages*):
> "Symbol's value as variable is void"
> the hook is wiped out.

Hm, then you may have another problem. The following simple example
works for me:

     (defun boom-after-change (&rest _)
       (ignore-errors (error (message "Boom!"))))

     (add-hook 'after-change-functions #'boom-after-change nil t)

Hope that helps

         John



reply via email to

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