unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: make emacs ask to save modified non-file buffers
Date: Sun, 22 Jun 2008 17:23:26 -0700 (PDT)	[thread overview]
Message-ID: <635b5b5f-398f-44a0-8bf2-873a050696bb@v1g2000pra.googlegroups.com> (raw)

when i create a new buffer, how can i make emacs ask to save if it is
modified?

for example, i have this function:

(defun new-empty-buffer ()
  "Opens a new empty buffer."
  (interactive)
  (let ((buf (generate-new-buffer "untitled")))
    (switch-to-buffer buf)
    (funcall (and initial-major-mode))
    (setq buffer-offer-save t)
))

after calling, it'll create a new buffer. Then, if user edit the
buffer, then close it (using either kill-buffer or kill-this-buffer),
then i want emacs to ask whether to save it if the buffer has been
modified.

according to the manual, the var buffer-offer-save will do it only if
the buffer is a visiting buffer. Then the manual talks about save-some-
buffers second argument but i don't see how this fits together, since
i don't actually want to call save-some-buffers.

Thanks.

  Xah
∑ http://xahlee.org/

             reply	other threads:[~2008-06-23  0:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-23  0:23 Xah [this message]
2008-06-23  0:48 ` make emacs ask to save modified non-file buffers Lennart Borgman (gmail)
     [not found] ` <mailman.13718.1214182118.18990.help-gnu-emacs@gnu.org>
2008-06-23  4:02   ` Xah
2008-06-23  6:26     ` Lennart Borgman (gmail)
2008-06-23  8:48 ` Juanma Barranquero

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=635b5b5f-398f-44a0-8bf2-873a050696bb@v1g2000pra.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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).