From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.bugs Subject: bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect Date: Wed, 13 Jul 2016 08:28:45 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1468391364 17089 80.91.229.3 (13 Jul 2016 06:29:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2016 06:29:24 +0000 (UTC) To: 23963@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 13 08:29:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNDfV-0003ZN-Ga for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 08:29:13 +0200 Original-Received: from localhost ([::1]:45403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDfU-0001wh-AS for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 02:29:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDfO-0001wO-Cy for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:29:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNDfK-0008De-6G for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:29:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDfK-0008Da-2n for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bNDfJ-0006ff-SC for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Markus Triska Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2016 06:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23963 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.146839133925633 (code B ref -1); Wed, 13 Jul 2016 06:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Jul 2016 06:28:59 +0000 Original-Received: from localhost ([127.0.0.1]:48971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNDfG-0006fM-Ps for submit@debbugs.gnu.org; Wed, 13 Jul 2016 02:28:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35371) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNDfF-0006f9-2Q for submit@debbugs.gnu.org; Wed, 13 Jul 2016 02:28:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNDf8-00089r-S7 for submit@debbugs.gnu.org; Wed, 13 Jul 2016 02:28:51 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDf8-00089g-P1 for submit@debbugs.gnu.org; Wed, 13 Jul 2016 02:28:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDf6-0001uK-FM for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:28:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNDf2-00089H-84 for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:28:47 -0400 Original-Received: from metalevel.at ([78.46.218.83]:41316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNDf2-00089A-14 for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 02:28:44 -0400 Original-Received: from dawn.meta (localhost.localdomain [127.0.0.1]) by metalevel.at (Postfix) with ESMTP id 8FD91A05DE for ; Wed, 13 Jul 2016 08:28:42 +0200 (CEST) Original-Received: by dawn.meta (Postfix, from userid 501) id 092571AA32D0; Wed, 13 Jul 2016 08:28:45 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120979 Archived-At: The manual entry of `unwind-protect' shows an example whose essence is: (unwind-protect (progn (setq process (ftp-...)) ;; use process (delete-process process)) It adds the following important explanation: This example has a small [sic] bug: if the user types `C-g' to quit, and the quit happens immediately after the function `ftp-...' returns but before the variable `process' is set, *the process will not be killed*. There is no easy way to fix this bug, but at least it is very unlikely. Would it be good to make such resource leak *impossible* instead? This seems quite desirable and could be done with a complementing primitive. Please consider a new primitive `setup-unwind-protect' with 3 arguments: 1. SETUPFORM, called in such a way that it *cannot be interrupted* 2. BODYFORM, like in unwind-protect, called after SETUPFORM 3. UNWINDFORMS, like in unwind-protect With this primitive, we could write the example above as: (setup-unwind-protect (setq process (ftp-...)) (progn ;; use process ... (delete-process process)) Please consider adding such a construct to Emacs. A precedence for such a construct is setup_call_cleanup/3 which appears in the Prolog ISO draft standard and is already included in many systems: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/N215 Thank you and all the best! Markus In GNU Emacs 25.0.95.4 (x86_64-apple-darwin15.5.0, X toolkit, Xaw scroll bars) of 2016-07-05 built on mt-imac Repository revision: e3b039d1a0e611d6619ed3ce67d125160d644ebc Windowing system distributor 'The X.Org Foundation', version 11.0.11502000 Configured using: 'configure --without-ns CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix