unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jambunathan K <kjambunathan@gmail.com>
Cc: ofv@wanadoo.es, emacs-devel@gnu.org
Subject: Re: unwind-protect not cleaning up?
Date: Sat, 30 Jun 2012 09:09:06 +0300	[thread overview]
Message-ID: <83bok172m5.fsf@gnu.org> (raw)
In-Reply-To: <81bok15psm.fsf@gmail.com>

> From: Jambunathan K <kjambunathan@gmail.com>
> Date: Sat, 30 Jun 2012 11:01:21 +0530
> Cc: emacs-devel@gnu.org
> 
> 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))
      (unwind-protect
	  (/ 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	other threads:[~2012-06-30  6:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-30  0:54 unwind-protect not cleaning up? Jambunathan K
2012-06-30  2:07 ` Óscar Fuentes
2012-06-30  5:31   ` Jambunathan K
2012-06-30  6:09     ` Eli Zaretskii [this message]
2012-07-01 17:47       ` Jambunathan K
2012-07-01 18:01         ` Jambunathan K

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=83bok172m5.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=kjambunathan@gmail.com \
    --cc=ofv@wanadoo.es \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).