From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Is it possible not to quit emacs when buffer is modified? Date: Wed, 19 Aug 2009 19:23:06 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <3fa169e2-c16c-46cb-bbab-7329ccd554b8@f20g2000prn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1250860862 24143 80.91.229.12 (21 Aug 2009 13:21:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Aug 2009 13:21:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 21 15:20:55 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MeU33-0003uU-VM for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Aug 2009 15:20:54 +0200 Original-Received: from localhost ([127.0.0.1]:52646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeU33-00018x-Au for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Aug 2009 09:20:53 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!postnews.google.com!u16g2000pru.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 50 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1250734988 2205 127.0.0.1 (20 Aug 2009 02:23:08 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 20 Aug 2009 02:23:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u16g2000pru.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.39 Safari/530.5, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:172125 comp.emacs:98621 X-Mailman-Approved-At: Fri, 21 Aug 2009 09:08:43 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:67341 Archived-At: On Aug 19, 7:09 pm, Xah Lee wrote: > On Aug 19, 5:22 pm, YOUNG 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 =E2=88=91 http://xahlee.org/ =E2=98=84