This describes the sequence of Emacs start-up actions, including the meaning of all the command-line options. It was written by Joe Wells. 1. These command line switches are handled, only if they appear before all other command line arguments, and only if they appear in this order: `-map'. Only under VMS. Instead of "undumping", under VMS the contents of a dump file are mapped over a section of memory (very quickly initializing lots of variables). You would not normally use this options explicitly; it is given automatically by the command file that implements the `emacs' command. `-t'. The next argument is treated as the name of a terminal to use instead of whatever is connected to the stdin, stdout, and stderr FILE pointers. `-display' (synonym: `-d'). The next argument is treated as the name of an X Window System server with which to connect. This overrides the DISPLAY environment variable. `-nw'. This means don't connect to an X Window server even if the DISPLAY environment variable was set or the `-display' switch was specified. Instead, Emacs talks to a regular dumb terminal. `-batch'. Run noninteractively. This disables any full screen interaction either with a dumb terminal or with a window system. In addition, Emacs will die after processing all command line arguments. The variable `noninteractive' is t. All of Emacs's internal data structures are initialized between steps 2 and 5. 2. The `*scratch*' buffer is created and its value of `default-directory' is set from the result of calling the `getwd' library routine. (getwd does what the `pwd' program does.) 3. If X11 is being used, Emacs determines the name under which it looks for X resource values. (I haven't checked how it does this under X10.) 1. If there is a `-rn' command line switch, it is handled now, no matter where it is on the command line. (Later it will be processed again and ignored.) The next argument is used as Emacs's resource name. 2. If the `-rn' switch was missing, Emacs looks for the WM_RES_NAME environment variable. 3. If neither of the previous two steps succeed, Emacs uses the filename with which it was invoked as its resource name. 4. If X11 is being used, these command line switches are handled now, no matter where they appear in the command line. (Under X10, they are not handled until step 13.) WARNING: this can cause strange interactions with the processing of the remaining command line arguments in step 13. In addition, under both X11 and X10, X resources (ie. the stuff in an `.Xdefaults' file) are handled now. Command line switches take precedence over resources. After each command line switch are given the equivalent resource names in this format: (X10 name / X11 instance name / X11 class name). `-r'. Reverse video. (ReverseVideo/reverseVideo/ReverseVideo) `-font' (synonym: `-fn'). Font. (BodyFont/font/Font) `-wn'. Window name (X11 only). (/title/Title) `-in'. Icon name (X11 only). (/iconName/Title) `-i'. Use built-in icon bitmap. (BitMapIcon//) `-b'. Border width (in pixels). (BorderWidth/borderWidth/BorderWidth) `-ib'. Internal border width (in pixels) (default: 1). (/internalBorder/BorderWidth) `-xrm RESOURCESTRING'. Specifies a resource name and value that overrides any other value in the X server for that name. This is useful also for setting parameters that don't have their own specific options. `-geometry' (synonym: `-w'). Window shape and size. `-geometry' is X11 only, but its synonym `-w' was available under X10. (/geometry/Geometry) Color options only: `-fg'. Foreground color. (Foreground/foreground/Foreground) `-bg'. Background color. (Background/background/Background) `-bd'. Border color. (Border/borderColor/BorderColor) `-cr'. Cursor color. (Cursor/cursorColor/Foreground) `-ms'. Mouse pointer color. (Mouse/pointerColor/Foreground) In addition, under X10, the resource `Keymap' was handled now. 5. If your Emacs isn't dumped, the default Lisp libraries are loaded now. 6. Emacs enters a recursive edit. The first time Emacs does a recursive edit, steps 7 through 15 are followed, and then Emacs enters its normal editing mode. 7. If the environment variable PWD exists, the value of `default-directory' in the `*scratch*' buffer is set to the value of PWD. This often causes problems and confusion when the value of PWD doesn't actually contain the pathname of the current directory. 8. Now the `-no-init-file' (synonym: `-q') and `-user' (synonym: `-u') command line switches are handled. They must follow the switches mentioned in step 1, and must precede any other command line arguments. Actually, both of these options can be specified; whichever is last on the command line wins. 9. The user's `.emacs' file is loaded now, if the `-no-init-file' option was not specified. If the `-user' option was specified, that user's init file is loaded instead. This file is named `.emacs' in the user's home directory. If no such file exists, this step has no effect. 10. The system wide `default.el' file is loaded now, if the variable `inhibit-default-init' is nil. The user can set this variable in the `.emacs' file to skip this step. 11. If the *scratch* buffer still exists now, the value of `initial-major-mode' is called as a function in this buffer. Normally, this puts this buffer in Lisp Interaction mode. 12. Now the terminal/window-system setup file is loaded. The name of this file is determined as follows: 1. It starts with the value of `term-file-prefix'. Normally this is `term/', but the user can set it to another value. If this variable is nil, this entire step is skipped. 2. For a window system, the prefix is followed by the name of the value of the variable `window-system', followed by `-win'. For X Windows, this means the name is `term/x-win'. 3. For a terminal, the prefix is followed by the value of the environment variable TERM, for example, `term/vt200'. If Emacs cannot find such a file to load, it retries by stripping off suffixes that begin with a hyphen. For example, if TERM is `vt200-40', first Emacs will try `term/vt200-40', and if that fails it will try `term/vt200'. 13. The rest of the command line arguments are handled at this point, in the order they appear: `-funcall' (synonyms: `-f', `-e'). The next argument is treated as the name of a function, which is called with no arguments. `-load' (synonym: `-l'). The next argument is treated as the name of a file to load. NOTE: the value of the variable `load-path' will be restored after this file is done loading. Thus, trying to change `load-path' in such a file will fail!! `-kill'. When this argument is handled, Emacs kills itself. `+DDD', where D is a digit. DDD is used as a line number to go to. When the next ordinary file argument on the command line is handled, Emacs positions point in that file on line DDD. An ordinary filename. Emacs edits this file using the function `find-file'. If the filename is not an absolute filename, it is expanded relative to the value that default-directory in the `*scratch*' buffer had at the beginning of step 11. The buffer visiting this file becomes the current buffer. `-insert' (synonym: `-i'). The next argument is treated as the name of a file. This file is inserted in the current buffer. Initially, this is the `*scratch*' buffer. Otherwise it is the buffer visiting the file most recently specified on the command line. Other command line switches may have been created by modifying the value of the variable `command-switch-alist'. If X Windows is being used, all X-specific switches mentioned above in steps 3 and 4 will be processed. Under X11, they will have already been handled, and will be ignored now. Under X10, they are being handled for the first time. 14. The values of the variables `term-setup-hook' and `window-setup-hook' are called as functions with no arguments, in the order listed. 15. If the user did not specify any of the command line options handled in step 13, and the variable `inhibit-startup-message' is still nil, the familiar Emacs startup message is displayed. .