unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: "Peter Münster" <pm@a16n.net>
Cc: help-gnu-emacs@gnu.org
Subject: Re: kill-buffer without asking for confirmation
Date: Mon, 28 Nov 2022 10:25:46 +0100	[thread overview]
Message-ID: <87edtnpgbt.fsf@gnu.org> (raw)
In-Reply-To: <87pmd71nfr.fsf@a16n.net>

Peter Münster <pm@a16n.net> 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



  reply	other threads:[~2022-11-28  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  8:40 kill-buffer without asking for confirmation Peter Münster
2022-11-28  9:25 ` Tassilo Horn [this message]
2022-11-28 13:46   ` Peter Münster
2022-11-28  9:47 ` Gregory Heytings
2022-11-28 17:27 ` Andreas Röhler

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=87edtnpgbt.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pm@a16n.net \
    /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.
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).