all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is it possible not to quit emacs when buffer is modified?
@ 2009-08-20  0:22 YOUNG
  2009-08-20  2:09 ` Xah Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: YOUNG @ 2009-08-20  0:22 UTC (permalink / raw
  To: help-gnu-emacs

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?

Regards,
Youngwhan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible not to quit emacs when buffer is modified?
  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
  2009-08-20  4:49 ` A.Politz
  2009-08-20 15:08 ` Michael Heerdegen
  2 siblings, 1 reply; 6+ messages in thread
From: Xah Lee @ 2009-08-20  2:09 UTC (permalink / raw
  To: help-gnu-emacs

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 ergoemacs
http://code.google.com/p/ergoemacs/

it's fixed there.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible not to quit emacs when buffer is modified?
  2009-08-20  2:09 ` Xah Lee
@ 2009-08-20  2:23   ` Xah Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Xah Lee @ 2009-08-20  2:23 UTC (permalink / raw
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible not to quit emacs when buffer is modified?
  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  4:49 ` A.Politz
  2009-08-20 18:44   ` young
  2009-08-20 15:08 ` Michael Heerdegen
  2 siblings, 1 reply; 6+ messages in thread
From: A.Politz @ 2009-08-20  4:49 UTC (permalink / raw
  To: help-gnu-emacs

On Aug 20, 2:22 am, 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?
>
> Regards,
> Youngwhan

One way to avoid this is the `buffer-offer-save' variable, e.g like
this.

(add-hook 'first-change-hook
          #'(lambda nil
              ;; set for all 'regular' buffers
              (unless (string-match "\\`[ *].*[*]\\'"
                                    (buffer-name))
                (setq buffer-offer-save t))))

-ap


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible not to quit emacs when buffer is modified?
  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  4:49 ` A.Politz
@ 2009-08-20 15:08 ` Michael Heerdegen
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2009-08-20 15:08 UTC (permalink / raw
  To: help-gnu-emacs

You could use emacs-lock.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible not to quit emacs when buffer is modified?
  2009-08-20  4:49 ` A.Politz
@ 2009-08-20 18:44   ` young
  0 siblings, 0 replies; 6+ messages in thread
From: young @ 2009-08-20 18:44 UTC (permalink / raw
  To: help-gnu-emacs

On Aug 19, 9:49 pm, "A.Politz" <poli...@googlemail.com> wrote:
> On Aug 20, 2:22 am, 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?
>
> > Regards,
> > Youngwhan
>
> One way to avoid this is the `buffer-offer-save' variable, e.g like
> this.
>
> (add-hook 'first-change-hook
>           #'(lambda nil
>               ;; set for all 'regular' buffers
>               (unless (string-match "\\`[ *].*[*]\\'"
>                                     (buffer-name))
>                 (setq buffer-offer-save t))))
>
> -ap

Thank you!

It works!

Regards,
Youngwhan


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-20 18:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-08-20  4:49 ` A.Politz
2009-08-20 18:44   ` young
2009-08-20 15:08 ` Michael Heerdegen

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.