* save-buffer when directory doesn't exist
@ 2007-03-10 9:43 martin rudalics
2007-03-20 8:09 ` Jason Spiro
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-03-10 9:43 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
Assume I modify *scratch* and try to `save-buffer' it as ".../bar/foo".
(I know `write-file' should be used for this purpose but `save-buffer'
offers the service as well.) Assume further, I mistype the name as
".../baz/foo" where the subdirectory "baz" does not exist. Emacs will
complain as:
basic-save-buffer-2: .../baz/foo: no such directory
which is misleading since ".../baz/foo" is supposed to be a file.
Assume now I notice my mistake and want to `save-buffer' *scratch* in
the existing directory ".../bar/". Emacs will insist on storing my
buffer as ".../baz/foo" and continue telling me that such a directory
doesn't exist.
After a while `auto-save-mode' may kick in and add to my confusion by
complaining
Auto-saving foo: Opening output file: no such file or directory, .../baz/#foo#
This confusion could be relieved by the attached patch.
[-- Attachment #2: files.patch --]
[-- Type: text/plain, Size: 1428 bytes --]
*** files.el Fri Mar 9 07:48:34 2007
--- files.el Sat Mar 10 10:38:28 2007
***************
*** 3599,3606 ****
(setq buffer-new-name (buffer-name buf))
(kill-buffer buf))
(rename-buffer buffer-new-name)))
! ;; If buffer has no file name, ask user for one.
! (or buffer-file-name
(let ((filename
(expand-file-name
(read-file-name "File to save in: ") nil)))
--- 3599,3607 ----
(setq buffer-new-name (buffer-name buf))
(kill-buffer buf))
(rename-buffer buffer-new-name)))
! ;; If buffer has no file name or the visited file is not writable, ask
! ;; user for one.
! (or (and buffer-file-name (file-writable-p buffer-file-name))
(let ((filename
(expand-file-name
(read-file-name "File to save in: ") nil)))
***************
*** 3681,3687 ****
(if (not (file-directory-p dir))
(if (file-exists-p dir)
(error "%s is not a directory" dir)
! (error "%s: no such directory" buffer-file-name))
(if (not (file-exists-p buffer-file-name))
(error "Directory %s write-protected" dir)
(if (yes-or-no-p
--- 3682,3688 ----
(if (not (file-directory-p dir))
(if (file-exists-p dir)
(error "%s is not a directory" dir)
! (error "%s: no such directory" dir))
(if (not (file-exists-p buffer-file-name))
(error "Directory %s write-protected" dir)
(if (yes-or-no-p
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-03-10 9:43 save-buffer when directory doesn't exist martin rudalics
@ 2007-03-20 8:09 ` Jason Spiro
2007-03-20 9:46 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Jason Spiro @ 2007-03-20 8:09 UTC (permalink / raw)
To: emacs-devel
martin rudalics <rudalics <at> gmx.at> writes:
>
> Assume I modify *scratch* and try to `save-buffer' it as ".../bar/foo".
> (I know `write-file' should be used for this purpose but `save-buffer'
> offers the service as well.) Assume further, I mistype the name as
> ".../baz/foo" where the subdirectory "baz" does not exist. Emacs will
> complain as:
>
> basic-save-buffer-2: .../baz/foo: no such directory
>
> which is misleading since ".../baz/foo" is supposed to be a file.
>
> Assume now I notice my mistake and want to `save-buffer' *scratch* in
> the existing directory ".../bar/". Emacs will insist on storing my
> buffer as ".../baz/foo" and continue telling me that such a directory
> doesn't exist.
>
> After a while `auto-save-mode' may kick in and add to my confusion by
> complaining
>
> Auto-saving foo: Opening output file: no such file or directory, .../baz/#foo#
>
> This confusion could be relieved by the attached patch.
I am not an Emacs developer, and I have not tested the patch (I am on a Windows
machine without Cygwin or patch(1) right now). But Martin's problem seems to be
valid, and his patch seems like it will fix it. Would it be helpful if I tested
the patch on my Linux PC? I could check that it works and see if it does
something about the auto-save errors too.
Regards,
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-03-20 8:09 ` Jason Spiro
@ 2007-03-20 9:46 ` martin rudalics
2007-04-06 23:38 ` Jason Spiro
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-03-20 9:46 UTC (permalink / raw)
To: Jason Spiro; +Cc: emacs-devel
> I am not an Emacs developer, and I have not tested the patch (I am on a Windows
> machine without Cygwin or patch(1) right now). But Martin's problem seems to be
> valid, and his patch seems like it will fix it. Would it be helpful if I tested
> the patch on my Linux PC? I could check that it works and see if it does
> something about the auto-save errors too.
I just checked in a slightly modified version. Could you test it on your
GNU Linux machine?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-03-20 9:46 ` martin rudalics
@ 2007-04-06 23:38 ` Jason Spiro
2007-04-07 7:33 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Jason Spiro @ 2007-04-06 23:38 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
> I just checked in a slightly modified version. Could you test it on your
> GNU Linux machine?
>
I like the new error message much better. But now that I think about
it, the error message could be improved even more. Instead of
"/ho,e/j/Desktop/: no such directory", how about this?
Cannot save /ho,e/jspiro/Desktop/todo.txt because directory /ho,e does not exist
I did 4 things different in my suggested example: I used the word
"because"; I added a verbose explanation of why it failed; I left
out the trailing slash on the directory name since I think it looks
better that way; and I only mentioned the nonexistent directory /ho,e
and not its subdirectories.
By the way, what can be done about the annoying "can't auto-save"
messages? I wish emacs would just auto-save to /tmp by default.
Cheers,
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-04-06 23:38 ` Jason Spiro
@ 2007-04-07 7:33 ` martin rudalics
2007-04-08 21:42 ` Jason Spiro
0 siblings, 1 reply; 7+ messages in thread
From: martin rudalics @ 2007-04-07 7:33 UTC (permalink / raw)
To: Jason Spiro; +Cc: emacs-devel
> I like the new error message much better. But now that I think about
> it, the error message could be improved even more. Instead of
> "/ho,e/j/Desktop/: no such directory", how about this?
>
> Cannot save /ho,e/jspiro/Desktop/todo.txt because directory /ho,e does
> not exist
>
> I did 4 things different in my suggested example: I used the word
> "because"; I added a verbose explanation of why it failed; I left
> out the trailing slash on the directory name since I think it looks
> better that way; and I only mentioned the nonexistent directory /ho,e
> and not its subdirectories.
Then I would have to change the text in `basic-save-buffer-2' as well.
I don't want to think about the consequences of doing that now. BTW,
`file-exists-p' won't tell me which subdirectory doesn't exist.
> By the way, what can be done about the annoying "can't auto-save"
> messages? I wish emacs would just auto-save to /tmp by default.
Are you sure that you get them now? When the directory doesn't exist
`set-visited-file-name' should _not_ be executed and auto-saving should
_not_ try to save the buffer. Anything else wold be a bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-04-07 7:33 ` martin rudalics
@ 2007-04-08 21:42 ` Jason Spiro
2007-04-09 8:50 ` martin rudalics
0 siblings, 1 reply; 7+ messages in thread
From: Jason Spiro @ 2007-04-08 21:42 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
2007/4/7, martin rudalics <rudalics@gmx.at> wrote:
> > I like the new error message much better. But now that I think about
> > it, the error message could be improved even more. Instead of
> > "/ho,e/j/Desktop/: no such directory", how about this?
> >
> > Cannot save /ho,e/jspiro/Desktop/todo.txt because directory /ho,e does
> > not exist
> >
> > I did 4 things different in my suggested example: I used the word
> > "because"; I added a verbose explanation of why it failed; I left
> > out the trailing slash on the directory name since I think it looks
> > better that way; and I only mentioned the nonexistent directory /ho,e
> > and not its subdirectories.
>
> Then I would have to change the text in `basic-save-buffer-2' as well.
> I don't want to think about the consequences of doing that now. BTW,
> `file-exists-p' won't tell me which subdirectory doesn't exist.
That's fair. But wouldn't it be better to at least use a more verbose
text like "Cannot save file: no such directory /ho,e/j/Desktop"?
> > By the way, what can be done about the annoying "can't auto-save"
> > messages? I wish emacs would just auto-save to /tmp by default.
>
> Are you sure that you get them now? When the directory doesn't exist
> `set-visited-file-name' should _not_ be executed and auto-saving should
> _not_ try to save the buffer. Anything else wold be a bug.
Never mind.
Regards,
Jason
--
Jason Spiro: computer consulting with a smile.
I provide software development and training services to clients worldwide.
Contact me for a FREE consultation. Satisfaction guaranteed.
+1 (416) 781-5938 / Email: info@jspiro.com / MSN: jasonspiro@hotmail.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: save-buffer when directory doesn't exist
2007-04-08 21:42 ` Jason Spiro
@ 2007-04-09 8:50 ` martin rudalics
0 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2007-04-09 8:50 UTC (permalink / raw)
To: Jason Spiro; +Cc: emacs-devel
> That's fair. But wouldn't it be better to at least use a more verbose
> text like "Cannot save file: no such directory /ho,e/j/Desktop"?
Maybe. But as I said earlier we would have to check all
file-saving related messages if we changed this one.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-04-09 8:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-10 9:43 save-buffer when directory doesn't exist martin rudalics
2007-03-20 8:09 ` Jason Spiro
2007-03-20 9:46 ` martin rudalics
2007-04-06 23:38 ` Jason Spiro
2007-04-07 7:33 ` martin rudalics
2007-04-08 21:42 ` Jason Spiro
2007-04-09 8:50 ` martin rudalics
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.