unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: hw <hw@adminart.net>
To: help-gnu-emacs@gnu.org
Subject: Re: how to force auto-save of buffers not visiting files, right now?
Date: Fri, 18 Mar 2022 09:28:10 +0100	[thread overview]
Message-ID: <9f32ac59eb1bc186b015c0b6c5b94822e70d4135.camel@adminart.net> (raw)
In-Reply-To: <87wngsmdwp.fsf@web.de>



On Thu, 2022-03-17 at 23:07 +0100, Michael Heerdegen wrote:
> hw <hw@adminart.net> writes:
> 
> > Think it through: You can only undo when nothing goes wrong.  With
> > copies of buffers being autmatically saved to auto-save files, you
> > can recover from the auto-save files when something does go wrong.
> > When nothing goes wrong, these buffers and auto-save files automatically
> > go away.
> 
> What are these "something"s that make undo not work but have no effect
> on your auto-saving?  How do you check if "nothing goes wrong" and these
> auto-save files can be deleted?

Perltidy is a code formatter for perl, see [1].  It's not impossible that
perltidy messes up the code, and you might find out only later when testing
the program you're working on, which can be hours or days later, after you
have been programming and been using perltidy lots of times.  Your program
may not always in a state where you could test or even run it at the time
when you want to use perltidy.

When you use perltidy only right before you want to run and test your program,
you still want to have a backup from before you used perltidy so that, if
you need to, can try the version that wasn't altered by perltidy to see if
that makes a difference.  Of course you can save backups manually, but it's
nicer to have that automated.

Swapping buffer contents removes the undo information.  Even if you have all
the undo information, how do you jump between different states of the contents
of the buffer, like to yesterday morning?  Undo goes only step by step, and
you probably do not want to undo hours of programming step by step until you
arrive at yesterday morning, save that state, try to run that version (which
may be unfinished and won't run) and then redo all the steps.

Undo wasn't made for that.  It's great to be able to go back a couple steps,
but not hundreds or thousands.

All kinds of other things can go wrong.  Emacs may crash, your computer may
feeze or crash, your graphics card or your display may fail and leave you
blind, or whatever.  When the version of your program that wasn't altered
by perltidy is lost due to things like that, you won't be able to undo that
when it wasn't saved.

The undo you have in mind only works when nothing goes wrong, and it goes
only so far.

> With only abstract "things that go wrong" and claiming auto save files
> solve all problems and undo none, without being more specific, I can't
> say much more.

I can't possibly list all things that can go wrong.  Maybe you have never
experienced that a computer or software doesn't work as it should or that
things can go wrong.  If you want to find out, you might use wayland with
sway and libreoffice because libreoffice loves to crash all the time then.
Or use thunderbird and try to open attachments --- you'll find that some
of them are garbled because thunderbird is currently buggy, while evolution
lets you open them just fine.  Other things have gone wrong in the past,
and it's not unreasonable to expect that other things or the same ones will
go wrong in the future.

In any case, I never said that auto-save files would solve all problems.

> If you want files and you feel safe with having them, nothing wrong with
> that.
> 
> And yes, Emacs could perform better with the information collected by
> undo.  "undo-tree.el" is one approach to achieve that.  AFAIR it now
> supports also saving undo histories.
> 
> In your scenario however I would expect that when "something goes wrong"
> you just hit undo and get the former buffer contents, and that's it.

Why would you expect that perltidy will never ever damage your source code
so that you do not need to keep a copy of what you used it on?  That would
be unreasonable.

It's enough when you don't like the formatting it produces in some case and
want to undo it.  Without a copy, the undo you have in mind is at best pretty
unwieldy for giving you back what you had before.

My expectation is always that things can go wrong, and I never trust computers.
I do not expect that files saved somewhere will be there and undamaged, only
that they usually are and only because I don't see a better alternative.  A long
time ago I did experience that files got damaged when they were saved, and it
was quite a nightmare and turned out to be due to a broken disc controller.
Another time an xfs file system got damaged and I had to recover from the backup,
and I never really found out why and can only suspect that I used wrong settings
when mounting it.

Just expect things to go wrong; sooner or later they will, always.  Remember the
story about why bugs are called bugs, and that alone kinda tells you all about
things being able to go wrong.

The function I created makes it very easy for me to use perltidy and minimizes
the risk of things going wrong, and it has the side effect of giving me copies,
which can be useful.  If you have a better way, it'd be interesting to hear about
it.  A simple undo doesn't cut it, it only works when nothing goes wrong.




  reply	other threads:[~2022-03-18  8:28 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  4:55 how to force auto-save of buffers not visiting files, right now? hw
2022-03-14 12:48 ` Eli Zaretskii
2022-03-15  5:20   ` hw
2022-03-15  6:47     ` Jean Louis
2022-03-15  7:24       ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-17  4:35       ` hw
2022-03-17  5:00         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-18  7:31           ` hw
2022-03-18 14:45             ` [External] : " Drew Adams
2022-03-19  2:33               ` hw
2022-03-19  2:38                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-15 14:07     ` Eli Zaretskii
2022-03-16  0:51 ` Michael Heerdegen
2022-03-16  1:45   ` [External] : " Drew Adams
2022-03-17 19:23   ` hw
2022-03-17 22:07     ` Michael Heerdegen
2022-03-18  8:28       ` hw [this message]
2022-03-19  1:18         ` Michael Heerdegen
2022-03-19  3:14           ` hw
2022-03-19  3:47             ` Michael Heerdegen
2022-03-19  6:24               ` hw
2022-03-19  7:34                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-19  7:51                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-20  6:02                   ` hw
2022-03-20  6:26                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-19  9:58                 ` Michael Albinus
2022-03-20  6:36                   ` hw
2022-03-20  7:04                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-21 16:22                       ` [External] : " Drew Adams
2022-03-20  7:29                     ` tomas
2022-03-20  8:05                       ` volatile /tmp [was: how to force auto-save of buffers not visiting files, right now?] tomas
2022-03-20 10:36                         ` hw
2022-03-20 11:13                           ` tomas
2022-03-21  3:41                             ` hw
2022-03-21  5:53                               ` tomas
2022-03-21  8:47                               ` Michael Albinus
2022-03-20  9:57                       ` how to force auto-save of buffers not visiting files, right now? Michael Albinus
2022-03-20 10:21                         ` tomas
2022-03-20 10:19                       ` hw
2022-03-20 10:30                         ` tomas
2022-03-21  3:55                           ` hw
2022-03-21  4:13                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-21 12:22                             ` Eli Zaretskii
2022-03-23  6:12                               ` hw
2022-03-23  9:25                                 ` Michael Albinus
2022-03-20  0:21                 ` Michael Heerdegen
2022-03-20  4:56                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-20  7:39                   ` hw
2022-03-20  8:08                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-22  7:06                       ` hw
2022-03-22 19:50                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-22 21:45                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-21  7:22               ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f32ac59eb1bc186b015c0b6c5b94822e70d4135.camel@adminart.net \
    --to=hw@adminart.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).