GNU bug report logs - #77797
31.0.50; Visit an empty file on creating it

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Mon, 14 Apr 2025 11:59:02 UTC

Severity: normal

Found in version 31.0.50

Full log


Message #26 received at 77797 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 77797 <at> debbugs.gnu.org
Subject: Re: bug#77797: 31.0.50; Visit an empty file on creating it
Date: Tue, 15 Apr 2025 09:18:49 +0200
On Mon, 14 Apr 2025 18:59:11 +0200 Eshel Yaron <me <at> eshelyaron.com> wrote:

> 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:
>
> (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)

Thanks for the suggestion, but I think I'd rather not preempt the
basic-save-buffer prompt, it's a good safeguard, since C-x C-f is a very
high frequency command.  For the much rarer cases where I want to add a
new file in one or more new subdirectories, it's better to use a
command that I know is designed to do that.  If my proposal to enhance
make-empty-file is not accepted, I can just advise it or redefine it in
my init file.

Steve Berman




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.