help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs ignores modified state of "untitled" buffer


From: Kevin Rodgers
Subject: Re: Emacs ignores modified state of "untitled" buffer
Date: Fri, 21 May 2010 08:11:30 -0600
User-agent: Thunderbird 2.0.0.24 (Macintosh/20100228)

Stefan Vollmar wrote:
we now use

(require 'switch-to-new-buffer)
(let ((default-major-mode 'org-mode))
 (switch-to-new-untitled-buffer))

> in site-start.el and also have replaced switch-to-new-buffer() with
> your new routine. Emacs starts with an "untitled" buffer in Org-mode,
> but does not ask when closing the buffer with unsaved data. If this
> did work (it does not), what would happen to the "untitled" buffer if
> the user switches "manually" to another major mode?

Hi Stefan, sorry about that -- I moved the function to display the buffer
from the beginning to the end and didn't take into account that it also
is responsible for making the buffer current.

Here's the fixed version:

(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)
    (with-current-buffer 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)))

--
Kevin Rodgers
Denver, Colorado, USA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]