From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Is it possible not to quit emacs when buffer is modified?
Date: Wed, 19 Aug 2009 19:23:06 -0700 (PDT) [thread overview]
Message-ID: <e72f3889-2b2a-49a6-bde5-9a2d0c31b7b7@u16g2000pru.googlegroups.com> (raw)
In-Reply-To: 3fa169e2-c16c-46cb-bbab-7329ccd554b8@f20g2000prn.googlegroups.com
On Aug 19, 7:09 pm, Xah Lee <xah...@gmail.com> wrote:
> On Aug 19, 5:22 pm, YOUNG <breadn...@gmail.com> wrote:
>
> > Hi,
>
> > If a buffer does not connect to a file but it is modified, if you type
> > c-x c, emacs just quits and losts the data.
>
> > Is there a way to protect of it?
>
> I don't think there's a default way. This is one of the problem that
> pains me.
>
> But if you use ergoemacshttp://code.google.com/p/ergoemacs/
>
> it's fixed there.
O, just tried to reproduce your situation but there's a bit warning.
When you use ergoemacs, you can create buffers by Ctrl+n, which calls
new-empty-buffer. Then, in this buffer, if modified and not saved,
when you try to close it or quit emacs, emacs will prompt you to save
it.
However, it does not fix when if you just use switch-to-buffer (C-x b)
command to create a new buffer.
Here's the relevant source code. Note the line
(setq buffer-offer-save t).
Feel free to use it.
(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)))
;; note: emacs won't offer to save a buffer that's
;; not associated with a file,
;; even if buffer-modified-p is true.
;; One work around is to define your own my-kill-buffer function
;; that wraps around kill-buffer, and check on the buffer modification
;; status to offer save
;; This custome kill buffer is close-current-buffer.
Xah
∑ http://xahlee.org/
☄
next prev parent reply other threads:[~2009-08-20 2:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 0:22 Is it possible not to quit emacs when buffer is modified? YOUNG
2009-08-20 2:09 ` Xah Lee
2009-08-20 2:23 ` Xah Lee [this message]
2009-08-20 4:49 ` A.Politz
2009-08-20 18:44 ` young
2009-08-20 15:08 ` Michael Heerdegen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e72f3889-2b2a-49a6-bde5-9a2d0c31b7b7@u16g2000pru.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.