write-file to a directory in helm-mode

34 views
Skip to first unread message

Julien Cubizolles

unread,
Nov 24, 2017, 12:48:29 AM11/24/17
to emacs...@googlegroups.com
In helm-mode, write-file can't be used to copy a file to another
directory with the same name. When visiting file.org, invoking
write-file and selecting ~/directory/ in the completing buffer gives
"File ''~/directory/.' exists; overwrite ?" Of course that's not what I
want, I want to write ~/directory/file.org. Can helm be made to use the
current file-name by default the way write-file does when not in
helm-mode ?

Julien.

Thierry Volpiatto

unread,
Nov 24, 2017, 1:53:48 AM11/24/17
to emacs...@googlegroups.com

Julien Cubizolles <j.cubi...@free.fr> writes:

> In helm-mode, write-file can't be used to copy a file to another
> directory with the same name. When visiting file.org, invoking
> write-file and selecting ~/directory/ in the completing buffer gives
> "File ''~/directory/.' exists; overwrite ?" Of course that's not what I
> want, I want to write ~/directory/file.org.

Of course.
It is working in emacs-25.3, I can only reproduce your bug in
emacs-27.0.50, which is due to recent changes (stupid IMO) in files.el,

> Can helm be made to use the current file-name by default the way
> write-file does when not in helm-mode?

Will try to see what I can do.

Thanks.

--
Thierry

Thierry Volpiatto

unread,
Nov 24, 2017, 2:14:39 AM11/24/17
to emacs...@googlegroups.com

Thierry Volpiatto <thierry....@gmail.com> writes:

> Julien Cubizolles <j.cubi...@free.fr> writes:
>
>> In helm-mode, write-file can't be used to copy a file to another
>> directory with the same name. When visiting file.org, invoking
>> write-file and selecting ~/directory/ in the completing buffer gives
>> "File ''~/directory/.' exists; overwrite ?" Of course that's not what I
>> want, I want to write ~/directory/file.org.
>
> Of course.
> It is working in emacs-25.3, I can only reproduce your bug in
> emacs-27.0.50, which is due to recent changes (stupid IMO) in files.el,

Here are the changes:

61946d991b663c9d35a50b758d0108c3cbf8027b
Author: Paul Eggert <egg...@cs.ucla.edu>
AuthorDate: Sun Sep 10 22:19:01 2017 -0700
Commit: Paul Eggert <egg...@cs.ucla.edu>
CommitDate: Sun Sep 10 22:31:23 2017 -0700

Parent: e22794867d8 Make copy-directory act like copy-file etc.
Containing: master
Follows: emacs-25.1 (129998)

Make write-file act like copy-file etc.

Change write-file to be consistent with the new behavior
of copy-file, etc.
* etc/NEWS: Mention this.
* lisp/files.el (write-file): Treat the destination as special
only if it is a directory name.


--
Thierry

Thierry Volpiatto

unread,
Nov 24, 2017, 2:27:39 AM11/24/17
to emacs...@googlegroups.com
Is this working for you?

(defun tv/advice--write-file (old-fn &rest args)
(cl-letf (((symbol-function 'directory-name-p)
#'file-directory-p))
(apply old-fn args)))
(advice-add 'write-file :around #'tv/advice--write-file)

--
Thierry

Thierry Volpiatto

unread,
Nov 24, 2017, 4:06:54 AM11/24/17
to emacs...@googlegroups.com

See https://github.com/emacs-helm/helm/issues/1920

Please report there if commit c8bfb71 fixes your issue.

Thanks.

--
Thierry
Reply all
Reply to author
Forward
0 new messages