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: Drew Adams
Subject: RE: Emacs ignores modified state of "untitled" buffer
Date: Fri, 21 May 2010 07:20:11 -0700

> > What am I missing? What is wrong with just using (find-file 
> > "untitled")?
> > 
> > If a buffer is associated with a file name (which is what 
> > `find-file' does) then Emacs asks you about saving it.
> > What else is the OP asking for?
> 
> C-x C-s won't ask.
>
> I can think of a couple nuisances:
> 
> * If the buffer gets saved to file "untitled", a subsequent 
> invocation of emacs will visit that file, not an empty buffer.
> 
> * Changes to the buffer will be auto-saved to the #untitled# 
> file, and a subsequent invocation of emacs will ask to recover
> the file (if the 2 invocations are concurrent, or if the first
> invocation exited uncleanly).

I see. It's clear now; thanks.

C-x C-s saves quietly (to the `buffer-file-name') without asking for a target
file (since it already has an associated file name).

The behavior of most programs is different: If no _previously saved_ file is
associated with the buffer, then trying to save makes the program ask for a file
name. For the first save, users are typically required to use `Save As' (or else
`Save' acts as `Save As' before the first save).

Your code implements, I think, just what is needed for the OP (and others). It
provides autosaving, saving without asking if already saved once, and saving
with asking if not yet saved.

You've offered this as command `switch-to-new-buffer' and put it on the
`Buffers' menu as `Select New Buffer'.

I would prefer that it be considered an improved behavior for `Visit New File',
which is currently just `find-file'. The use of your command is, I think, for
new file buffers only, so that intention should be reflected in both the command
name and menu-item name. The `Buffers' menu is the wrong place for this, IMO.

So I would suggest changing the command name to something like `new-file' or
`visit-new-file' and (more importantly) replacing the `File' > `Visit New File'
menu item with it.

Those who are most likely to use such a menu item are newbies who expect that
behavior. Any Emacs veteran who prefers `find-file' will not be likely to use
the menu and choose `Visit New File'. And it is clear what a `new-file' command
is for.

I agree with Lennart that you should think about proposing this to emacs-devel.
I would support it, especially with the changes I just mentioned.





reply via email to

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