From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: kill-buffer without asking for confirmation Date: Mon, 28 Nov 2022 10:25:46 +0100 Message-ID: <87edtnpgbt.fsf@gnu.org> References: <87pmd71nfr.fsf@a16n.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5748"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.3; emacs 29.0.50 Cc: help-gnu-emacs@gnu.org To: Peter =?utf-8?Q?M=C3=BCnster?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 28 10:41:20 2022 Return-path: Envelope-to: geh-help-gnu-emacs@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 1ozadc-0001K3-1o for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 28 Nov 2022 10:41:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozad7-0003sY-P9; Mon, 28 Nov 2022 04:40:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozad2-0003sK-Bn for help-gnu-emacs@gnu.org; Mon, 28 Nov 2022 04:40:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozad1-0007K8-Lc; Mon, 28 Nov 2022 04:40:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=dBanGYXlBwi/LD1XDZXyIHPaLeNboc2BUivd/mAN/oU=; b=KBsFHXdVjwpBOS f1iKzE+eDOplbG2uTuFAWnyfp7r6+pKU4x4oY5d81KjOMQdmOR+gf6LriQz5bnVydIP8EL75fDTJX 1ndFYlu6NzBn48s0t6pCfjy2auN0xN9AweuDFfllbTw3zfk+9B2eVXg9yc5hcJKGJs4ttcT++ePd7 kPqTBwdrTJeQjvKCN1Yw/yopMUyEiO/62zSVk/mgX5QpM9ggUURCRnAsqtxdRCdeiplvi/hkbhSjH G67qLvgXU/3peqju3axSw6Z0OkKJgyQKoQ0zJn5utXSTvPQsHqSJmQ0iAx1k2qscfnItfMF7fK+4S mnXrq9NzUgipsqiYtPNA==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozad1-0007no-6A; Mon, 28 Nov 2022 04:40:43 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 8845727C0054; Mon, 28 Nov 2022 04:40:41 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Nov 2022 04:40:41 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrjedvgddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvfevufffjgfkgggtgfesthhqredttderjeenucfhrhhomhepvfgrshhs ihhlohcujfhorhhnuceothhsughhsehgnhhurdhorhhgqeenucggtffrrghtthgvrhhnpe fgtedtudeivdfhfffhfefhvefhuedvheejjeefleffheekffeutdfhgfejiefhgeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhorhhnod hmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdekieejfeekjeekgedqieefhedv leekqdhtshguhheppehgnhhurdhorhhgsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 28 Nov 2022 04:40:40 -0500 (EST) In-reply-to: <87pmd71nfr.fsf@a16n.net> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141214 Archived-At: Peter M=C3=BCnster writes: Hi Peter, > When a buffer is modified, kill-buffer normally asks for confirmation > ("Buffer modified; kill anyway?"). How can I avoid this confirmation > please? > > This worked with version 28.X: > > (defun some-function-called-by-timer () > "Send email to user." > (compose-mail user-mail-address "bla") > (insert "bla") > (funcall send-mail-function) > (cl-letf (((symbol-function 'yes-or-no-p) (lambda (_) t))) > (kill-buffer))) > > But unfortunately, it doesn't work any more with the latest 29.0.50. Yeah, it's not yes-or-no-query anymore but now you can answer yes/no/"first save and then kill". You could use your above function but swap yes-or-no-p with kill-buffer--possibly-save (or temporarily redefine both to "always t"), I think. OTOH, the definition of kill-buffer in buffer.c suggests that the query is only performed when your function is called interactively which shouldn't be the case when it's run from a timer as its name suggests. Another way might be to slap a (let ((noninteractive t)) ...) around the kill-buffer call. Maybe that does the trick, too, and works with more emacs versions. Bye, Tassilo