Mercurial > hg > xemacs-beta
comparison lisp/startup.el @ 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 | 86f900725eda |
children | 6b571dc4ba3f |
comparison
equal
deleted
inserted
replaced
4110:c32e316ca8c1 | 4111:ff446f61f88f |
---|---|
878 perform the migration at any time with M-x migrate-user-init-file.") | 878 perform the migration at any time with M-x migrate-user-init-file.") |
879 (show-temp-buffer-in-current-frame standard-output) | 879 (show-temp-buffer-in-current-frame standard-output) |
880 (yes-or-no-p-minibuf (concat "Migrate init file to " | 880 (yes-or-no-p-minibuf (concat "Migrate init file to " |
881 user-init-directory | 881 user-init-directory |
882 "? ")))) | 882 "? ")))) |
883 (progn | 883 |
884 (migrate-user-init-file) | 884 (let ((backup (migrate-user-init-file))) |
885 (maybe-create-compatibility-dot-emacs)) | 885 (with-output-to-temp-buffer (help-buffer-name nil) |
886 (customize-save-variable 'load-home-init-file t)))) | 886 (progn |
887 | 887 (princ "The initialization code has now been migrated to the ") |
888 (defun maybe-create-compatibility-dot-emacs () | 888 (princ user-init-directory) |
889 "Ask user if she wants to create a .emacs compatibility file." | 889 (princ "directory. |
890 (if (with-output-to-temp-buffer (help-buffer-name nil) | |
891 (progn | |
892 (princ "The initialization code has now been migrated to the ") | |
893 (princ user-init-directory) | |
894 (princ "directory. | |
895 | 890 |
896 For backwards compatibility with, for example, older versions of XEmacs, | 891 For backwards compatibility with, for example, older versions of XEmacs, |
897 XEmacs can create a special old-style .emacs file in your home | 892 XEmacs can create a special old-style .emacs file in your home |
898 directory which will load the relocated initialization code.") | 893 directory which will load the relocated initialization code.") |
899 (show-temp-buffer-in-current-frame standard-output) | 894 (if backup |
900 (yes-or-no-p-minibuf "Create compatibility .emacs? "))) | 895 (progn |
896 (princ "\nMoreover, a backup of your old .emacs file was created as\n") | |
897 (princ backup) | |
898 (princ ".\n"))) | |
899 (show-temp-buffer-in-current-frame standard-output) | |
900 (maybe-create-compatibility-dot-emacs)))) | |
901 (customize-save-variable 'load-home-init-file t)))) | |
902 | |
903 (defun maybe-create-compatibility-dot-emacs () | |
904 "Ask user if she wants to create a .emacs compatibility file." | |
905 (if (yes-or-no-p-minibuf "Create compatibility .emacs? ") | |
901 (create-compatibility-dot-emacs))) | 906 (create-compatibility-dot-emacs))) |
902 | 907 |
903 (defun migrate-user-init-file () | 908 (defun migrate-user-init-file () |
904 "Migrate the init file from the home directory." | 909 "Migrate the init file from the home directory. |
910 Return the name of backup file, if one was created." | |
905 (interactive) | 911 (interactive) |
906 (if (not (file-exists-p user-init-directory)) | 912 (if (not (file-exists-p user-init-directory)) |
907 (progn | 913 (progn |
908 (message "Creating %s directory..." user-init-directory) | 914 (message "Creating %s directory..." user-init-directory) |
909 (make-directory user-init-directory))) | 915 (make-directory user-init-directory))) |
910 (message "Migrating custom file...") | 916 (message "Migrating custom file...") |
911 (customize-set-value 'load-home-init-file nil) | 917 (let* ((backup (concat user-init-file ".backup")) |
912 (custom-migrate-custom-file (make-custom-file-name user-init-file | 918 (backup-p |
913 'force-new)) | 919 (and (not (file-exists-p backup)) |
914 (message "Moving init file...") | 920 (progn |
915 (let ((new-user-init-file (expand-file-name user-init-file-base | 921 (copy-file user-init-file backup) |
916 user-init-directory))) | 922 t)))) |
917 (rename-file user-init-file new-user-init-file) | 923 (customize-set-value 'load-home-init-file nil) |
918 (setq user-init-file new-user-init-file)) | 924 (custom-migrate-custom-file (make-custom-file-name user-init-file |
919 (message "Migration done.")) | 925 'force-new)) |
926 (message "Moving init file...") | |
927 (let ((new-user-init-file (expand-file-name user-init-file-base | |
928 user-init-directory))) | |
929 (rename-file user-init-file new-user-init-file) | |
930 (setq user-init-file new-user-init-file)) | |
931 (message "Migration done.") | |
932 (and backup-p backup))) | |
920 | 933 |
921 (defun create-compatibility-dot-emacs () | 934 (defun create-compatibility-dot-emacs () |
922 "Create .emacs compatibility file for migrated setup." | 935 "Create .emacs compatibility file for migrated setup." |
923 (message "Creating .emacs compatibility file.") | 936 (message "Creating .emacs compatibility file.") |
924 (with-temp-file (expand-file-name ".emacs" "~") | 937 (with-temp-file (expand-file-name ".emacs" "~") |