From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.devel Subject: Re: graceful shutdown of non-interactive Elisp program Date: Sun, 14 Jun 2020 00:59:51 +0200 Message-ID: <87tuzed120.fsf@fastmail.fm> References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="51522"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.2; emacs 27.0.91 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 14 01:00:54 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jkF8w-000DLo-8Z for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Jun 2020 01:00:54 +0200 Original-Received: from localhost ([::1]:48592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkF8v-0007J6-9a for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Jun 2020 19:00:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkF82-00069r-LL for emacs-devel@gnu.org; Sat, 13 Jun 2020 18:59:58 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:39609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkF80-0006ol-Nj for emacs-devel@gnu.org; Sat, 13 Jun 2020 18:59:58 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id B5B775C009C for ; Sat, 13 Jun 2020 18:59:54 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 13 Jun 2020 18:59:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm3; bh=dTjuuAsq8nutgOyi3094xyemQ2 cGNcVUsRaQ53KHISI=; b=co8cHYt1NGx5Z8J8ZTX9Lu4kTWgMy3vgDAgxJj8MP/ H43gY34STXq+4C3T2fQpLbDjikrSi37+/A7KLKdwh7KbhAwM1uKdZRTnjewC4oO3 fTRC2+uTEhzgkmxM5ZvXupwSkLbddEj+lYKjBLKDsE9rTGx4b3+5RlPqUyayDr3s A36PqZIruhPeaQ1A5xXSM3kPio3mn07q/Gn6Xe1/oO3oyt2E0e3r93wI2clSdQrE uuLYH/CWAWa8D6fyHMsejKG/4YOvVbibZgP2PLqVvhQDhUnxZfQ15ILu4hQcTjX/ 8XkHn4O27TrQa6QZ43l/oq/fYrJLz1aMjw3fArMfe/OA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=dTjuuA sq8nutgOyi3094xyemQ2cGNcVUsRaQ53KHISI=; b=UWgIj3t+P2pRdwwu5U3JtA kCbeoB0qz/HtGMhfoUHym2MXQRQB/H4E7/gUOB9sEwkAm4lICh6ENuBoLMVrW08Y zvgKi7kJsGxlFruTcbrKbipY4tWR0LechqI5FlBbhgXTYU9DNxDXmX0bq8Ty7PFq Lu8eRe/OzBCLuDkaCEEZ5yFzJM44uj3lFiMBTrNukYVpHcZG6RHAYcJQ18qd/IM6 qyEZSrBVPsls0jMR0tN3Ftz++ORAscMpsIqmB7jITSk+WCedqvPNNsjAKp54eD2I DGrIeXrb/LoeHtxu9uN/h8+4Vfr0wpK7KaLslcJCAGciDkV61JbSkCcDv6XJPKeQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeigedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpehffgfhvffujgffkfggtgesthdtre dttdertdenucfhrhhomheplfhoohhsthcumfhrvghmvghrshcuoehjohhoshhtkhhrvghm vghrshesfhgrshhtmhgrihhlrdhfmheqnecuggftrfgrthhtvghrnhephfduffeuhfdule fhgfelueekgeduveettdduudfhfeetueegvdevtdduudfgffefnecukfhppeelhedrledt rddvtddurdeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from Swift.fastmail.com (ip5f5ac93e.dynamic.kabel-deutschland.de [95.90.201.62]) by mail.messagingengine.com (Postfix) with ESMTPA id 39A323061856 for ; Sat, 13 Jun 2020 18:59:54 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=66.111.4.28; envelope-from=joostkremers@fastmail.fm; helo=out4-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/13 18:59:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252215 Archived-At: On Sat, Jun 13 2020, Paul Pogonyshev wrote: > I'm trying to make a Elisp program that is run in a > non-interactive mode, > i.e. essentially as `emacs --batch --load myfile.el'. A normal > way to > shutdown terminal programs is with C-c, which is expected to be > "graceful" > shutdown, e.g. the program still has a chance to save files etc. > > However, with Elisp I'm not sure how to achieve that except for > constantly > modifying `kill-emacs-hook', which would be a nightmare from > coding > perspective. What do you mean "constantly modifying `kill-emacs-hook'"? You just add a function to it when your program starts and if it's shut down before Emacs is killed, you remove the function again. Or leave it, if it doesn't do any harm. -- Joost Kremers Life has its moments