From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Emacs ignores modified state of "untitled" buffer Date: Fri, 21 May 2010 07:17:25 -0600 Message-ID: References: <51707DDA-8D52-4D9F-9FD4-461987F2DEDE@nf.mpg.de> <13332868-CB10-41EE-AED7-3980DEB97220@nf.mpg.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1274448934 21157 80.91.229.12 (21 May 2010 13:35:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 21 May 2010 13:35:34 +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 May 21 15:35:33 2010 connect(): No such file or directory 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.69) (envelope-from ) id 1OFSNw-0004Eq-FJ for geh-help-gnu-emacs@m.gmane.org; Fri, 21 May 2010 15:35:32 +0200 Original-Received: from localhost ([127.0.0.1]:37953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFSNt-0007cO-4T for geh-help-gnu-emacs@m.gmane.org; Fri, 21 May 2010 09:35:29 -0400 Original-Received: from [140.186.70.92] (port=49759 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFSLR-0006ft-HZ for help-gnu-emacs@gnu.org; Fri, 21 May 2010 09:33:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OFSLJ-0006Fp-G2 for help-gnu-emacs@gnu.org; Fri, 21 May 2010 09:32:55 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:46123) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFSLI-0006Eo-EP for help-gnu-emacs@gnu.org; Fri, 21 May 2010 09:32:49 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OFS6e-0001RP-1l for help-gnu-emacs@gnu.org; Fri, 21 May 2010 15:17:40 +0200 Original-Received: from c-71-237-24-138.hsd1.co.comcast.net ([71.237.24.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 May 2010 15:17:40 +0200 Original-Received: from kevin.d.rodgers by c-71-237-24-138.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 May 2010 15:17:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ connect(): No such file or directory Original-Lines: 56 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-71-237-24-138.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) In-Reply-To: <13332868-CB10-41EE-AED7-3980DEB97220@nf.mpg.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:73711 Archived-At: Stefan Vollmar wrote: > I have now tried: > > http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-09/msg00016.html > > site-start.el now ends with: > > (require 'switch-to-new-buffer) > (switch-to-new-untitled-buffer) > ;(org-mode) > (setq initial-buffer-choice 'none) > > This works fine - except that when I uncomment the (org-mode) line, > the "Untitled" buffer is set to Org-mode (as intended) but when I > close Emacs it will no longer ask about saving data if the buffer was > marked dirty. If the (org-mode) line is commented out, Emacs does ask > about saving (if it is required). I also tried c-mode instead of > Org-mode, same effect - so the problem is probably not related to > Org-mode. I was going to suggest: (let ((default-major-mode 'org-mode)) (switch-to-new-untitled-buffer)) But when I tested it, I found out it didn't work as intended. For that, the following version of switch-to-new-buffer is needed (I will post a new version of switch-to-new-buffer.el to gnu.emacs.sources and the EmacsWiki later): (defun switch-to-new-buffer () "Switch to a new buffer. The buffer name is the value of `switch-to-new-buffer-name', or \"*scratch*\" if that is nil. See `set-buffer-major-mode'." (interactive) (let ((new-buffer (generate-new-buffer (or switch-to-new-buffer-name "*scratch*")))) (set-buffer-major-mode new-buffer) ;; Protect against kill-emacs: (setq buffer-offer-save t) ;; Protect against kill-buffer: (add-hook 'kill-buffer-query-functions 'switch-to-new-buffer-kill-buffer-query-function nil t) ;; Finally, select: (switch-to-buffer new-buffer))) > I guess changing the mode somehow overwrites the kill protections in switch-to-new-buffer? Yes, via kill-all-local-variables. -- Kevin Rodgers Denver, Colorado, USA