* prevent hook vanishing @ 2018-05-18 8:23 akrl 2018-05-18 13:58 ` John Mastro [not found] ` <mailman.32.1526651897.1292.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 5+ messages in thread From: akrl @ 2018-05-18 8:23 UTC (permalink / raw) To: help-gnu-emacs Hi all, How do I prevent emacs from removing a hook I've installed using something like: (add-hook 'after-change-functions 'render-buf nil t) in case of an error occur executing it? I would also be fine in being able to reinstall it somehow afterward. Bests akrl -- akrl@sdf.org SDF Public Access UNIX System - https://sdf.org ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: prevent hook vanishing 2018-05-18 8:23 prevent hook vanishing akrl @ 2018-05-18 13:58 ` John Mastro [not found] ` <mailman.32.1526651897.1292.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 5+ messages in thread From: John Mastro @ 2018-05-18 13:58 UTC (permalink / raw) To: Help Gnu Emacs mailing list; +Cc: akrl akrl <akrl@sdf.org> wrote: > How do I prevent emacs from removing a hook I've installed using > something like: (add-hook 'after-change-functions 'render-buf nil t) > in case of an error occur executing it? > I would also be fine in being able to reinstall it somehow afterward. 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) John ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.32.1526651897.1292.help-gnu-emacs@gnu.org>]
* Re: prevent hook vanishing [not found] ` <mailman.32.1526651897.1292.help-gnu-emacs@gnu.org> @ 2018-05-18 14:42 ` akrl 2018-05-18 15:59 ` John Mastro [not found] ` <mailman.42.1526659194.1292.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 5+ messages in thread From: akrl @ 2018-05-18 14:42 UTC (permalink / raw) To: help-gnu-emacs John Mastro <john.b.mastro@gmail.com> writes: > 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) > > John 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. Bests akrl -- akrl@sdf.org SDF Public Access UNIX System - https://sdf.org ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: prevent hook vanishing 2018-05-18 14:42 ` akrl @ 2018-05-18 15:59 ` John Mastro [not found] ` <mailman.42.1526659194.1292.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 5+ messages in thread From: John Mastro @ 2018-05-18 15:59 UTC (permalink / raw) To: Help Gnu Emacs mailing list; +Cc: akrl 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.42.1526659194.1292.help-gnu-emacs@gnu.org>]
* Re: prevent hook vanishing [not found] ` <mailman.42.1526659194.1292.help-gnu-emacs@gnu.org> @ 2018-05-18 21:38 ` akrl 0 siblings, 0 replies; 5+ messages in thread From: akrl @ 2018-05-18 21:38 UTC (permalink / raw) To: help-gnu-emacs John Mastro <john.b.mastro@gmail.com> writes: > 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 Thanks John, that worked perfectly for me now, seems I was wrapping at the wrong level. Bests! akrl -- akrl@sdf.org SDF Public Access UNIX System - https://sdf.org ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-18 21:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-05-18 8:23 prevent hook vanishing akrl 2018-05-18 13:58 ` John Mastro [not found] ` <mailman.32.1526651897.1292.help-gnu-emacs@gnu.org> 2018-05-18 14:42 ` akrl 2018-05-18 15:59 ` John Mastro [not found] ` <mailman.42.1526659194.1292.help-gnu-emacs@gnu.org> 2018-05-18 21:38 ` akrl
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.