changeset 4111:ff446f61f88f

[xemacs-hg @ 2007-08-11 14:42:50 by michaels] 2007-08-09 Mike Sperber <mike@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.
author michaels
date Sat, 11 Aug 2007 14:42:51 +0000
parents c32e316ca8c1
children d63a4a53c953
files lisp/ChangeLog lisp/startup.el
diffstat 2 files changed, 45 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Aug 10 21:51:20 2007 +0000
+++ b/lisp/ChangeLog	Sat Aug 11 14:42:51 2007 +0000
@@ -1,3 +1,11 @@
+2007-08-09  Mike Sperber  <mike@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.
+
 2007-08-07  Mike Sperber  <mike@xemacs.org>
 
 	* setup-paths.el (paths-find-doc-directory):
--- a/lisp/startup.el	Fri Aug 10 21:51:20 2007 +0000
+++ b/lisp/startup.el	Sat Aug 11 14:42:51 2007 +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))
+
+	  (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.")
+	      (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 (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 (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."