Issue158

classification
Title [PATCH] fix corruption of ~/.emacs when trying to migrate an init file XEmacs can't fully load
Type defect Module core code 21.4, core code 21.5
Severity data loss Platform N/A
Keywords has patch Nosy List aidan
explanation
process
These controls should only be changed by committers and tracker administrators.
Status closed   Reason fixed
Superseder   Submitted 2007-10-02.23:45:25
Priority normal   Assigned To

Created on 2008-01-19.06:43:03 by jasonspiro, last changed 2011-09-29.17:46:33 by aidan.

Messages
msg756 [hidden] ([hidden]) Date: 2008-05-14.08:48:21
I committed this patch, in
http://mid.gmane.org/18227.8783.194951.601047@parhasard.net .
msg488 [hidden] ([hidden]) Date: 2008-01-23.10:17:50
Supersedes issue71.
msg230 [hidden] ([hidden]) Date: 2008-01-19.06:43:03
  Message-ID: <c241693f0710021645g642f145n5925c7a35e7b2c58@mail.gmail.com>
Hi all,

This is a patch for a preference-corruption issue.  XEmacs (I use
xemacs-21.5.27) corrupts the ~/.emacs file when you follow the steps below.  It
has happened to me both on Ubuntu Linux and on FreeBSD.  The poor guy posting at
https://stat.ethz.ch/pipermail/ess-help/2005-September/002851.html also
experienced it.

== How-To-Repeat ==

* Make a new user on your *nix PC
* Log on as that user
* Make a ~/.emacs file
* Use GNU Emacs's custom.el tool, or use vi, to customize one or more variables
* Add something to the top of the ~/.emacs file (somewhere above the
custom-set-variables statement) that xemacs can't understand, such as
the lone word:
    foobarbazquux
* As that user, start xemacs for the first time
* At the "Migrate init file to ~/.xemacs/? (yes or no)" prompt, enter "no"

Now XEmacs will clobber the custom-set-variables and custom-set-fonts clauses in
your ~/.emacs file.  It replaces them with:

(custom-set-variables
 '(load-home-init-file t t))
(custom-set-faces)

== Fix ==

See patch below.  To make the patch, I copied two lines from
http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/cus-edit.el?revision=1.321&view=markup
into the xemacs21-devel-mule port's unpacked source.  Then I modified it to
check even more aggressively: it refuses to try to save a user's customizations
any time the init file didn't fully load, even if the custom file is a different
file than the init file.  This is because it seems that the variable custom-file
was set (to /home/j/.emacs) on my PC and I am worried it may be set
elsewhere too.

I tested the patch by deleting my cus-edit.elc and pasting in the new
cus-edit.el in my xemacs lisp directory.  It works fine.

I sent the patch to the FreeBSD folk (at
http://www.freebsd.org/cgi/query-pr.cgi?pr=114031 you can see my bug report) and
they merged the patch into their own XEmacs distribution.  But they did not send
the patch to you folks.  So, I am sending it to you now.

The patch follows.

Cheers,
Jason

--- xemacs-21.5.27/lisp/cus-edit.el.orig        Tue Jun 26 04:10:18 2007
+++ xemacs-21.5.27/lisp/cus-edit.el     Tue Jun 26 04:14:52 2007
@@ -3756,6 +3756,8 @@
 ;;;###autoload
 (defun custom-save-all ()
   "Save all customizations in `custom-file'."
+  (when init-file-had-error
+    (error "Cannot save customizations; init file was not fully loaded"))
   (let ((inhibit-read-only t))
     (custom-save-variables)
     (custom-save-faces)

_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta@xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta
History
Date User Action Args
2011-09-29 17:46:33aidansetstatus: done/needs work -> closed
2011-08-26 08:14:30aidansetstatus: committed -> done/needs work
2008-05-14 08:48:21aidansetstatus: chatting -> committed
assignedto: aidan
reason: fixed
messages: + msg756
nosy: + aidan
2008-01-23 10:18:55stephenlinkissue71 superseder
2008-01-23 10:18:10stephensetkeyword: + has patch
2008-01-23 10:17:50stephensetstatus: new -> chatting
severity: data loss
messages: + msg488
module: + core code 21.4, core code 21.5
priority: normal
platform: + N/A
type: defect
2008-01-19 06:43:03jasonspirocreate