The t flag is the 'uniquify' flag, which roughly means "replace all
slashes by exclamation marks".
However, this way it is possible to create a file name that is invalid
for use in the file system tree, especially if the file you are editing
is deeply nested.
Would it be possible, to, maybe, add a flag "ensure-filesystem-correctness"?
In GNU Emacs 27.1 (build 1, x86_64-slackware-linux-gnu, GTK+ Version 3.24.24)
of 2021-02-18 built on delllaptop.lockywolf.net
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Slackware 14.2 x86_64 (post 14.2 -current)
221 2.0.0 closing connection k127sm19044528pfd.63 - gsmtp
Successfully sent message via lockywolf-gmail account
[mu4e] Message sent
init.el has auto save data; consider M-x recover-this-file
Mark saved where search started
value of $LC_COLLATE: C
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
Major mode: mu4e-headers
Minor modes in effect:
> In order to avoid littering my file system with autosaves, I have the
> following setting in my .emacs:
> (setq auto-save-file-name-transforms '((".*" "~/.emacs.d/autosave/" t)))
> The t flag is the 'uniquify' flag, which roughly means "replace all
> slashes by exclamation marks".
> However, this way it is possible to create a file name that is invalid
> for use in the file system tree, especially if the file you are editing
> is deeply nested.
Could you pls show an example of such invalid file name?
> Would it be possible, to, maybe, add a flag "ensure-filesystem-correctness"?
Maybe we could have a flag which means "convert the directory part of a
file name into sha1" (or whatever `secure-hash' provides).
bug#47493: 27.1; auto-save-file-name-transforms with uniquify should not create invalid filenames
Michael Albinus wrote:
> Nobody has commented.
You asked for an example of why this was needed; I was waiting to hear
> + If the optional element UNIQUIFY is a symbol returned by function
> + `secure-hash-algorithms', the auto-save file name is constructed
> + by taking the directory part of the replaced file-name,
> + concatenated with the buffer file name run through `secure-hash'
> + instead. This returns a valid name for your filesystem any way.
If UNIQUIFY is one of the members of `secure-hash-algorithms',
Emacs constructs the nondirectory part of the auto-save file name by
applying that `secure-hash' to the buffer file name. This avoids any
risk of excessively long file names.
>> Nobody has commented.
> You asked for an example of why this was needed; I was waiting to hear
> the answer.
Same here. However, the docstring of auto-save-file-name-transforms
speaks about the problem, so I believe it is a real one.
>> + If the optional element UNIQUIFY is a symbol returned by function
>> + `secure-hash-algorithms', the auto-save file name is constructed
>> + by taking the directory part of the replaced file-name,
>> + concatenated with the buffer file name run through `secure-hash'
>> + instead. This returns a valid name for your filesystem any way.
> Grammar tweaks:
> If UNIQUIFY is one of the members of `secure-hash-algorithms',
> Emacs constructs the nondirectory part of the auto-save file name by
> applying that `secure-hash' to the buffer file name. This avoids any
> risk of excessively long file names.