[Top][All Lists]

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

Re: unwind-protect not cleaning up?

From: Eli Zaretskii
Subject: Re: unwind-protect not cleaning up?
Date: Sat, 30 Jun 2012 09:09:06 +0300

> From: Jambunathan K <address@hidden>
> Date: Sat, 30 Jun 2012 11:01:21 +0530
> Cc: address@hidden
> Nothing in the manual suggests that some sort of user-intervention
> is required for recovery.

Because no intervention is needed, in general.  It's just that you
tried to trigger the stack unwinding with something that signals an
error and enters the debugger.  Change your example to this:

  (let ((buffer (get-buffer-create "YOU CANNOT KILL ME")))
    (with-current-buffer buffer
      (let ((eval-expression-debug-on-error nil)
            (debug-on-signal nil))
          (/ 1 0)
        (kill-buffer buffer)))))

and you will get what you expected without any user intervention.

> May be I should be looking at someother API that "guarantees" cleanup
> very much like unwind-protect, without the 'c' part.
> I can use (condition-case VAR BODYFORM &rest HANDLERS) with the cleanup
> happening both in BODYFORM and also in (error ) HANDLER.  I felt that
> unwind-protect construct is more elegant.  Any suggestions...

The popular use for unwind-protect is when the user could C-g inside
the protected form.  For errors such as division by zero,
condition-case is indeed better, as you can run some code when the
error is thrown.

> Btw, if unwind-protect is behaving the right way, manpage needs an
> update...

We don't have manpages in Emacs.  Did you mean the manual?  If so,
what would you suggest to add/update there, in view of the above?

reply via email to

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