Mercurial > hg > xemacs-beta
comparison lisp/startup.el @ 452:3d3049ae1304 r21-2-41
Import from CVS: tag r21-2-41
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 11:40:21 +0200 |
| parents | 1ccc32a20af4 |
| children | c33ae14dd6d0 |
comparison
equal
deleted
inserted
replaced
| 451:8ad70c5cd5d7 | 452:3d3049ae1304 |
|---|---|
| 75 "Functions to call after handling urgent options but before init files. | 75 "Functions to call after handling urgent options but before init files. |
| 76 The frame system uses this to open frames to display messages while | 76 The frame system uses this to open frames to display messages while |
| 77 XEmacs loads the user's initialization file.") | 77 XEmacs loads the user's initialization file.") |
| 78 | 78 |
| 79 (defvar after-init-hook nil | 79 (defvar after-init-hook nil |
| 80 "*Functions to call after loading the init file (`.emacs'). | 80 "*Functions to call after loading the init file. |
| 81 The call is not protected by a condition-case, so you can set `debug-on-error' | 81 The call is not protected by a condition-case, so you can set `debug-on-error' |
| 82 in `.emacs', and put all the actual code on `after-init-hook'.") | 82 in the init file, and put all the actual code on `after-init-hook'.") |
| 83 | 83 |
| 84 (defvar term-setup-hook nil | 84 (defvar term-setup-hook nil |
| 85 "*Functions to be called after loading terminal-specific Lisp code. | 85 "*Functions to be called after loading terminal-specific Lisp code. |
| 86 See `run-hooks'. This variable exists for users to set, so as to | 86 See `run-hooks'. This variable exists for users to set, so as to |
| 87 override the definitions made by the terminal-specific file. XEmacs | 87 override the definitions made by the terminal-specific file. XEmacs |
| 236 display code: use the current tty. | 236 display code: use the current tty. |
| 237 -batch Execute noninteractively (messages go to stderr). | 237 -batch Execute noninteractively (messages go to stderr). |
| 238 -debug-init Enter the debugger if an error in the init file occurs. | 238 -debug-init Enter the debugger if an error in the init file occurs. |
| 239 -unmapped Do not map the initial frame. | 239 -unmapped Do not map the initial frame. |
| 240 -no-site-file Do not load the site-specific init file (site-start.el). | 240 -no-site-file Do not load the site-specific init file (site-start.el). |
| 241 -no-init-file Do not load the user-specific init file (~/.emacs). | 241 -no-init-file Do not load the user-specific init file. |
| 242 -no-early-packages Do not process early packages. | 242 -no-early-packages Do not process early packages. |
| 243 -no-autoloads Do not load global symbol files (auto-autoloads) at | 243 -no-autoloads Do not load global symbol files (auto-autoloads) at |
| 244 startup. Also implies `-vanilla'. | 244 startup. Also implies `-vanilla'. |
| 245 -vanilla Equivalent to -q -no-site-file -no-early-packages. | 245 -vanilla Equivalent to -q -no-site-file -no-early-packages. |
| 246 -q Same as -no-init-file. | 246 -q Same as -no-init-file. |
| 247 -user-init-file <file> Use <file> as init file. | 247 -user-init-file <file> Use <file> as init file. |
| 248 -user-init-directory <directory> Use <directory> as init directory. | 248 -user-init-directory <directory> Use <directory> as init directory. |
| 249 -user <user> Load user's init file instead of your own. | 249 -user <user> Load user's init file instead of your own. |
| 250 Equivalent to -user-init-file ~<user>/.emacs | |
| 251 -user-init-directory ~<user>/.xemacs/ | |
| 252 -u <user> Same as -user.\n") | 250 -u <user> Same as -user.\n") |
| 253 (let ((l command-switch-alist) | 251 (let ((l command-switch-alist) |
| 254 (insert (lambda (&rest x) | 252 (insert (lambda (&rest x) |
| 255 (princ " ") | 253 (princ " ") |
| 256 (let ((len 2)) | 254 (let ((len 2)) |
| 435 (packages-load-package-auto-autoloads late-package-load-path) | 433 (packages-load-package-auto-autoloads late-package-load-path) |
| 436 (packages-load-package-auto-autoloads last-package-load-path))) | 434 (packages-load-package-auto-autoloads last-package-load-path))) |
| 437 | 435 |
| 438 (unwind-protect | 436 (unwind-protect |
| 439 (command-line) | 437 (command-line) |
| 440 ;; Do this again, in case .emacs defined more abbreviations. | 438 ;; Do this again, in case the init file defined more abbreviations. |
| 441 (setq default-directory (abbreviate-file-name default-directory)) | 439 (setq default-directory (abbreviate-file-name default-directory)) |
| 442 ;; Specify the file for recording all the auto save files of | 440 ;; Specify the file for recording all the auto save files of |
| 443 ;; this session. This is used by recover-session. | 441 ;; this session. This is used by recover-session. |
| 444 (if auto-save-list-file-prefix | 442 (if auto-save-list-file-prefix |
| 445 (setq auto-save-list-file-name | 443 (setq auto-save-list-file-name |
| 450 (system-name))))) | 448 (system-name))))) |
| 451 (run-hooks 'emacs-startup-hook) | 449 (run-hooks 'emacs-startup-hook) |
| 452 (and term-setup-hook | 450 (and term-setup-hook |
| 453 (run-hooks 'term-setup-hook)) | 451 (run-hooks 'term-setup-hook)) |
| 454 (setq term-setup-hook nil) | 452 (setq term-setup-hook nil) |
| 455 ;; ;; Modify the initial frame based on what .emacs puts into | 453 ;; ;; Modify the initial frame based on what the init file puts into |
| 456 ;; ;; ...-frame-alist. | 454 ;; ;; ...-frame-alist. |
| 457 (frame-notice-user-settings) | 455 (frame-notice-user-settings) |
| 458 ;; ;;####FSFmacs junk | 456 ;; ;;####FSFmacs junk |
| 459 ;; ;; Now we know the user's default font, so add it to the menu. | 457 ;; ;; Now we know the user's default font, so add it to the menu. |
| 460 ;; (if (fboundp 'font-menu-add-default) | 458 ;; (if (fboundp 'font-menu-add-default) |
| 703 | 701 |
| 704 After the migration, init.el/init.elc holds user-written | 702 After the migration, init.el/init.elc holds user-written |
| 705 initialization code. Moreover the customize settings will be in | 703 initialization code. Moreover the customize settings will be in |
| 706 custom.el. | 704 custom.el. |
| 707 | 705 |
| 706 You can undo the migration at any time with | |
| 707 M-x maybe-unmigrate-user-init-file. | |
| 708 | |
| 708 If you choose not to do this now, XEmacs will not ask you this | 709 If you choose not to do this now, XEmacs will not ask you this |
| 709 question in the future. However, you can still make XEmacs | 710 question in the future. However, you can still make XEmacs |
| 710 perform the migration at any time with M-x migrate-user-init-file.") | 711 perform the migration at any time with M-x migrate-user-init-file.") |
| 711 (show-temp-buffer-in-current-frame standard-output) | 712 (show-temp-buffer-in-current-frame standard-output) |
| 712 (yes-or-no-p-minibuf (concat "Migrate init file to " | 713 (yes-or-no-p-minibuf (concat "Migrate init file to " |
| 713 user-init-directory | 714 user-init-directory |
| 714 "? ")))) | 715 "? ")))) |
| 715 (migrate-user-init-file) | 716 (progn |
| 717 (migrate-user-init-file) | |
| 718 (maybe-create-compatibility-dot-emacs)) | |
| 716 (customize-save-variable 'load-home-init-file t)))) | 719 (customize-save-variable 'load-home-init-file t)))) |
| 720 | |
| 721 (defun maybe-create-compatibility-dot-emacs () | |
| 722 "Ask user if she wants to create a .emacs compatibility file." | |
| 723 (if (with-output-to-temp-buffer (help-buffer-name nil) | |
| 724 (progn | |
| 725 (princ "The initialization code has now been migrated to the ") | |
| 726 (princ user-init-directory) | |
| 727 (princ "directory. | |
| 728 | |
| 729 For backwards compatibility with, for example, older versions of XEmacs, | |
| 730 XEmacs can create a special old-style .emacs file in your home | |
| 731 directory which will load the relocated initialization code.") | |
| 732 (show-temp-buffer-in-current-frame standard-output) | |
| 733 (yes-or-no-p-minibuf "Create compatibility .emacs? "))) | |
| 734 (create-compatibility-dot-emacs))) | |
| 717 | 735 |
| 718 (defun migrate-user-init-file () | 736 (defun migrate-user-init-file () |
| 719 "Migrate the init file from the home directory." | 737 "Migrate the init file from the home directory." |
| 720 (interactive) | 738 (interactive) |
| 721 (if (not (file-exists-p user-init-directory)) | 739 (if (not (file-exists-p user-init-directory)) |
| 722 (progn | 740 (progn |
| 723 (message "Creating %s directory..." user-init-directory) | 741 (message "Creating %s directory..." user-init-directory) |
| 724 (make-directory user-init-directory))) | 742 (make-directory user-init-directory))) |
| 725 (message "Migrating custom file...") | 743 (message "Migrating custom file...") |
| 744 (customize-set-value 'load-home-init-file nil) | |
| 726 (custom-migrate-custom-file (make-custom-file-name user-init-file | 745 (custom-migrate-custom-file (make-custom-file-name user-init-file |
| 727 'force-new)) | 746 'force-new)) |
| 728 (message "Moving init file...") | 747 (message "Moving init file...") |
| 729 (rename-file user-init-file | 748 (let ((new-user-init-file (expand-file-name user-init-file-base |
| 730 (expand-file-name user-init-file-base | 749 user-init-directory))) |
| 731 user-init-directory)) | 750 (rename-file user-init-file new-user-init-file) |
| 751 (setq user-init-file new-user-init-file)) | |
| 732 (message "Migration done.")) | 752 (message "Migration done.")) |
| 753 | |
| 754 (defun create-compatibility-dot-emacs () | |
| 755 "Create .emacs compatibility file for migrated setup." | |
| 756 (message "Creating .emacs compatibility file.") | |
| 757 (with-temp-file (expand-file-name ".emacs" "~") | |
| 758 (insert ";;; XEmacs backwards compatibility file\n") | |
| 759 (insert "(setq user-init-file\n") | |
| 760 (insert " (expand-file-name \"init.el\"\n") | |
| 761 (insert " (expand-file-name \".xemacs\" \"~\")))\n") | |
| 762 (insert "(setq custom-file\n") | |
| 763 (insert " (expand-file-name \"custom.el\"\n") | |
| 764 (insert " (expand-file-name \".xemacs\" \"~\")))\n") | |
| 765 (insert "\n") | |
| 766 (insert "(load-file user-init-file)\n") | |
| 767 (insert "(load-file custom-file)")) | |
| 768 (message "Created .emacs compatibility file.")) | |
| 769 | |
| 770 (defun maybe-unmigrate-user-init-file () | |
| 771 "Possibly unmigrate the user's init and custom files." | |
| 772 (interactive) | |
| 773 (let ((dot-emacs-file-name (expand-file-name ".emacs" "~"))) | |
| 774 (if (and (not load-home-init-file) | |
| 775 (or (not (file-exists-p dot-emacs-file-name)) | |
| 776 (yes-or-no-p-minibuf (concat "Overwrite " dot-emacs-file-name | |
| 777 "? ")))) | |
| 778 (unmigrate-user-init-file dot-emacs-file-name)))) | |
| 779 | |
| 780 (defun unmigrate-user-init-file (&optional target-file-name) | |
| 781 "Unmigrate the user's init and custom files." | |
| 782 (interactive) | |
| 783 (let ((target-file-name | |
| 784 (or target-file-name (expand-file-name ".emacs" "~")))) | |
| 785 (rename-file user-init-file target-file-name 'ok-if-already-exists) | |
| 786 (setq user-init-file target-file-name) | |
| 787 (let ((old-custom-file custom-file)) | |
| 788 (custom-migrate-custom-file target-file-name) | |
| 789 (customize-save-variable 'load-home-init-file t) | |
| 790 (delete-file old-custom-file)))) | |
| 733 | 791 |
| 734 (defun load-user-init-file () | 792 (defun load-user-init-file () |
| 735 "This function actually reads the init file." | 793 "This function actually reads the init file." |
| 736 (if (not user-init-file) | 794 (if (not user-init-file) |
| 737 (setq user-init-file | 795 (setq user-init-file |
