all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 22025@debbugs.gnu.org
Subject: bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop.
Date: Fri, 27 Nov 2015 12:27:54 +0000	[thread overview]
Message-ID: <vz1vb8nhbjp.fsf@gmail.com> (raw)
In-Reply-To: <20151127083837.GB1782@acm.fritz.box>

On Fri 27 Nov 2015, Eli Zaretskii wrote:

>> I think we are enormously cavalier with the .desktop file - no backup of
>> any type (such as .emacs.desktop~) is kept, and should there be trouble
>> reading .desktop, it is difficult to exit Emacs without having this
>> .desktop overwritten.
>
> Maybe having backups for it would be a good and safe measure, indeed.
> At least as an option.  Does anyone see any reasons why not?

I add this to desktop-save-hook to avoid problems with lost or corrupted
desktop files:

  (defun ajm:backup-desktop-file ()
    "Save a backup of the desktop file."
    (let* ((version-control     t)
           (delete-old-versions t)
           (kept-new-versions   8)
           (kept-old-versions   2)
           (file   (desktop-full-file-name))
           (names  (find-backup-file-name file))
           (backup (pop names)))
      (when (and (file-exists-p file) backup)
        (copy-file file backup nil t)
        (message "Saved backup of desktop file '%s' as '%s'." file backup)
        (mapc #'delete-file names))))

Doubtless this is hacky and could be improved, but it seems to work for me.

>> > Of course, if making that happen is relatively easy, it would be good
>> > to have such a compatibility mode.  Patches welcome.
>> 
>> I will work on this.

I haven't checked recently, but this worked for me the last time I used
emacs-25 desktop files with emacs-24:

  (when (< emacs-major-version 25)
    (defun ajm:fixup-desktop-create-buffer (args)
      "Fixup for emacs-24 to use emacs-25 desktop files."
      (let ((nargs (length args)))
        (if (> nargs 10)
            (butlast args (- nargs 10))
          args)))
    (advice-add 'desktop-create-buffer :filter-args
                'ajm:fixup-desktop-create-buffer))

With that advice installed, both emacs versions can read either version
of desktop file. If emacs-24 reads a version 208 desktop file and then
saves a version 206 desktop file, then there may be minor information
loss.

    AndyM






  parent reply	other threads:[~2015-11-27 12:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  8:38 bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop Alan Mackenzie
2015-11-27  9:05 ` Eli Zaretskii
2015-11-27  9:47   ` Alan Mackenzie
2015-11-27 10:23     ` Eli Zaretskii
2015-11-27 11:39       ` Alan Mackenzie
2015-11-27 12:27       ` Andy Moreton [this message]
2015-12-01 12:19   ` Alan Mackenzie
2015-12-01 15:43     ` Eli Zaretskii
2015-12-01 17:01       ` Alan Mackenzie
2015-12-01 17:46         ` Drew Adams
2015-12-02 12:35           ` Alan Mackenzie
2015-12-02 14:47             ` Drew Adams
2015-12-01 18:46         ` Eli Zaretskii
2015-12-02 11:27           ` Alan Mackenzie
2015-12-02 13:16             ` Andy Moreton
2015-12-02 13:50             ` Eli Zaretskii
2015-12-03  8:40               ` Alan Mackenzie
2015-12-03 10:30                 ` Eli Zaretskii
2016-01-15 16:18                   ` Alan Mackenzie
2016-01-15 18:31                     ` Eli Zaretskii
2016-01-18 13:37                       ` Alan Mackenzie
     [not found]                 ` <<83mvtrj02w.fsf@gnu.org>
2015-12-03 14:33                   ` Drew Adams
2015-12-03 14:57                     ` Alan Mackenzie
2015-12-03 15:35                       ` Drew Adams
2015-12-03 15:44                         ` Alan Mackenzie
2019-09-29 21:17 ` Stefan Kangas
     [not found] <<20151127083837.GB1782@acm.fritz.box>

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

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

  git send-email \
    --in-reply-to=vz1vb8nhbjp.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=22025@debbugs.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.