GNU bug report logs -
#77797
31.0.50; Visit an empty file on creating it
Previous Next
Full log
Message #17 received at 77797 <at> debbugs.gnu.org (full text, mbox):
Hi,
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: 77797 <at> debbugs.gnu.org
>> Date: Mon, 14 Apr 2025 17:14:03 +0200
>>
>> Since you don't necessarily object, what's the next step?
>
> I'd like to hear more opinions about this, since I think it takes that
> command in directions we didn't intend it to go.
FWIW, I use C-x C-f to create new files all the time, also in
non-existing directories. Then I save the buffer as usual, and that
prompts me to create the directory if needed, which I find to be fine.
So I probably wouldn't find much use for this addition. I wouldn't mind
if it was added nonetheless, of course.
BTW if you want to suppress the prompt for creating a new directory and
always just create it when needed, you can (ab)use write-file-functions
for that:
--8<---------------cut here---------------start------------->8---
(defun my-ensure-dir ()
(let ((dir (file-name-directory (buffer-file-name))))
(unless (file-directory-p dir)
(make-directory dir t)))
nil)
(add-hook 'write-file-functions #'my-ensure-dir)
--8<---------------cut here---------------end--------------->8---
Best regards,
Eshel
This bug report was last modified 62 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.