unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
@ 2009-04-16 12:37 Daniel Clemente
  2013-02-12  8:37 ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Clemente @ 2009-04-16 12:37 UTC (permalink / raw)
  To: emacs-pretest-bug



1. Do: C-x C-f /tmp/doesnotexist/myfile RET. Emacs tells you about make-directory
2. Type something.
3. C-x C-s. Error: no such directory

I suggest that Emacs not only tell the user about make-directory, but actually ask him/her in a y-n question if the directory should be created. This should happen on save.

The script could be then:

a. User does: C-x C-f /tmp/doesnotexist/myfile RET
b. Emacs warns: Warning: Directory /tmp/doesnotexist does not exist
c. User types something
d. User does: C-x C-s
e. Emacs asks: Create directory /tmp/doesnotexist? (y/n)
f1. If yes, it (and the above directories) are created
f2. If not, issue an error. The user can then do M-x make-directory as needed


This allows a faster save with just one extra key (C-x C-s y) instead of having to type M-x make-directory /tmp/doesnotexist RET C-x C-s










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

* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
  2009-04-16 12:37 bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed Daniel Clemente
@ 2013-02-12  8:37 ` Glenn Morris
  2013-02-20 15:33   ` Kazuhiro Ito
  0 siblings, 1 reply; 6+ messages in thread
From: Glenn Morris @ 2013-02-12  8:37 UTC (permalink / raw)
  To: 3016-done

Version: 24.4

Daniel Clemente wrote:

> 1. Do: C-x C-f /tmp/doesnotexist/myfile RET. Emacs tells you about
> make-directory
> 2. Type something.
> 3. C-x C-s. Error: no such directory
>
> I suggest that Emacs not only tell the user about make-directory, but
> actually ask him/her in a y-n question if the directory should be
> created. This should happen on save.

Sorry for the huge delay. This seems like a good idea, so I did it.





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

* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
  2013-02-12  8:37 ` Glenn Morris
@ 2013-02-20 15:33   ` Kazuhiro Ito
  2013-02-20 21:28     ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Kazuhiro Ito @ 2013-02-20 15:33 UTC (permalink / raw)
  To: rgm; +Cc: dcl441-bugs, 3016

At Tue, 12 Feb 2013 03:37:39 -0500,
Glenn Morris wrote:
> 
> Version: 24.4
> 
> Daniel Clemente wrote:
> 
> > 1. Do: C-x C-f /tmp/doesnotexist/myfile RET. Emacs tells you about
> > make-directory
> > 2. Type something.
> > 3. C-x C-s. Error: no such directory
> >
> > I suggest that Emacs not only tell the user about make-directory, but
> > actually ask him/her in a y-n question if the directory should be
> > created. This should happen on save.
> 
> Sorry for the huge delay. This seems like a good idea, so I did it.

I want this check is done more later.  Because, in draft buffers of
Wanderlust (a message user agent), buffer-file-name does not indicate
actual file name and saving file is done via hook functions (such as
write-contents-functions, local-write-file-hooks,
write-file-functions).  In such case, this offer could make incorrect
directory.

-- 
Kazuhiro Ito





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

* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
  2013-02-20 15:33   ` Kazuhiro Ito
@ 2013-02-20 21:28     ` Glenn Morris
  2013-02-21  9:52       ` Kazuhiro Ito
  0 siblings, 1 reply; 6+ messages in thread
From: Glenn Morris @ 2013-02-20 21:28 UTC (permalink / raw)
  To: Kazuhiro Ito; +Cc: dcl441-bugs, 3016

Kazuhiro Ito wrote:

> I want this check is done more later.  Because, in draft buffers of
> Wanderlust (a message user agent), buffer-file-name does not indicate
> actual file name and saving file is done via hook functions (such as
> write-contents-functions, local-write-file-hooks,
> write-file-functions).  In such case, this offer could make incorrect
> directory.

My initial reaction is to ask why you can't just set buffer-file-name to
the right value (or to nil, so that basic-save-buffer will prompt for
it); or at least to something whose parent directory exists, and then do
whatever checks you want in your hook functions?

By doing it the way you do, it sounds like you must already be missing
the other checks that basic-save-buffer does (overwriting an existing
file, saving to a directory rather than a file, verify file modtime),
though they may not be relevant in your case.





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

* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
  2013-02-20 21:28     ` Glenn Morris
@ 2013-02-21  9:52       ` Kazuhiro Ito
  2013-02-21 17:05         ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Kazuhiro Ito @ 2013-02-21  9:52 UTC (permalink / raw)
  To: Glenn Morris; +Cc: dcl441-bugs, 3016

At Wed, 20 Feb 2013 16:28:21 -0500,
Glenn Morris wrote:
> 
> Kazuhiro Ito wrote:
> 
> > I want this check is done more later.  Because, in draft buffers of
> > Wanderlust (a message user agent), buffer-file-name does not indicate
> > actual file name and saving file is done via hook functions (such as
> > write-contents-functions, local-write-file-hooks,
> > write-file-functions).  In such case, this offer could make incorrect
> > directory.
> 
> My initial reaction is to ask why you can't just set buffer-file-name to
> the right value (or to nil, so that basic-save-buffer will prompt for
> it); or at least to something whose parent directory exists, and then do
> whatever checks you want in your hook functions?

In Wanderlust, the file name (represented by message number) for the
draft is decided when buffer is made.  But Wanderlust updates it to
make the latest saved draft have largest number.  So, Wanderlust needs
to check and modify the file name at saving for the case that another
draft is saved while editing the draft.  Setting buffer-file-name to
existing directory could avoid the present problem, but I think that
is very ad hoc.

> By doing it the way you do, it sounds like you must already be missing
> the other checks that basic-save-buffer does (overwriting an existing
> file, saving to a directory rather than a file, verify file modtime),
> though they may not be relevant in your case.

Thank you for pointing it out.  It seems that Emacs does not expect
buffer-file-name is modified while hook functions.  Additionally, I
noticed that Wanderlust could save draft into non-local file, i.e.
remote imap4 server.  If basic-save-buffer really does not support
such cases, Wanderlust would need the workaround or to have own draft
saving function.

-- 
Kazuhiro Ito





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

* bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed
  2013-02-21  9:52       ` Kazuhiro Ito
@ 2013-02-21 17:05         ` Glenn Morris
  0 siblings, 0 replies; 6+ messages in thread
From: Glenn Morris @ 2013-02-21 17:05 UTC (permalink / raw)
  To: Kazuhiro Ito; +Cc: 3016

Kazuhiro Ito wrote:

>> > I want this check is done more later.  Because, in draft buffers of
>> > Wanderlust (a message user agent), buffer-file-name does not indicate
>> > actual file name and saving file is done via hook functions (such as
>> > write-contents-functions, local-write-file-hooks,
>> > write-file-functions).  In such case, this offer could make incorrect
>> > directory.

I had to move it after the hooks anyway, due to

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13773






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

end of thread, other threads:[~2013-02-21 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-16 12:37 bug#3016: 23.0.92.2; offer to make a directory when saving if it is needed Daniel Clemente
2013-02-12  8:37 ` Glenn Morris
2013-02-20 15:33   ` Kazuhiro Ito
2013-02-20 21:28     ` Glenn Morris
2013-02-21  9:52       ` Kazuhiro Ito
2013-02-21 17:05         ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).