help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to force auto-save of buffers not visiting files, right now?


From: tomas
Subject: Re: how to force auto-save of buffers not visiting files, right now?
Date: Sun, 20 Mar 2022 08:29:55 +0100

On Sun, Mar 20, 2022 at 07:36:42AM +0100, hw wrote:
> On Sat, 2022-03-19 at 10:58 +0100, Michael Albinus wrote:
> > hw <hw@adminart.net> writes:
> > 
> > Hi,
> > 
> > > For example, I may edit a file '/usr/local/bin/example.pl' which is
> > > owned by foo:foo because I made that so.  The directory
> > > '/usr/local/bin/' is owned by root.  How do you expect emacs to create
> > > a backup file there?  For remote files, I have set
> > > tramp-auto-save-directory to a local directory, and I'm missing an
> > > equivalent option for local files.
> > 
> > There is the user option auto-save-file-name-transforms, which gives you
> > this feature also for local files.
> 
> Thanks!
> 
> Its value is
> (("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" "/tmp/\\2" t))
> 
> Ah, hm, what is that regexp supposed to match?  All files with at
> least a ':', a bunch of slashes and some optional brackets?  Who puts
> bracktes into file names, that shouldn't be allowed.

The colon is to match remote files. That's the default. Tramp remote
files for Emacs have a prefix with a colon.

And the brackets are regexp metacharacters, [^/]* meaning zero or
more non-slashes (i.e. one path component)

Or do you mean the parentheses ()? Those are for grouping. Due to
Emacs's regexp syntax (not ERE) you have to escape them. The extra
backslash is for the string syntax.

> Apprently that leads to puttting some files into /tmp, and I would
> consider it a bug to put auto-save files into /tmp because doing that
> totally defeats the auto-saving because /tmp is volatile.

One person's bugs are other person's features. That's why you can
change it, after all.

I don't know why the default is as it is, but knowing Emacs I guess
there has been some discussion. I'll leave it to you to *POLITELY*
(hint, hint) ask around here if you are interested.

> I don't
> know who made the utterly stupid decision to make /tmp volatile,

Careful. You can change that, too, if you want. Someone thought
it to be useful. I'm around for long enough that I remember the
time before (for Gnu/Linux, anyway). I got along the change. It
has up- and downsides. Throwing "stupid" around won't change those
things :)

> but
> it's the way it is since quite a while now.  This default needs to be
> changed, or /tmp needs to go back to be a useful directory.

That depends on whether you want that auto-save file to persist
across operating system sessions or not. Not everybody agrees with
you (or me) on what a nice behaviour is.

> Why didn't they just make a directory /volatile in addition to /tmp?
> Because someone would argue that when something must not be saved,
> then don't save it to begin with?
> 
> But then, the auto-save files for buffers not visiting files show up
> in the directories the files are in from which the buffers not
> visiting these files were created.

In a way, yes. It's whatever the value of `default-directory' is,
I guess, unless you give it an absolute path.

> That is very confusing.

That's perhaps because there are not many people auto-saving
buffers without an associated file: not many around for testing!

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]