[Bug: 21.4.17] XEmacs eats customizations in .emacs file

Mike Sperber sperber at informatik.uni-tuebingen.de
Thu Aug 9 08:57:30 EDT 2007


Ralf Angeli <angeli at iwi.uni-sb.de> writes:

> When starting XEmacs without a .xemacs directory, but with a .emacs
> file being present, it asks if the .emacs file should be migrated to
> .xemacs/init.el.  If you answer "no" to this question, it will change
> and delete a lot of customizations in the .emacs file.

I know things take a long time out here, but here's finally a fix for
this.  Migration will now create a backup file of your .emacs if
possible.  (Leaving the old .emacs in place doesn't really
work---migration either wants to replace it or know that it's been
moved.)  Will apply Saturday if nobody objects.

2007-08-09  Mike Sperber  <mike at xemacs.org>

	* startup.el (migrate-user-init-file): Create backup of
	`user-init-file' before migrating.
	* startup.el (maybe-migrate-user-init-file): Print
	information about backup file.
	(maybe-create-compatibility-dot-emacs): Follow above change.

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
-------------- next part --------------
Index: lisp/startup.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/startup.el,v
retrieving revision 1.59
diff -u -r1.59 startup.el
--- lisp/startup.el	2 Aug 2007 06:37:53 -0000	1.59
+++ lisp/startup.el	9 Aug 2007 12:54:05 -0000
@@ -880,43 +880,56 @@
 	      (yes-or-no-p-minibuf (concat "Migrate init file to "
 					   user-init-directory
 					   "? "))))
-	  (progn
-	    (migrate-user-init-file)
-	    (maybe-create-compatibility-dot-emacs))
-	(customize-save-variable 'load-home-init-file t))))
 
-(defun maybe-create-compatibility-dot-emacs ()
-  "Ask user if she wants to create a .emacs compatibility file."
-  (if (with-output-to-temp-buffer (help-buffer-name nil)
-	(progn
-	  (princ "The initialization code has now been migrated to the ")
-	  (princ user-init-directory)
-	  (princ "directory.
+	  (let ((backup (migrate-user-init-file)))
+	    (with-output-to-temp-buffer (help-buffer-name nil)
+	      (progn
+	      (princ "The initialization code has now been migrated to the ")
+	      (princ user-init-directory)
+	      (princ "directory.
 
 For backwards compatibility with, for example, older versions of XEmacs,
 XEmacs can create a special old-style .emacs file in your home
 directory which will load the relocated initialization code.")
-	  (show-temp-buffer-in-current-frame standard-output)
-	  (yes-or-no-p-minibuf "Create compatibility .emacs? ")))
+	      (if backup
+		  (progn
+		    (princ "\nMoreover, a backup of your old .emacs file was created as\n")
+		    (princ backup)
+		    (princ ".\n")))
+	      (show-temp-buffer-in-current-frame standard-output)
+	      (maybe-create-compatibility-dot-emacs))))
+	(customize-save-variable 'load-home-init-file t))))
+
+(defun maybe-create-compatibility-dot-emacs ()
+  "Ask user if she wants to create a .emacs compatibility file."
+  (if (yes-or-no-p-minibuf "Create compatibility .emacs? ")
       (create-compatibility-dot-emacs)))
 
 (defun migrate-user-init-file ()
-  "Migrate the init file from the home directory."
+  "Migrate the init file from the home directory.
+Return the name of backup file, if one was created."
   (interactive)
   (if (not (file-exists-p user-init-directory))
       (progn
 	(message "Creating %s directory..." user-init-directory)
 	(make-directory user-init-directory)))
   (message "Migrating custom file...")
-  (customize-set-value 'load-home-init-file nil)
-  (custom-migrate-custom-file (make-custom-file-name user-init-file
-						     'force-new))
-  (message "Moving init file...")
-  (let ((new-user-init-file (expand-file-name user-init-file-base
-					      user-init-directory)))
-    (rename-file user-init-file new-user-init-file)
-    (setq user-init-file new-user-init-file))
-  (message "Migration done."))
+  (let* ((backup (concat user-init-file ".backup"))
+	 (backup-p
+	  (and (not (file-exists-p backup))
+	       (progn
+		 (copy-file user-init-file backup)
+		 t))))
+    (customize-set-value 'load-home-init-file nil)
+    (custom-migrate-custom-file (make-custom-file-name user-init-file
+						       'force-new))
+    (message "Moving init file...")
+    (let ((new-user-init-file (expand-file-name user-init-file-base
+						user-init-directory)))
+      (rename-file user-init-file new-user-init-file)
+      (setq user-init-file new-user-init-file))
+    (message "Migration done.")
+    (and backup-p backup)))
 
 (defun create-compatibility-dot-emacs ()
   "Create .emacs compatibility file for migrated setup."
-------------- next part --------------
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta at xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta


More information about the XEmacs-Patches mailing list