From unknown Fri Aug 15 15:55:52 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#33601 <33601@debbugs.gnu.org> To: bug#33601 <33601@debbugs.gnu.org> Subject: Status: 26; Add macro `with-hook-added' Reply-To: bug#33601 <33601@debbugs.gnu.org> Date: Fri, 15 Aug 2025 22:55:52 +0000 retitle 33601 26; Add macro `with-hook-added' reassign 33601 emacs submitter 33601 Drew Adams severity 33601 wishlist tag 33601 wontfix thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 13:47:29 2018 Received: (at submit) by debbugs.gnu.org; 3 Dec 2018 18:47:30 +0000 Received: from localhost ([127.0.0.1]:59397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtFh-0004N3-K0 for submit@debbugs.gnu.org; Mon, 03 Dec 2018 13:47:29 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtFe-0004Mo-G2 for submit@debbugs.gnu.org; Mon, 03 Dec 2018 13:47:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTtFY-0003qG-C7 for submit@debbugs.gnu.org; Mon, 03 Dec 2018 13:47:21 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:34891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTtFY-0003qB-8l for submit@debbugs.gnu.org; Mon, 03 Dec 2018 13:47:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTtFX-0004Mg-0y for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:47:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTtFT-0003oA-RQ for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:47:18 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTtFT-0003nb-I3 for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 13:47:15 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3IcWHI050474 for ; Mon, 3 Dec 2018 18:47:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=GZ1v0b9JZpZqY7T1c2FvSx8EYSs70YXYIMf/R7oIj1A=; b=wolZhwBFzU6LdVloep0eup0Wyg0XT/TczJzFxXezdLc8SU8MYlw8tOQjYNOkh3JcrHjq lm8d2L7k/hwiU6Y+r56+3ka8UaldpG41rXL3kOwkYG371sZDNwfdtIhvf9hstvzd4mbz cX+9HZhamXTBBe7tPR/ePdIp+h6a/PMLPgrJ8HhivRnso9vpgwbanV1XuWdex0LbVeRh 0GGK9scO3vrLhJnjrK9AcoWzOoFvzpecqvdnevt3aEEI7lAmfAkR0ngChz6RIybxvAvC ZDwY8beHOye8T4PBvxnGIf1NYc9HMnAJlYNJP1gsjEirP9wkzAXH8NcBxpsZroBqTs/v XQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2p3hqtr6fd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 03 Dec 2018 18:47:13 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB3IlD2C005806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 3 Dec 2018 18:47:13 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3IlDCT018859 for ; Mon, 3 Dec 2018 18:47:13 GMT MIME-Version: 1.0 Message-ID: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> Date: Mon, 3 Dec 2018 10:47:12 -0800 (PST) From: Drew Adams To: bug-gnu-emacs@gnu.org Subject: 26; Add macro `with-hook-added' X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030172 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Enhancement request: Please consider adding a macro such as this, to facilitate temporary use of a hook function. (defmacro with-hook-added (hook function &rest body) "Evaluate forms in BODY with FUNCTION added to HOOK, then remove FUNCTION= ." (declare (indent 1) (debug t)) `(unwind-protect (progn (add-hook ',hook ',function) ,@body) (remove-hook ',hook ',function))) In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30 Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea Windowing system distributor `Microsoft Corp.', version 10.0.16299 Configured using: `configure --without-dbus --host=3Dx86_64-w64-mingw32 --without-compress-install 'CFLAGS=3D-O2 -static -g3'' From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 14:01:45 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 19:01:45 +0000 Received: from localhost ([127.0.0.1]:59407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtTU-0004kd-TO for submit@debbugs.gnu.org; Mon, 03 Dec 2018 14:01:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtTS-0004kL-U4 for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 14:01:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTtTI-0001wL-Dt for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 14:01:37 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTtTE-0001ui-7B; Mon, 03 Dec 2018 14:01:28 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1gTtTD-0005E0-0a; Mon, 03 Dec 2018 14:01:27 -0500 From: Glenn Morris To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> X-Spook: Telecommunications Drug Administration Exposure USDOJ X-Ran: l}Z\&,C!Kp~?*5`\iE`d-4OwV(i,TZLI^2wR9#$+"varGdX0r09vM/k?H*$yWk7MOJ)M/| X-Hue: red X-Attribution: GM Date: Mon, 03 Dec 2018 14:01:25 -0500 In-Reply-To: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> (Drew Adams's message of "Mon, 3 Dec 2018 10:47:12 -0800 (PST)") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Drew Adams wrote: > Enhancement request: Please write "Severity: wishlist" as the first line of the message body. Also, FYI your customized bug reporting is (I assume) messing up the version number in the subject of your reports. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 14:03:21 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 19:03:21 +0000 Received: from localhost ([127.0.0.1]:59412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtV2-0004nC-8A for submit@debbugs.gnu.org; Mon, 03 Dec 2018 14:03:21 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:58546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTtUz-0004mu-IM for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 14:03:18 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3IwjWL036242 for <33601@debbugs.gnu.org>; Mon, 3 Dec 2018 19:03:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=IraldzJtr5IZGrNasUJrI1q9dZixGrr2F5fWaS9bFSU=; b=nYBHFlQ4g4+keuqS3TiGsFqBC1yu2mX05KAgJWfGRPpqt8VDSiBmBJPPcZ5XjOg2v5d3 1CxrNxp7Srzvy6AALS3njWBTOBREOLj6Gd9Idd8AXuDEhI5jAYZActgAPKk3U3EnRnXq vxaUuOHdAezjk7Qcn9pSK47OkpnyWkATKjs40EiAwHKlgUJIq90E8BsFBlWzY5OW4FwP hgQMiHE5qZ7G9gi0ovYfUmAuC7txXnl6dhv17SwitOhEDc+dnIjAdabIGf5YAuNyqwGD vbJIymLJ0FJOwP3OPhZ+vXeRpQHFdvU/97e3ugFXYP4gPRBadEkAtZZ5UKNP/bQX7uUj dQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2p3j8q891h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <33601@debbugs.gnu.org>; Mon, 03 Dec 2018 19:03:10 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB3J3Agf009499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <33601@debbugs.gnu.org>; Mon, 3 Dec 2018 19:03:10 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3J39xO028987 for <33601@debbugs.gnu.org>; Mon, 3 Dec 2018 19:03:10 GMT MIME-Version: 1.0 Message-ID: <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> Date: Mon, 3 Dec 2018 11:03:09 -0800 (PST) From: Drew Adams To: 33601@debbugs.gnu.org Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> In-Reply-To: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=13 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=568 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030175 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Maybe a better name would be `with-function-on-hook' or `with-hook-function-added'. It is the function, not the hook, that is added (to the hook). From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 15:58:44 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 20:58:44 +0000 Received: from localhost ([127.0.0.1]:59519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTvIi-0007ty-8p for submit@debbugs.gnu.org; Mon, 03 Dec 2018 15:58:44 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:35792) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTvIf-0007tg-6K for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 15:58:42 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3Ks2Eq122645; Mon, 3 Dec 2018 20:58:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=s8z3F1IixAEpPO9XHzJAH+eJu7TotA7LIBVqaIPrsCQ=; b=Gr2R4wFucmyPT5AKf8hUtMgQ7fhDSkiFzVebaCMTKut8P9YLKheeCw/TCYevYgzm2dTy gj21SqLDmmAh5UVYS4T6SpgN0lWHBMgOzzou0JSlkfJ+Hco3Ah6/DI/qrj8GsplQ3VJC za1Fz02GVLU3YVHlDrkI5G3FyzTpJeRiylV0L34B1Q3dSpUsBAvf5487BV6QCrX69L06 xQxNEoC51WNkVjrkLeudySD3Cbvh5XbQHmxUMaP6U8e4/pO1j3BmuRpU+NWBljPqfVUv qgi/mzxEJAv9L/spwCZv2xRc2IHViQUKlwM7Be7Z0oOWBxR1fv+bYCIQ9rtHHakPLYkh Zw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2p3jxr8qby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 03 Dec 2018 20:58:34 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB3KwX1C025604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Dec 2018 20:58:34 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB3KwXC2012308; Mon, 3 Dec 2018 20:58:33 GMT MIME-Version: 1.0 Message-ID: <9ec21508-b387-4178-9701-e17b2501d7be@default> Date: Mon, 3 Dec 2018 12:58:31 -0800 (PST) From: Drew Adams To: Glenn Morris Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=813 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030190 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > FYI your customized bug reporting is (I assume) messing up the > version number in the subject of your reports. Thanks. Yes, in Emacs 26 vanilla emacsbug.el changed the way it reports the version number in the Subject line. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 17:38:02 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 22:38:02 +0000 Received: from localhost ([127.0.0.1]:59553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTwqo-0002F1-3S for submit@debbugs.gnu.org; Mon, 03 Dec 2018 17:38:02 -0500 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:44343) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTwql-0002Ej-Gq for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 17:38:00 -0500 Received: from [10.253.37.70] (port=31044 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1gTwqU-0004Rf-Oc; Tue, 04 Dec 2018 11:37:57 +1300 Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Tue, 04 Dec 2018 11:37:42 +1300 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 04 Dec 2018 11:37:42 +1300 From: Phil Sainty To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' In-Reply-To: <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> Message-ID: <06d76795115ae2a95f56694a904100ba@webmail.orcon.net.nz> X-Sender: psainty@orcon.net.nz User-Agent: Orcon Webmail X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 2018-12-04 08:03, Drew Adams wrote: > Maybe a better name would be `with-function-on-hook' or > `with-hook-function-added'. It is the function, not the > hook, that is added (to the hook). True, but `with-hook-added' seems consistent with the name of `add-hook' itself (which likewise isn't for creating hooks). From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 17:51:01 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 22:51:01 +0000 Received: from localhost ([127.0.0.1]:59558 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTx3N-0002c6-9j for submit@debbugs.gnu.org; Mon, 03 Dec 2018 17:51:01 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:33256) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTx3J-0002bm-RC for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 17:50:58 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3MmmKq051412; Mon, 3 Dec 2018 22:50:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=qZ2/E91RktHEdEY9lZtRh1qWqJ5k9Sf2NRdp9guK9rA=; b=fCYBxAriDbvvx2Ee1/SPAxgWNlpdJfxnAur32UAMMPA22NAwRGFsB4M4afpw6RI21aeJ 3jCK8q74ylca7uxTzOLV28yQwkR62OxqAfAkJ4uB42YVpZcZ1TzxB2IJOT7CXQS7WKRt bO+EnrmJ6+D+0xsleZp4Q8gvGr16VI95ICOlQaSyUW7JRHT+/ZZDimwzx8EQr40NFWD6 DtZdsDvwgvzOiz2KU7iRxd1nW/uqRW4Gme51ZG8Iv+tZJO66xIKZXDrcgHTSX4jJPOmw LAiksEAynobw4neRVtu9G1v55k3pgiIusqg9inYe5EL6gttAfjYY2ZV3UCSFj0z1TbGD 8w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2p3hqts8r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 03 Dec 2018 22:50:51 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB3Monlc008176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Dec 2018 22:50:50 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3Moneh007547; Mon, 3 Dec 2018 22:50:49 GMT MIME-Version: 1.0 Message-ID: <9bda9cb4-42bb-4e89-b73e-fb0b62443b6c@default> Date: Mon, 3 Dec 2018 14:50:48 -0800 (PST) From: Drew Adams To: Phil Sainty Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> <06d76795115ae2a95f56694a904100ba@webmail.orcon.net.nz> In-Reply-To: <06d76795115ae2a95f56694a904100ba@webmail.orcon.net.nz> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030204 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > > Maybe a better name would be `with-function-on-hook' or > > `with-hook-function-added'. It is the function, not the > > hook, that is added (to the hook). >=20 > True, but `with-hook-added' seems consistent with the name of > `add-hook' itself (which likewise isn't for creating hooks). Yeah, that's why I used that name. I'm OK with any of those names mentioned so far, and probably with other alternatives too. The real question is whether such a macro is useful. I think it can be. I gave a couple examples in bug #33595. It was those examples that made me think such a macro might be useful. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 18:13:59 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 23:13:59 +0000 Received: from localhost ([127.0.0.1]:59568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTxPb-0003GI-JJ for submit@debbugs.gnu.org; Mon, 03 Dec 2018 18:13:59 -0500 Received: from smtp-2.orcon.net.nz ([60.234.4.43]:52342) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTxPZ-0003G8-HQ for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 18:13:58 -0500 Received: from [10.253.37.70] (port=34272 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.86_2) (envelope-from ) id 1gTxPX-0006CM-9w; Tue, 04 Dec 2018 12:13:55 +1300 Received: from wlgwil-nat-office.catalyst.net.nz ([202.78.240.7]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Tue, 04 Dec 2018 12:13:55 +1300 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 04 Dec 2018 12:13:55 +1300 From: Phil Sainty To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' In-Reply-To: <9bda9cb4-42bb-4e89-b73e-fb0b62443b6c@default> References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> <06d76795115ae2a95f56694a904100ba@webmail.orcon.net.nz> <9bda9cb4-42bb-4e89-b73e-fb0b62443b6c@default> Message-ID: <1c26ed105b9c1262e1688018d32d4957@webmail.orcon.net.nz> X-Sender: psainty@orcon.net.nz User-Agent: Orcon Webmail X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 2018-12-04 11:50, Drew Adams wrote: > The real question is whether such a macro is useful. > I think it can be. I gave a couple examples in bug > #33595. It was those examples that made me think > such a macro might be useful. I certainly think it can be useful. On a couple of occasions I've used code which does a similar thing with advice -- adding temporary advice, running a body, and removing the advice again. In both cases one could argue for a more persistent hook or advice which performs its own check to see whether it should do things, but that might also entail writing a new wrapper to perform the test, so there's appeal in a with-* approach (particularly for things which are wanted only very occasionally). -Phil From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 03 18:51:57 2018 Received: (at 33601) by debbugs.gnu.org; 3 Dec 2018 23:51:57 +0000 Received: from localhost ([127.0.0.1]:59579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTy0K-0004ND-Up for submit@debbugs.gnu.org; Mon, 03 Dec 2018 18:51:57 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTy0H-0004Mn-NL for 33601@debbugs.gnu.org; Mon, 03 Dec 2018 18:51:54 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB3NmVK0058975; Mon, 3 Dec 2018 23:51:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=byWPQ6ZrYJLIizlxvz4QT2EYosfHWWu/9BxMEybhMKk=; b=Kn350vy85F22ZeIe2aBIoSXd3fshPvy7qHSpw2DrrpoLoCcnkVOjGd6eVd55Yumbki98 oLEYHNSVb8c5+uC/WXoHyLHWfZ7QIqnopz+MKjHsOeOyLrZa9Ybl2Oy9xAq25a0tOgbz vtMhLtebH1ZJ5w+2jRMSDGYoEqZ1z+0xIWuWZdfIUXHRFr4MHvWq0DS+7UVo1LxTEER4 X1XndkVlX8sYGD/eGdWb468WmqFbX79pPZi762G6GsrMIrGUoz2E0AXyo/ueyduaHtlU zQ1oXDHIDkojB+Arj/9V+tYwqzi/hSp50jTO+9fCS1xhMSntCy8O39rnWni+4Vq/+7N5 vg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2p3jxr9bk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 03 Dec 2018 23:51:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB3NpkOH029907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Dec 2018 23:51:46 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB3Npjx7028943; Mon, 3 Dec 2018 23:51:45 GMT MIME-Version: 1.0 Message-ID: <108a3ae8-9959-4dc1-a7fe-bea4a31c8643@default> Date: Mon, 3 Dec 2018 23:51:44 +0000 (UTC) From: Drew Adams To: Phil Sainty Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> <0b15a9be-6f19-4569-93fd-1a09a6456b25@default> <06d76795115ae2a95f56694a904100ba@webmail.orcon.net.nz> <9bda9cb4-42bb-4e89-b73e-fb0b62443b6c@default> <1c26ed105b9c1262e1688018d32d4957@webmail.orcon.net.nz> In-Reply-To: <1c26ed105b9c1262e1688018d32d4957@webmail.orcon.net.nz> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9096 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030211 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > > The real question is whether such a macro is useful. > > I think it can be. I gave a couple examples in bug > > #33595. It was those examples that made me think > > such a macro might be useful. >=20 > I certainly think it can be useful. >=20 > On a couple of occasions I've used code which does a similar thing > with advice -- adding temporary advice, running a body, and removing > the advice again. >=20 > In both cases one could argue for a more persistent hook or advice > which performs its own check to see whether it should do things, but > that might also entail writing a new wrapper to perform the test, so > there's appeal in a with-* approach (particularly for things which are > wanted only very occasionally). Yes to all that. A propos, I don't think advice (even nadvice) replaces the special utility of a hook, for reasons similar to those I gave in bug #33595 for why a hook is handier for that use case than is using `:exit-function' on `completion-extra-properties'. Each such function behavior-modifying tool has a purpose, even if sometimes they can substitute for each other. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 13:46:17 2018 Received: (at 33601) by debbugs.gnu.org; 4 Dec 2018 18:46:17 +0000 Received: from localhost ([127.0.0.1]:60948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUFi4-0006h6-SO for submit@debbugs.gnu.org; Tue, 04 Dec 2018 13:46:17 -0500 Received: from colin.muc.de ([193.149.48.1]:18749 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gUFi3-0006gx-F9 for 33601@debbugs.gnu.org; Tue, 04 Dec 2018 13:46:16 -0500 Received: (qmail 2050 invoked by uid 3782); 4 Dec 2018 18:46:14 -0000 Date: 4 Dec 2018 18:46:14 -0000 Message-ID: <20181204184614.2049.qmail@mail.muc.de> From: Alan Mackenzie To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p4 (amd64)) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Drew. In article you wrote: > Enhancement request: Please consider adding a macro such as this, to > facilitate temporary use of a hook function. > (defmacro with-hook-added (hook function &rest body) > "Evaluate forms in BODY with FUNCTION added to HOOK, then remove FUNCTION." > (declare (indent 1) (debug t)) > `(unwind-protect (progn (add-hook ',hook ',function) ,@body) > (remove-hook ',hook ',function))) Just a big point: you need to test whether FUNCTION is already on HOOK at the start, and if so, not remove it at the end. Apologies if somebody else has already pointed this out. > In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) > of 2018-05-30 > Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea > Windowing system distributor `Microsoft Corp.', version 10.0.16299 > Configured using: > `configure --without-dbus --host=x86_64-w64-mingw32 > --without-compress-install 'CFLAGS=-O2 -static -g3'' -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 14:18:41 2018 Received: (at 33601) by debbugs.gnu.org; 4 Dec 2018 19:18:41 +0000 Received: from localhost ([127.0.0.1]:60976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUGDR-0007cI-5F for submit@debbugs.gnu.org; Tue, 04 Dec 2018 14:18:41 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:51102) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUGDP-0007c3-2A for 33601@debbugs.gnu.org; Tue, 04 Dec 2018 14:18:39 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB4JED94000843; Tue, 4 Dec 2018 19:18:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=IGi2qIEDlzn3tfYoKfxKan6rlXvYY81XMlMdIsZhE5o=; b=TJsosvUol1htlLaPk1FlZ42SHwyjRSHQk/1qvVWrXAQo+enK54FDvA3QS/PxFxFnZLrJ G8Ng4h5UDNMiRwJ1qb/uZuX5N84w+OAJE6BuCjk38l6Xxb2NADLdTjVI8ykgiFyYyZ4z lsX7V2y7W5/8MZyIk60ZiE8wFG+FqjVq8pY/3/F2c4+xq/Ps7l2Lo4SaF0oS5xv0haDg CMOmxpp1lmU+IYsHczmvJdMnCBnezPDCDF1maWBGuHElVSTfqPeT4rrINhgRqk9MaEx+ M0mAEkfuBAZjiHN+o5j2kun4SvPd8K3+GdxPi3bcuaEfvHQuXOyF6Nvuq3UKw1j9qzRP eg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2p3ftf2ckk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Dec 2018 19:18:32 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB4JIUrD020308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Dec 2018 19:18:31 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB4JIUM7030002; Tue, 4 Dec 2018 19:18:30 GMT MIME-Version: 1.0 Message-ID: Date: Tue, 4 Dec 2018 11:18:29 -0800 (PST) From: Drew Adams To: Alan Mackenzie , Drew Adams Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <> <<20181204184614.2049.qmail@mail.muc.de>> In-Reply-To: <<20181204184614.2049.qmail@mail.muc.de>> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9097 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812040164 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > > Enhancement request: Please consider adding a macro such as this, to > > facilitate temporary use of a hook function. >=20 > > (defmacro with-hook-added (hook function &rest body) > > "Evaluate forms in BODY with FUNCTION added to HOOK, then remove FUNC= TION." > > (declare (indent 1) (debug t)) > > `(unwind-protect (progn (add-hook ',hook ',function) ,@body) > > (remove-hook ',hook ',function))) >=20 > Just a big point: you need to test whether FUNCTION is already on HOOK > at the start, and if so, not remove it at the end. Hi Alan, A big point? Need to? That wasn't the behavior I had in mind for this, but it's another possibility. I intended to provide only for the behavior of always removing at the end. There are in fact several different possibilities for such a macro. We could provide also for `add-hook' args APPEND and LOCAL. I left that out as well. Choices: 1. Provide a single macro for all such possibilities, with 3 (mandatory) args for APPEND, LOCAL and whether to remove FUNCTION at the end if it was already present at the outset. 2. Provide multiple macros, each specific for a given case. #2 would mean 8 macros, to cover all the combinations (nil or t for each of the 3 args). Another possibility would be to accept a single arg for the BODY code, instead of that being a &rest parameter, and so be able to provide those 3 behavior-specifying args as optional. In that case, we'd want to decide on the best order among those args, e.g., based on which we expect to be used most often. I'm not sure what the right approach is. I think the most common use case would be the one I wrote up (but I don't know that): . Always remove FUNCTION at the end . Prepend, not append. . Global, not local. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 15:15:12 2018 Received: (at 33601) by debbugs.gnu.org; 4 Dec 2018 20:15:13 +0000 Received: from localhost ([127.0.0.1]:60996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUH68-0000lx-LH for submit@debbugs.gnu.org; Tue, 04 Dec 2018 15:15:12 -0500 Received: from colin.muc.de ([193.149.48.1]:58470 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gUH66-0000iJ-2L for 33601@debbugs.gnu.org; Tue, 04 Dec 2018 15:15:10 -0500 Received: (qmail 27375 invoked by uid 3782); 4 Dec 2018 20:15:08 -0000 Received: from acm.muc.de (p2E5D5BD9.dip0.t-ipconnect.de [46.93.91.217]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 04 Dec 2018 21:15:07 +0100 Received: (qmail 14338 invoked by uid 1000); 4 Dec 2018 20:10:48 -0000 Date: Tue, 4 Dec 2018 20:10:48 +0000 To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' Message-ID: <20181204201048.GA13646@ACM> References: <20181204184614.2049.qmail@mail.muc.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Drew. On Tue, Dec 04, 2018 at 11:18:29 -0800, Drew Adams wrote: > > > Enhancement request: Please consider adding a macro such as this, to > > > facilitate temporary use of a hook function. > > > (defmacro with-hook-added (hook function &rest body) > > > "Evaluate forms in BODY with FUNCTION added to HOOK, then remove FUNCTION." > > > (declare (indent 1) (debug t)) > > > `(unwind-protect (progn (add-hook ',hook ',function) ,@body) > > > (remove-hook ',hook ',function))) > > Just a big point: you need to test whether FUNCTION is already on HOOK > > at the start, and if so, not remove it at the end. > Hi Alan, > A big point? Need to? I think so, yes. The essence of the `with-...' macros is that they temporarily change something, then evaluate ,@body, and at the end, the something is restored to what it was. If with-hook-added didn't preserve the hook, it would be an anomaly, an outlier, and quite possibly a PITA. > That wasn't the behavior I had in mind for this, but it's > another possibility. I intended to provide only for the > behavior of always removing at the end. Why? What's the use case? > There are in fact several different possibilities for such > a macro. We could provide also for `add-hook' args APPEND > and LOCAL. I left that out as well. > Choices: > 1. Provide a single macro for all such possibilities, with > 3 (mandatory) args for APPEND, LOCAL and whether to remove > FUNCTION at the end if it was already present at the outset. > 2. Provide multiple macros, each specific for a given case. > #2 would mean 8 macros, to cover all the combinations > (nil or t for each of the 3 args). How many of these would actually be of any use? > Another possibility would be to accept a single arg for > the BODY code, instead of that being a &rest parameter, > and so be able to provide those 3 behavior-specifying > args as optional. In that case, we'd want to decide on > the best order among those args, e.g., based on which we > expect to be used most often. > I'm not sure what the right approach is. I think the > most common use case would be the one I wrote up (but > I don't know that): > . Always remove FUNCTION at the end > . Prepend, not append. > . Global, not local. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 04 16:22:55 2018 Received: (at 33601) by debbugs.gnu.org; 4 Dec 2018 21:22:55 +0000 Received: from localhost ([127.0.0.1]:32816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUI9e-000496-VP for submit@debbugs.gnu.org; Tue, 04 Dec 2018 16:22:55 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:48362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUI9c-00048q-RQ for 33601@debbugs.gnu.org; Tue, 04 Dec 2018 16:22:53 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB4LJLlJ098940; Tue, 4 Dec 2018 21:22:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=ne9TGVAp1ulEAZB04O/MdbNUxDZE3wbAt/mIKV8GjoU=; b=rygYEXy3ToAZdcHjUDErCnB+m2//yL1NhDVpHncgUYJmw8i0WTxO5Yc1yXXdEc/bQh4P ExBImvKjo6A8UnjmCQVZszpcs//T37yHxg2kUXNAxkpsHIgfty72zEVYqBSyzJhFCj7z dpUyDaA1wdTSdZ0mK764eh+cdpHv9K/G9xjQ0n1czFBTxcNLKX/rkVGzpDFa4JR1k9/L dmHq8+QTmhV3wBKIEzE2egTFgvxUzuuDobKwGZ7QRHNwJ88rhY8AKuhD2sz40ySLggyk zsVnfx0Y8sztVEVaDW91bj1R3ihYLYy69natCx5r2/UXgF68o80PrSVQd+zSvGrYLqzH XA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2p3ftf2wh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 04 Dec 2018 21:22:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wB4LMjWU028783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Dec 2018 21:22:46 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB4LMgAj027909; Tue, 4 Dec 2018 21:22:42 GMT MIME-Version: 1.0 Message-ID: Date: Tue, 4 Dec 2018 13:22:41 -0800 (PST) From: Drew Adams To: Alan Mackenzie Subject: RE: bug#33601: 26; Add macro `with-hook-added' References: <20181204184614.2049.qmail@mail.muc.de> <20181204201048.GA13646@ACM> In-Reply-To: <20181204201048.GA13646@ACM> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4771.0 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9097 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812040182 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > > > Just a big point: you need to test whether FUNCTION is already on > > > HOOK at the start, and if so, not remove it at the end. >=20 > > A big point? Need to? >=20 > I think so, yes. The essence of the `with-...' macros is that they > temporarily change something, then evaluate ,@body, and at the end, the > something is restored to what it was. >=20 > If with-hook-added didn't preserve the hook, it would > be an anomaly, an outlier, and quite possibly a PITA. If there's an unwritten rule that `with-*' macros preserve and restore everything then clearly the macro I proposed was not a `with-*' macro. Another name for it would be fine, if that's the rule. ;-) > > That wasn't the behavior I had in mind for this, but it's > > another possibility. I intended to provide only for the > > behavior of always removing at the end. >=20 > Why? What's the use case? The kind of thing I showed (with two examples). Yes, I would use them where I either know that the function is not on the hook already or I don't care - cases where I would want it removed at the end in any case. And yes, given your question, the doc of such a macro would need to make clear that it always removes FUNCTION from the hook afterward. > > Choices: > > 1. Provide a single macro for all such possibilities, with > > 3 (mandatory) args for APPEND, LOCAL and whether to remove > > FUNCTION at the end if it was already present at the outset. > > 2. Provide multiple macros, each specific for a given case. > > > > #2 would mean 8 macros, to cover all the combinations > > (nil or t for each of the 3 args). >=20 > How many of these would actually be of any use? All of the behaviors are useful. If you meant to ask whether it is useful to have 8 individual macros, then my answer is probably not. > > Another possibility would be to accept a single arg for > > the BODY code, instead of that being a &rest parameter, > > and so be able to provide those 3 behavior-specifying > > args as optional. In that case, we'd want to decide on > > the best order among those args, e.g., based on which we > > expect to be used most often. >=20 > > I'm not sure what the right approach is. I think the > > most common use case would be the one I wrote up (but > > I don't know that): > > > > . Always remove FUNCTION at the end > > . Prepend, not append. > > . Global, not local. I really have no problem with what you requested: not removing FUNCTION at the end if it was present beforehand. However, now you've gone beyond that to suggest that we should restore the original hook value: "preserve the hook". Should it preserve the hook? Maybe, maybe not. How strict is your unwritten `with-*' rule? Does it apply only to undoing the particular change _it_ makes, or does it also undo changes that might be made by the BODY? In this case, the BODY might itself make changes to the hook. If I had to choose only one macro, it would probably be a general one. I guess it would, as you first requested, remove FUNCTION only if it was not already present. And it would accept args for APPEND and LOCAL. But it would not restore the original hook value. Whether it should require args APPEND and LOCAL or it should instead make you wrap body sexps in a progn is another choice. Dunno which I'd prefer, but probably the former (probably less error prone). Other ideas are welcome. What is your preference (besides always restoring the original hook value)? From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 12 03:46:30 2022 Received: (at 33601) by debbugs.gnu.org; 12 Feb 2022 08:46:31 +0000 Received: from localhost ([127.0.0.1]:33400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIo34-0002Fo-MT for submit@debbugs.gnu.org; Sat, 12 Feb 2022 03:46:30 -0500 Received: from quimby.gnus.org ([95.216.78.240]:40110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIo33-0002Ab-81 for 33601@debbugs.gnu.org; Sat, 12 Feb 2022 03:46:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9axjto+fpS9L+oGZ0SXrIwYUqNW1UCYxUpFRLeWdhDc=; b=j/Ts0UprL6E6+HpWwMCBinS3ie V4MMPbD3VO6qvjQnXdB4LgeOIghGjZuWIHKCXrI5rw+VqmlDNdBKt8sp0KRJ/HrMRErQkgpdIbBfa hv4i+gc9rWKpptJCBimEOk4/GUKlUfZ+x1/HS7cde1ElepCAZgeQOHl68MPEZNhua9j4=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIo2t-0005WS-RA; Sat, 12 Feb 2022 09:46:22 +0100 From: Lars Ingebrigtsen To: Drew Adams Subject: Re: bug#33601: 26; Add macro `with-hook-added' References: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> X-Now-Playing: Zazou Bikaye's _Mr. Manager_: "Signorina" Date: Sat, 12 Feb 2022 09:46:19 +0100 In-Reply-To: <6871371f-5c46-46f2-9a92-b1c154ec5a73@default> (Drew Adams's message of "Mon, 3 Dec 2018 10:47:12 -0800 (PST)") Message-ID: <87bkzc321w.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Drew Adams writes: > Enhancement request: Please consider adding a macro such as this, to > facilitate temporary use of a hook function. > > (defmacro with-hook-added (hook function &rest body) > "Evaluate forms in BODY [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33601 Cc: 33601@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Drew Adams writes: > Enhancement request: Please consider adding a macro such as this, to > facilitate temporary use of a hook function. > > (defmacro with-hook-added (hook function &rest body) > "Evaluate forms in BODY with FUNCTION added to HOOK, then remove FUNCTION." > (declare (indent 1) (debug t)) > `(unwind-protect (progn (add-hook ',hook ',function) ,@body) > (remove-hook ',hook ',function))) I don't think this is generally useful enough, so I'm closing this bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 12 03:46:36 2022 Received: (at control) by debbugs.gnu.org; 12 Feb 2022 08:46:36 +0000 Received: from localhost ([127.0.0.1]:33403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIo39-0002KO-TF for submit@debbugs.gnu.org; Sat, 12 Feb 2022 03:46:36 -0500 Received: from quimby.gnus.org ([95.216.78.240]:40124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIo38-0002Ed-MD for control@debbugs.gnu.org; Sat, 12 Feb 2022 03:46:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PFK7yHvhDjaWrjQANx09oMZUWUilTwCTApTrm7DGh6c=; b=YEJ5lJV9EkSqB6I8NNAez0cyZU hnQotwUY/od3mH+g0Bx8BeqE5Kwqb9BGxC0U23hsSxeCJlClwTR6e2OKxVT7wgaSRPruB+QQ2z9la Cb7aenWR6xVPQLxtcJXnR/3Mj6lrnz6zr+mqDiIqbjiYedQrreR4Zbw2JHYNCfTwxKAU=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIo30-0005Wb-BK for control@debbugs.gnu.org; Sat, 12 Feb 2022 09:46:28 +0100 Date: Sat, 12 Feb 2022 09:46:24 +0100 Message-Id: <87a6ew321r.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #33601 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 33601 wontfix close 33601 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 33601 wontfix close 33601 quit From unknown Fri Aug 15 15:55:52 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 12 Mar 2022 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator