[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop.
From: |
Andy Moreton |
Subject: |
bug#22025: Emacs 25 corrupts Emacs 24 .emacs.desktop. |
Date: |
Fri, 27 Nov 2015 12:27:54 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) |
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