* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. [not found] <E1U5BzI-0002eB-PS@vcs.savannah.gnu.org> @ 2013-02-13 11:05 ` Bastien 2013-02-13 15:08 ` Stefan Monnier 0 siblings, 1 reply; 8+ messages in thread From: Bastien @ 2013-02-13 11:05 UTC (permalink / raw) To: Glenn Morris; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 244 bytes --] Hi Glenn, Glenn Morris <rgm@gnu.org> writes: > * files.el (basic-save-buffer): Offer to create a non-existing > directory. The attached patch implements the same change for `find-file'. Let me know if it's okay to apply this. Thanks! [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: files.el.patch --] [-- Type: text/x-patch, Size: 1058 bytes --] === modified file 'lisp/files.el' --- lisp/files.el 2013-02-12 08:36:09 +0000 +++ lisp/files.el 2013-02-13 11:04:03 +0000 @@ -2077,6 +2077,7 @@ (if noninteractive nil (let* (not-serious + (dir (file-name-directory buffer-file-name)) (msg (cond ((not warn) nil) @@ -2105,11 +2106,14 @@ "Note: file is write protected") ((file-attributes (directory-file-name default-directory)) "File not found and directory write-protected") - ((file-exists-p (file-name-directory buffer-file-name)) + ((file-exists-p dir) (setq buffer-read-only nil)) (t (setq buffer-read-only nil) - "Use M-x make-directory RET RET to create the directory and its parents")))) + (if (not (y-or-n-p (format "Directory `%s' does not exist; create? " dir))) + "Use M-x make-directory RET RET to create the directory and its parents" + (make-directory dir t) + (format "Directory %s has been created" dir)))))) (when msg (message "%s" msg) (or not-serious (sit-for 1 t)))) [-- Attachment #3: Type: text/plain, Size: 14 bytes --] -- Bastien ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 11:05 ` /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory Bastien @ 2013-02-13 15:08 ` Stefan Monnier 2013-02-13 16:54 ` Bastien 2013-02-14 6:23 ` Thierry Volpiatto 0 siblings, 2 replies; 8+ messages in thread From: Stefan Monnier @ 2013-02-13 15:08 UTC (permalink / raw) To: Bastien; +Cc: emacs-devel >> * files.el (basic-save-buffer): Offer to create a non-existing >> directory. > The attached patch implements the same change for `find-file'. Now that save lets you create the dir, why would you need to do that in find-file? Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 15:08 ` Stefan Monnier @ 2013-02-13 16:54 ` Bastien 2013-02-13 19:27 ` Stefan Monnier 2013-02-14 6:23 ` Thierry Volpiatto 1 sibling, 1 reply; 8+ messages in thread From: Bastien @ 2013-02-13 16:54 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel Stefan Monnier <monnier@IRO.UMontreal.CA> writes: >>> * files.el (basic-save-buffer): Offer to create a non-existing >>> directory. >> The attached patch implements the same change for `find-file'. > > Now that save lets you create the dir, why would you need to do that in > find-file? To spare you from having to do it at saving time? I often use C-x s to save all buffers, I would find it more convenient to be asked for the creation of the dir when finding the file. Also right now, when finding a file in a non-existing dir, the user is taught how to create the directory... which seems a bit redundant with the fact that he will be asked to create the dir anyway. Probably not a big deal, though. -- Bastien ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 16:54 ` Bastien @ 2013-02-13 19:27 ` Stefan Monnier 2013-02-13 23:58 ` Xue Fuqiao 2013-02-14 6:23 ` Bastien 0 siblings, 2 replies; 8+ messages in thread From: Stefan Monnier @ 2013-02-13 19:27 UTC (permalink / raw) To: Bastien; +Cc: emacs-devel > I often use C-x s to save all buffers, I would find it > more convenient to be asked for the creation of the dir > when finding the file. I'm not opposed to it on principles, but I think that the default behavior should not do it, so as to minimize the risk that find-file ends up prompting in a context where the user is absent or doesn't even know that a file needs to be opened (internal uses of find-file-noselect). > Also right now, when finding a file in a non-existing > dir, the user is taught how to create the directory... > which seems a bit redundant with the fact that he will > be asked to create the dir anyway. It's still meaningful in that it warns the user that maybe the name he provided was wrong, or that at the dir has not yet been created. Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 19:27 ` Stefan Monnier @ 2013-02-13 23:58 ` Xue Fuqiao 2013-02-14 6:23 ` Bastien 1 sibling, 0 replies; 8+ messages in thread From: Xue Fuqiao @ 2013-02-13 23:58 UTC (permalink / raw) To: Stefan Monnier; +Cc: Bastien, emacs-devel On Wed, 13 Feb 2013 14:27:59 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote: > > I often use C-x s to save all buffers, I would find it > > more convenient to be asked for the creation of the dir > > when finding the file. > I'm not opposed to it on principles, but I think that the default > behavior should not do it, so as to minimize the risk that find-file > ends up prompting in a context where the user is absent or doesn't even > know that a file needs to be opened (internal uses of find-file-noselect). > > Also right now, when finding a file in a non-existing > > dir, the user is taught how to create the directory... > > which seems a bit redundant with the fact that he will > > be asked to create the dir anyway. > It's still meaningful in that it warns the user that maybe the name he > provided was wrong, or that at the dir has not yet been created. I agree with Stefan. -- Best regards, Xue Fuqiao. http://www.emacswiki.org/emacs/XueFuqiao ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 19:27 ` Stefan Monnier 2013-02-13 23:58 ` Xue Fuqiao @ 2013-02-14 6:23 ` Bastien 1 sibling, 0 replies; 8+ messages in thread From: Bastien @ 2013-02-14 6:23 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel Hi Stefan, Stefan Monnier <monnier@iro.umontreal.ca> writes: >> I often use C-x s to save all buffers, I would find it >> more convenient to be asked for the creation of the dir >> when finding the file. > > I'm not opposed to it on principles, but I think that the default > behavior should not do it, so as to minimize the risk that find-file > ends up prompting in a context where the user is absent or doesn't even > know that a file needs to be opened (internal uses of find-file-noselect). > >> Also right now, when finding a file in a non-existing >> dir, the user is taught how to create the directory... >> which seems a bit redundant with the fact that he will >> be asked to create the dir anyway. > > It's still meaningful in that it warns the user that maybe the name he > provided was wrong, or that at the dir has not yet been created. I see, and I agree -- thanks for the explanations. PS: For the "small story", a user came on Org's mailing a few days ago, requesting that Org would auto-create missing directories when following links to org files. I told him this was more of an Emacs issue and by magic, Glenn implemented this for save. So I thought I'd go for what the OP wanted too. -- Bastien ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-13 15:08 ` Stefan Monnier 2013-02-13 16:54 ` Bastien @ 2013-02-14 6:23 ` Thierry Volpiatto 2013-02-14 13:59 ` Stefan Monnier 1 sibling, 1 reply; 8+ messages in thread From: Thierry Volpiatto @ 2013-02-14 6:23 UTC (permalink / raw) To: emacs-devel Stefan Monnier <monnier@IRO.UMontreal.CA> writes: >>> * files.el (basic-save-buffer): Offer to create a non-existing >>> directory. >> The attached patch implements the same change for `find-file'. > > Now that save lets you create the dir, why would you need to do that in > find-file? Didn't look at the change in `basic-save-buffer' but it looks like it is asking for directory creation of "newdir" when buffer-name is "/newdir/newbufferfile", but what about find-file => /newdir/ ? Looks like actually a buffer "/newdir/" is created, which is non--sense IMHO. Here in helm user is asked for directory creation in such case. -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory. 2013-02-14 6:23 ` Thierry Volpiatto @ 2013-02-14 13:59 ` Stefan Monnier 0 siblings, 0 replies; 8+ messages in thread From: Stefan Monnier @ 2013-02-14 13:59 UTC (permalink / raw) To: Thierry Volpiatto; +Cc: emacs-devel > Didn't look at the change in `basic-save-buffer' but it looks like it is > asking for directory creation of "newdir" when buffer-name is > "/newdir/newbufferfile", but what about find-file => /newdir/ ? > Looks like actually a buffer "/newdir/" is created, which is non--sense > IMHO. Indeed, we have a bug here. It should create a dired buffer. Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-02-14 13:59 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <E1U5BzI-0002eB-PS@vcs.savannah.gnu.org> 2013-02-13 11:05 ` /srv/bzr/emacs/trunk r111746: * files.el (basic-save-buffer): Offer to create a non-existing directory Bastien 2013-02-13 15:08 ` Stefan Monnier 2013-02-13 16:54 ` Bastien 2013-02-13 19:27 ` Stefan Monnier 2013-02-13 23:58 ` Xue Fuqiao 2013-02-14 6:23 ` Bastien 2013-02-14 6:23 ` Thierry Volpiatto 2013-02-14 13:59 ` Stefan Monnier
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.