Bug 114031 - [PATCH] editors/xemacs-devel - stop XEmacs from corrupting the ~/.emacs file when trying to migrate an init file it can't start to parse
Summary: [PATCH] editors/xemacs-devel - stop XEmacs from corrupting the ~/.emacs file ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Alejandro Pulver
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-26 09:50 UTC by Jason Spiro
Modified: 2007-09-30 20:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Spiro 2007-06-26 09:50:01 UTC
This is a patch for a preference-corruption issue.  XEmacs 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.

Fix: See attached patch.  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.

Here is the patch:



Dear FreeBSD people, could you please forward the patch onto the XEmacs people?  Please let me know.

Regards,
Jason--2a4JsTCCeCb18JknbOnMc8jFMUjCCb6x41jss9DmFP9w4jj2
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- 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)
How-To-Repeat: * Add something to the top of the file (somewhere above the custom-set-variables statement) that xemacs can't understand, such as the lone word:
    foobarbazquux
* 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)
Comment 1 Alejandro Pulver freebsd_committer freebsd_triage 2007-09-29 21:34:59 UTC
Responsible Changed
From-To: freebsd-ports-bugs->alepulver

I'll take it.
Comment 2 dfilter service freebsd_committer freebsd_triage 2007-09-30 19:58:36 UTC
alepulver    2007-09-30 18:58:29 UTC

  FreeBSD ports repository

  Added files:
    editors/xemacs-devel/files patch-lisp__cus-edit.el 
  Log:
  - Avoid corrupting the ~/.emacs file when migrating if it couldn't be fully
    loaded.
  
  See: https://stat.ethz.ch/pipermail/ess-help/2005-September/002851.html.
  
  PR:             ports/114031
  Submitted by:   Jason Spiro <jasonspiro4@gmail.com>
  Obtained from:  http://cvs.savannah.gnu.org/viewvc/emacs/emacs/lisp/cus-edit.el?revision=1.321&view=markup
  
  Revision  Changes    Path
  1.1       +11 -0     ports/editors/xemacs-devel/files/patch-lisp__cus-edit.el (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 3 Alejandro Pulver freebsd_committer freebsd_triage 2007-09-30 19:59:08 UTC
State Changed
From-To: open->closed

Committed. Thanks!