From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs ignores modified state of "untitled" buffer
Date: Fri, 21 May 2010 07:17:25 -0600 [thread overview]
Message-ID: <ht6157$gdv$1@dough.gmane.org> (raw)
In-Reply-To: <13332868-CB10-41EE-AED7-3980DEB97220@nf.mpg.de>
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
next prev parent reply other threads:[~2010-05-21 13:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 14:52 Emacs ignores modified state of "untitled" buffer Stefan Vollmar
2010-05-19 15:04 ` Drew Adams
2010-05-19 20:34 ` Stephen Berman
2010-05-20 12:45 ` Kevin Rodgers
2010-05-20 13:29 ` Drew Adams
2010-05-20 14:00 ` Stefan Vollmar
2010-05-21 2:00 ` Kevin Rodgers
2010-05-21 2:06 ` Lennart Borgman
2010-05-21 1:56 ` Kevin Rodgers
2010-05-21 8:03 ` Stefan Vollmar
2010-05-21 13:17 ` Kevin Rodgers [this message]
2010-05-21 13:59 ` Stefan Vollmar
2010-05-21 14:11 ` Kevin Rodgers
2010-05-21 14:30 ` Stefan Vollmar
2010-05-21 17:15 ` Lennart Borgman
2010-05-21 20:49 ` Stefan Vollmar
2010-05-21 20:56 ` Lennart Borgman
2010-05-21 14:20 ` Drew Adams
2010-05-28 14:32 ` Kevin Rodgers
2010-05-28 17:18 ` Drew Adams
2010-05-28 21:21 ` Stefan Vollmar
[not found] ` <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org>
2010-05-29 1:04 ` Tim X
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='ht6157$gdv$1@dough.gmane.org' \
--to=kevin.d.rodgers@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.