;;; startup.el --- process Emacs shell arguments
;; Copyright (C) 1985, 1986, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
;; Free Software Foundation, Inc.
;; Maintainer: FSF
:type '(choice
(const :tag "Startup screen" nil)
(directory :tag "Directory" :value "~/")
- (file :tag "File" :value "~/file.txt")
+ (file :tag "File" :value "~/.emacs")
(const :tag "Lisp scratch buffer" t))
:version "23.1"
:group 'initialization)
(defcustom inhibit-startup-screen nil
"Non-nil inhibits the startup screen.
-This is for use in your personal init file (but NOT site-start.el), once
-you are familiar with the contents of the startup screen."
+This is for use in your personal init file (but NOT site-start.el),
+once you are familiar with the contents of the startup screen."
:type 'boolean
:group 'initialization)
(defvar startup-screen-inhibit-startup-screen nil)
(defcustom inhibit-startup-echo-area-message nil
- "*Non-nil inhibits the initial startup echo area message.
+ "Non-nil inhibits the initial startup echo area message.
Setting this variable takes effect
only if you do it with the customization buffer
or if your `.emacs' file contains a line of this form:
:group 'initialization)
(defcustom inhibit-default-init nil
- "*Non-nil inhibits loading the `default' library."
+ "Non-nil inhibits loading the `default' library."
:type 'boolean
:group 'initialization)
(defcustom inhibit-startup-buffer-menu nil
- "*Non-nil inhibits display of buffer list when more than 2 files are loaded."
+ "Non-nil inhibits display of buffer list when more than 2 files are loaded."
:type 'boolean
:group 'initialization)
("-fs" 0 x-handle-initial-switch fullscreen fullboth)
("-fw" 0 x-handle-initial-switch fullscreen fullwidth)
("-fh" 0 x-handle-initial-switch fullscreen fullheight)
+ ("-mm" 0 x-handle-initial-switch fullscreen maximized)
("-ib" 1 x-handle-numeric-switch internal-border-width)
("-g" 1 x-handle-geometry)
("-lsp" 1 x-handle-numeric-switch line-spacing)
("--fullscreen" 0 x-handle-initial-switch fullscreen fullboth)
("--fullwidth" 0 x-handle-initial-switch fullscreen fullwidth)
("--fullheight" 0 x-handle-initial-switch fullscreen fullheight)
+ ("--maximized" 0 x-handle-initial-switch fullscreen maximized)
("--internal-border" 1 x-handle-numeric-switch internal-border-width)
("--geometry" 1 x-handle-geometry)
("--foreground-color" 1 x-handle-switch foreground-color)
(defconst command-line-ns-option-alist
'(("-NSAutoLaunch" 1 ns-ignore-1-arg)
("-NXAutoLaunch" 1 ns-ignore-1-arg)
- ("-macosx" 0 ns-ignore-0-arg)
+ ("-macosx" 0 ignore)
("-NSHost" 1 ns-ignore-1-arg)
("-_NSMachLaunch" 1 ns-ignore-1-arg)
("-MachLaunch" 1 ns-ignore-1-arg)
("-cr" 1 ns-handle-switch cursor-color)
("-vb" 0 ns-handle-switch vertical-scroll-bars t)
("-hb" 0 ns-handle-switch horizontal-scroll-bars t)
- ("-bd" 1 ns-handle-switch)
- ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
+ ("-bd" 1 ns-handle-switch)
+ ;; ("--border-width" 1 ns-handle-numeric-switch border-width)
;; ("--display" 1 ns-handle-display)
("--name" 1 ns-handle-name-switch)
("--title" 1 ns-handle-switch title)
therefore, if you set `debug-on-error' non-nil in `.emacs',
an error in one of these functions will invoke the debugger.")
-(defvar before-init-time nil
- "Value of `current-time' before Emacs begins initialization.")
-
-(defvar after-init-time nil
- "Value of `current-time' after loading the init files.")
-
(defvar emacs-startup-hook nil
"Normal hook run after loading init files and handling the command line.")
Setting `init-file-user' does not prevent Emacs from loading
`site-start.el'. The only way to do that is to use `--no-site-file'.")
-(defcustom site-run-file "site-start"
+(defcustom site-run-file (purecopy "site-start")
"File containing site-wide run-time initializations.
This file is loaded at run-time before `~/.emacs'. It contains inits
that need to be in place for the entire site, but which, due to their
:type '(choice (const :tag "none" nil) string)
:group 'initialization
:initialize 'custom-initialize-default
- :set '(lambda (variable value)
+ :set (lambda (variable value)
(error "Customizing `site-run-file' does not work")))
(defcustom mail-host-address nil
- "*Name of this machine, for purposes of naming users."
+ "Name of this machine, for purposes of naming users."
:type '(choice (const nil) string)
:group 'mail)
(system-name))))
;; Empty string means "not set yet".
"")
- "*Full mailing address of this user.
+ "Full mailing address of this user.
This is initialized with environment variable `EMAIL' or, as a
-fallback, using `mail-host-address'. This is done after your
+fallback, using `mail-host-address'. This is done after your
init file is read, in case it sets `mail-host-address'."
:type 'string
:group 'mail)
string)
:group 'auto-save)
-(defvar emacs-quick-startup nil)
-
(defvar emacs-basic-display nil)
(defvar init-file-debug nil)
(defvar pure-space-overflow nil
"Non-nil if building Emacs overflowed pure space.")
-(defvar pure-space-overflow-message "\
+(defvar pure-space-overflow-message (purecopy "\
Warning Warning!!! Pure space overflow !!!Warning Warning
-\(See the node Pure Storage in the Lisp manual for details.)\n")
+\(See the node Pure Storage in the Lisp manual for details.)\n"))
-(defvar tutorial-directory nil
- "Directory containing the Emacs TUTORIAL files.")
-
-;; Get correct value in a dumped, installed Emacs.
-(eval-at-startup
- (setq tutorial-directory (file-name-as-directory
- (expand-file-name "tutorials" data-directory))))
+(defcustom tutorial-directory
+ (file-name-as-directory (expand-file-name "tutorials" data-directory))
+ "Directory containing the Emacs TUTORIAL files."
+ :group 'installation
+ :type 'directory
+ :initialize 'custom-initialize-delay)
(defun normal-top-level-add-subdirs-to-load-path ()
"Add all subdirectories of current directory to `load-path'.
;; the end, because the subdirs.el files may add elements to the end
;; of load-path and we want to take it into account.
(setq tail (cdr tail))))
- (unless (eq system-type 'vax-vms)
- ;; If the PWD environment variable isn't accurate, delete it.
- (let ((pwd (getenv "PWD")))
- (and (stringp pwd)
- ;; Use FOO/., so that if FOO is a symlink, file-attributes
- ;; describes the directory linked to, not FOO itself.
- (or (equal (file-attributes
- (concat (file-name-as-directory pwd) "."))
- (file-attributes
- (concat (file-name-as-directory default-directory)
- ".")))
- (setq process-environment
- (delete (concat "PWD=" pwd)
- process-environment))))))
+ ;; If the PWD environment variable isn't accurate, delete it.
+ (let ((pwd (getenv "PWD")))
+ (and (stringp pwd)
+ ;; Use FOO/., so that if FOO is a symlink, file-attributes
+ ;; describes the directory linked to, not FOO itself.
+ (or (equal (file-attributes
+ (concat (file-name-as-directory pwd) "."))
+ (file-attributes
+ (concat (file-name-as-directory default-directory)
+ ".")))
+ (setq process-environment
+ (delete (concat "PWD=" pwd)
+ process-environment)))))
(setq default-directory (abbreviate-file-name default-directory))
- (let ((menubar-bindings-done nil))
+ (let ((old-face-font-rescale-alist face-font-rescale-alist))
(unwind-protect
(command-line)
;; Do this again, in case .emacs defined more abbreviations.
(not (and initial-window-system
(not noninteractive)
(not (eq initial-window-system 'pc)))))
+
+ ;; FIXME: The user's init file may change
+ ;; face-font-rescale-alist. However, the default face
+ ;; already has an assigned font object, which does not take
+ ;; face-font-rescale-alist into account. For such
+ ;; situations, we ought to have a way to find all font
+ ;; objects and regenerate them; currently we do not. As a
+ ;; workaround, we specifically reset te default face's :font
+ ;; attribute here. See bug#1785.
+ (unless (eq face-font-rescale-alist
+ old-face-font-rescale-alist)
+ (set-face-attribute 'default nil :font (font-spec)))
+
;; Modify the initial frame based on what .emacs puts into
;; ...-frame-alist.
(if (fboundp 'frame-notice-user-settings)
(if (fboundp 'font-menu-add-default)
(font-menu-add-default))
(and window-setup-hook
- (run-hooks 'window-setup-hook))
- (or menubar-bindings-done
- (if (display-popup-menus-p)
- (precompute-menubar-bindings)))))
+ (run-hooks 'window-setup-hook))))
;; Subprocesses of Emacs do not have direct access to the terminal, so
;; unless told otherwise they should only assume a dumb terminal.
;; We are careful to do it late (after term-setup-hook), although the
(delete display process-environment)))))
;; Precompute the keyboard equivalents in the menu bar items.
-(defun precompute-menubar-bindings ()
- (let ((submap (lookup-key global-map [menu-bar])))
- (while submap
- (and (consp (car submap))
- (symbolp (car (car submap)))
- (stringp (car-safe (cdr (car submap))))
- (keymapp (cdr (cdr (car submap))))
- (progn
- (x-popup-menu nil (cdr (cdr (car submap))))
- (if purify-flag
- (garbage-collect))))
- (setq submap (cdr submap))))
- (setq define-key-rebound-commands t))
-
;; Command-line options supported by tty's:
(defconst tty-long-option-alist
'(("--name" . "-name")
("--color" . "-color")))
(defconst tool-bar-images-pixel-height 24
- "Height in pixels of images in the tool bar.")
+ "Height in pixels of images in the tool-bar.")
(defvar tool-bar-originally-present nil
"Non-nil if tool-bars are present before user and site init files are read.")
(declare-function x-get-resource "frame.c"
(attribute class &optional component subclass))
(declare-function tool-bar-mode "tool-bar" (&optional arg))
+(declare-function tool-bar-setup "tool-bar")
+
+(defvar server-name)
+(defvar server-process)
(defun command-line ()
(setq before-init-time (current-time)
+ after-init-time nil
command-line-default-directory default-directory)
- ;; Choose a reasonable location for temporary files.
- (custom-reevaluate-setting 'temporary-file-directory)
- (custom-reevaluate-setting 'small-temporary-file-directory)
- (custom-reevaluate-setting 'auto-save-file-name-transforms)
+ ;; Force recomputation, in case it was computed during the dump.
+ (setq abbreviated-home-dir nil)
;; See if we should import version-control from the environment variable.
(let ((vc (getenv "VERSION_CONTROL")))
;; Set the default strings to display in mode line for
;; end-of-line formats that aren't native to this platform.
(cond
- ((memq system-type '(ms-dos windows-nt emx))
+ ((memq system-type '(ms-dos windows-nt))
(setq eol-mnemonic-unix "(Unix)"
eol-mnemonic-mac "(Mac)"))
- ;; Both Mac and Unix EOLs are now "native" on Mac OS so keep the
- ;; abbreviated strings `/' and `:' set in coding.c for them.
- ((eq system-type 'macos)
- (setq eol-mnemonic-dos "(DOS)"))
(t ; this is for Unix/GNU/Linux systems
(setq eol-mnemonic-dos "(DOS)"
eol-mnemonic-mac "(Mac)")))
- ;; Make sure window system's init file was loaded in loadup.el if using a window system.
- (condition-case error
- (unless noninteractive
- (if (and initial-window-system
- (not (featurep
- (intern (concat (symbol-name initial-window-system) "-win")))))
- (error "Unsupported window system `%s'" initial-window-system))
- ;; Process window-system specific command line parameters.
- (setq command-line-args
- (funcall (or (cdr (assq initial-window-system handle-args-function-alist))
- (error "Unsupported window system `%s'" initial-window-system))
- command-line-args))
- ;; Initialize the window system. (Open connection, etc.)
- (funcall (or (cdr (assq initial-window-system window-system-initialization-alist))
- (error "Unsupported window system `%s'" initial-window-system))))
- ;; If there was an error, print the error message and exit.
- (error
- (princ
- (if (eq (car error) 'error)
- (apply 'concat (cdr error))
- (if (memq 'file-error (get (car error) 'error-conditions))
- (format "%s: %s"
- (nth 1 error)
- (mapconcat (lambda (obj) (prin1-to-string obj t))
- (cdr (cdr error)) ", "))
- (format "%s: %s"
- (get (car error) 'error-message)
- (mapconcat (lambda (obj) (prin1-to-string obj t))
- (cdr error) ", "))))
- 'external-debugging-output)
- (terpri 'external-debugging-output)
- (setq initial-window-system nil)
- (kill-emacs)))
-
(set-locale-environment nil)
;; Convert preloaded file names in load-history to absolute.
(orig-argi argi)
argval)
;; Handle --OPTION=VALUE format.
- (when (string-match "^\\(--[^=]*\\)=" argi)
+ (when (string-match "\\`\\(--[^=]*\\)=" argi)
(setq argval (substring argi (match-end 0))
argi (match-string 1 argi)))
- (unless (equal argi "--")
+ (when (string-match "\\`--." orig-argi)
(let ((completion (try-completion argi longopts)))
(if (eq completion t)
(setq argi (substring argi 1))
((member argi '("-Q" "-quick"))
(setq init-file-user nil
site-run-file nil
- emacs-quick-startup t))
+ inhibit-x-resources t))
((member argi '("-D" "-basic-display"))
(setq no-blinking-cursor t
emacs-basic-display t)
(and command-line-args
(setcdr command-line-args args)))
+ ;; Make sure window system's init file was loaded in loadup.el if
+ ;; using a window system.
+ ;; Initialize the window-system only after processing the command-line
+ ;; args so that -Q can influence this initialization.
+ (condition-case error
+ (unless noninteractive
+ (if (and initial-window-system
+ (not (featurep
+ (intern
+ (concat (symbol-name initial-window-system) "-win")))))
+ (error "Unsupported window system `%s'" initial-window-system))
+ ;; Process window-system specific command line parameters.
+ (setq command-line-args
+ (funcall
+ (or (cdr (assq initial-window-system handle-args-function-alist))
+ (error "Unsupported window system `%s'" initial-window-system))
+ command-line-args))
+ ;; Initialize the window system. (Open connection, etc.)
+ (funcall
+ (or (cdr (assq initial-window-system window-system-initialization-alist))
+ (error "Unsupported window system `%s'" initial-window-system))))
+ ;; If there was an error, print the error message and exit.
+ (error
+ (princ
+ (if (eq (car error) 'error)
+ (apply 'concat (cdr error))
+ (if (memq 'file-error (get (car error) 'error-conditions))
+ (format "%s: %s"
+ (nth 1 error)
+ (mapconcat (lambda (obj) (prin1-to-string obj t))
+ (cdr (cdr error)) ", "))
+ (format "%s: %s"
+ (get (car error) 'error-message)
+ (mapconcat (lambda (obj) (prin1-to-string obj t))
+ (cdr error) ", "))))
+ 'external-debugging-output)
+ (terpri 'external-debugging-output)
+ (setq initial-window-system nil)
+ (kill-emacs)))
+
(run-hooks 'before-init-hook)
;; Under X Window, this creates the X frame and deletes the terminal frame.
- (when (fboundp 'frame-initialize)
+ (unless (daemonp)
(frame-initialize))
;; Turn off blinking cursor if so specified in X resources. This is here
;; only because all other settings of no-blinking-cursor are here.
(unless (or noninteractive
emacs-basic-display
- (and (memq window-system '(x w32 mac ns))
+ (and (memq window-system '(x w32 ns))
(not (member (x-get-resource "cursorBlink" "CursorBlink")
'("off" "false")))))
(setq no-blinking-cursor t))
(<= (frame-parameter nil 'menu-bar-lines) 0)))
(menu-bar-mode 1))
- ;; If frame was created with a tool bar, switch tool-bar-mode on.
- (unless (or noninteractive
- emacs-basic-display
- (not (display-graphic-p))
- (<= (frame-parameter nil 'tool-bar-lines) 0))
- (tool-bar-mode 1))
-
- ;; Can't do this init in defcustom because the relevant variables
- ;; are not set.
- (custom-reevaluate-setting 'blink-cursor-mode)
- (custom-reevaluate-setting 'tooltip-mode)
- (custom-reevaluate-setting 'global-font-lock-mode)
- (custom-reevaluate-setting 'mouse-wheel-down-event)
- (custom-reevaluate-setting 'mouse-wheel-up-event)
- (custom-reevaluate-setting 'file-name-shadow-mode)
- (custom-reevaluate-setting 'send-mail-function)
- (custom-reevaluate-setting 'focus-follows-mouse)
- (custom-reevaluate-setting 'global-auto-composition-mode)
- (custom-reevaluate-setting 'transient-mark-mode)
- (custom-reevaluate-setting 'auto-encryption-mode)
+ (unless (or noninteractive (not (fboundp 'tool-bar-mode)))
+ ;; Set up the tool-bar. Do this even in tty frames, so that there
+ ;; is a tool-bar if Emacs later opens a graphical frame.
+ (if (or emacs-basic-display
+ (and (numberp (frame-parameter nil 'tool-bar-lines))
+ (<= (frame-parameter nil 'tool-bar-lines) 0)))
+ ;; On a graphical display with the toolbar disabled via X
+ ;; resources, set up the toolbar without enabling it.
+ (tool-bar-setup)
+ ;; Otherwise, enable tool-bar-mode.
+ (tool-bar-mode 1)))
+
+ ;; Re-evaluate predefined variables whose initial value depends on
+ ;; the runtime context.
+ (mapc 'custom-reevaluate-setting
+ ;; Initialize them in the same order they were loaded, in case there
+ ;; are dependencies between them.
+ (prog1 (nreverse custom-delayed-init-variables)
+ (setq custom-delayed-init-variables nil)))
(normal-erase-is-backspace-setup-frame)
;; since users can connect to color-capable terminals and also
;; switch color support on or off in mid-session by setting the
;; tty-color-mode frame parameter.
- (tty-register-default-colors)
+ ;; Exception: the `pc' ``window system'' has only 16 fixed colors,
+ ;; and they are already set at this point by a suitable function in
+ ;; window-system-initialization-alist.
+ (or (eq initial-window-system 'pc)
+ (tty-register-default-colors))
;; Record whether the tool-bar is present before the user and site
;; init files are processed. frame-notice-user-settings uses this
init-file-user)
:error)
(if (file-directory-p (expand-file-name
- ;; We don't support ~USER on MS-Windows except
- ;; for the current user, and always load .emacs
- ;; from the current user's home directory (see
- ;; below). So always check "~", even if invoked
- ;; with "-u USER", or if $USER or $LOGNAME are
- ;; set to something different.
- (if (eq system-type 'windows-nt)
+ ;; We don't support ~USER on MS-Windows
+ ;; and MS-DOS except for the current
+ ;; user, and always load .emacs from
+ ;; the current user's home directory
+ ;; (see below). So always check "~",
+ ;; even if invoked with "-u USER", or
+ ;; if $USER or $LOGNAME are set to
+ ;; something different.
+ (if (memq system-type '(windows-nt ms-dos))
"~"
(concat "~" init-file-user))))
nil
debug-on-error-should-be-set
(debug-on-error-initial
(if (eq init-file-debug t) 'startup init-file-debug))
- (orig-enable-multibyte default-enable-multibyte-characters))
+ (orig-enable-multibyte (default-value 'enable-multibyte-characters)))
(let ((debug-on-error debug-on-error-initial)
;; This function actually reads the init files.
(inner
"~/_emacs"
;; But default to .emacs if _emacs does not exist.
"~/.emacs")))
- ((eq system-type 'vax-vms)
- "sys$login:.emacs")
(t
(concat "~" init-file-user "/.emacs")))))
;; This tells `load' to store the file name found
(funcall inner)
(setq init-file-had-error nil))
(error
- (let ((message-log-max nil))
- (with-current-buffer (get-buffer-create "*Messages*")
- (insert "\n\n"
- (format "An error has occurred while loading `%s':\n\n"
- user-init-file)
- (format "%s%s%s"
- (get (car error) 'error-message)
- (if (cdr error) ": " "")
- (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
- "\n\n"
- "To ensure normal operation, you should investigate and remove the\n"
- "cause of the error in your initialization file. Start Emacs with\n"
- "the `--debug-init' option to view a complete error backtrace.\n\n"))
- (message "Error in init file: %s%s%s"
- (get (car error) 'error-message)
- (if (cdr error) ": " "")
- (mapconcat 'prin1-to-string (cdr error) ", "))
- (let ((pop-up-windows nil))
- (pop-to-buffer "*Messages*"))
- (setq init-file-had-error t)))))
-
- (if (and deactivate-mark transient-mark-mode)
+ (display-warning
+ 'initialization
+ (format "An error occurred while loading `%s':\n\n%s%s%s\n\n\
+To ensure normal operation, you should investigate and remove the
+cause of the error in your initialization file. Start Emacs with
+the `--debug-init' option to view a complete error backtrace."
+ user-init-file
+ (get (car error) 'error-message)
+ (if (cdr error) ": " "")
+ (mapconcat (lambda (s) (prin1-to-string s t)) (cdr error) ", "))
+ :warning)
+ (setq init-file-had-error t))))
+
+ (if (and deactivate-mark transient-mark-mode)
(with-current-buffer (window-buffer)
(deactivate-mark)))
debug-on-error-from-init-file debug-on-error)))
(if debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file))
- (unless (or default-enable-multibyte-characters
- (eq orig-enable-multibyte default-enable-multibyte-characters))
+ (unless (or (default-value 'enable-multibyte-characters)
+ (eq orig-enable-multibyte (default-value
+ 'enable-multibyte-characters)))
;; Init file changed to unibyte. Reset existing multibyte
;; buffers (probably *scratch*, *Messages*, *Minibuff-0*).
;; Arguably this should only be done if they're free of
(run-hooks 'after-init-hook)
;; Decode all default-directory.
- (if (and default-enable-multibyte-characters locale-coding-system)
+ (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
(save-excursion
(dolist (elt (buffer-list))
(set-buffer elt)
;; If -batch, terminate after processing the command options.
(if noninteractive (kill-emacs t))
+ ;; In daemon mode, start the server to allow clients to connect.
+ ;; This is done after loading the user's init file and after
+ ;; processing all command line arguments to allow e.g. `server-name'
+ ;; to be changed before the server starts.
+ (let ((dn (daemonp)))
+ (when dn
+ (when (stringp dn) (setq server-name dn))
+ (server-start)
+ (if server-process
+ (daemon-initialized)
+ (if (stringp dn)
+ (message
+ "Unable to start daemon: Emacs server named %S already running"
+ server-name)
+ (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process."))
+ (kill-emacs 1))))
+
;; Run emacs-session-restore (session management) if started by
;; the session manager and we have a session manager connection.
(if (and (boundp 'x-session-previous-id)
;;; Fancy splash screen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defvar fancy-startup-text
+(defconst fancy-startup-text
'((:face (variable-pitch (:foreground "red"))
"Welcome to "
:link ("GNU Emacs"
'("GNU" (lambda (button) (describe-gnu-project))
"Display info on the GNU project")))
" operating system.\n\n"
+ :face variable-pitch
:link ("Emacs Tutorial" (lambda (button) (help-with-tutorial)))
"\tLearn basic keystroke commands"
(lambda ()
""
(concat " (" title ")"))))
"\n"
- :face variable-pitch
:link ("Emacs Guided Tour"
(lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/"))
"Browse http://www.gnu.org/software/emacs/tour/")
Each element in the list should be a list of strings or pairs
`:face FACE', like `fancy-splash-insert' accepts them.")
-(defvar fancy-about-text
+(defconst fancy-about-text
'((:face (variable-pitch (:foreground "red"))
"This is "
:link ("GNU Emacs"
:group 'initialization)
(defcustom fancy-splash-image nil
- "*The image to show in the splash screens, or nil for defaults."
+ "The image to show in the splash screens, or nil for defaults."
:group 'fancy-splash-screen
:type '(choice (const :tag "Default" nil)
(file :tag "File")))
;; If keys have their default meanings,
;; use precomputed string to save lots of time.
- (if (and (eq (key-binding "\C-h") 'help-command)
- (eq (key-binding "\C-xu") 'advertised-undo)
- (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
- (eq (key-binding "\C-ht") 'help-with-tutorial)
- (eq (key-binding "\C-hi") 'info)
- (eq (key-binding "\C-hr") 'info-emacs-manual)
- (eq (key-binding "\C-h\C-n") 'view-emacs-news))
- (progn
- (insert "
-Get help\t C-h (Hold down CTRL and press h)
-")
- (insert-button "Emacs manual"
- 'action (lambda (button) (info-emacs-manual))
- 'follow-link t)
- (insert " C-h r\t")
- (insert-button "Browse manuals"
- 'action (lambda (button) (Info-directory))
- 'follow-link t)
- (insert "\t C-h i
-")
- (insert-button "Emacs tutorial"
- 'action (lambda (button) (help-with-tutorial))
- 'follow-link t)
- (insert " C-h t\tUndo changes\t C-x u
-")
- (insert-button "Buy manuals"
- 'action (lambda (button) (view-order-manuals))
- 'follow-link t)
- (insert "\t C-h C-m\tExit Emacs\t C-x C-c"))
-
- (insert (format "
-Get help\t %s
-"
- (let ((where (where-is-internal
- 'help-command nil t)))
- (if where
- (key-description where)
- "M-x help"))))
+ (let* ((c-h-accessible
+ ;; If normal-erase-is-backspace is used on a tty, there's
+ ;; no way to invoke C-h and you have to use F1 instead.
+ (or (not (char-table-p keyboard-translate-table))
+ (eq (aref keyboard-translate-table ?\C-h) ?\C-h)))
+ (minor-mode-overriding-map-alist
+ (cons (cons (not c-h-accessible)
+ ;; If C-h can't be invoked, temporarily disable its
+ ;; binding, so where-is uses alternative bindings.
+ (let ((map (make-sparse-keymap)))
+ (define-key map [?\C-h] 'undefined)
+ map))
+ minor-mode-overriding-map-alist)))
+
+ (insert (format "\nGet help\t %s\n"
+ (let ((where (where-is-internal 'help-command nil t)))
+ (cond
+ ((equal where [?\C-h])
+ "C-h (Hold down CTRL and press h)")
+ (where (key-description where))
+ (t "M-x help")))))
(insert-button "Emacs manual"
- 'action (lambda (button) (info-emacs-manual))
- 'follow-link t)
+ 'action (lambda (button) (info-emacs-manual))
+ 'follow-link t)
(insert (substitute-command-keys"\t \\[info-emacs-manual]\t"))
(insert-button "Browse manuals"
- 'action (lambda (button) (Info-directory))
- 'follow-link t)
- (insert (substitute-command-keys "\t \\[info]
-"))
+ 'action (lambda (button) (Info-directory))
+ 'follow-link t)
+ (insert (substitute-command-keys "\t \\[info]\n"))
(insert-button "Emacs tutorial"
- 'action (lambda (button) (help-with-tutorial))
- 'follow-link t)
+ 'action (lambda (button) (help-with-tutorial))
+ 'follow-link t)
(insert (substitute-command-keys
- "\t \\[help-with-tutorial]\tUndo changes\t \\[advertised-undo]
-"))
+ "\t \\[help-with-tutorial]\tUndo changes\t \\[undo]\n"))
(insert-button "Buy manuals"
- 'action (lambda (button) (view-order-manuals))
- 'follow-link t)
+ 'action (lambda (button) (view-order-manuals))
+ 'follow-link t)
(insert (substitute-command-keys
- "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
+ "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]")))
;; Say how to use the menu bar with the keyboard.
(insert "\n")
(insert "\tBuying printed manuals from the FSF\n"))
(defun startup-echo-area-message ()
- (if (eq (key-binding "\C-h\C-a") 'about-emacs)
- "For information about GNU Emacs and the GNU system, type C-h C-a."
- (substitute-command-keys
- "For information about GNU Emacs and the GNU system, type \
-\\[about-emacs].")))
-
+ (cond ((daemonp)
+ "Starting Emacs daemon.")
+ ((eq (key-binding "\C-h\C-a") 'about-emacs)
+ "For information about GNU Emacs and the GNU system, type C-h C-a.")
+ (t
+ (substitute-command-keys
+ "For information about GNU Emacs and the GNU system, type \
+\\[about-emacs]."))))
(defun display-startup-echo-area-message ()
(let ((resize-mini-windows t))
(let ((buffer (get-buffer-create " *temp*")))
(prog1
(condition-case nil
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(insert-file-contents user-init-file)
(re-search-forward
(concat
(defun command-line-1 (command-line-args-left)
(display-startup-echo-area-message)
-
- ;; Delay 2 seconds after an init file error message
- ;; was displayed, so user can read it.
- (when init-file-had-error
- (sit-for 2))
-
(when (and pure-space-overflow
(not noninteractive))
(display-warning
'initialization
- "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)"
+ "Building Emacs overflowed pure space.\
+ (See the node Pure Storage in the Lisp manual for details.)"
:warning))
(let ((file-count 0)
first-file-buffer)
(when command-line-args-left
;; We have command args; process them.
- (let ((dir command-line-default-directory)
- tem
+ ;; Note that any local variables in this function affect the
+ ;; ability of -f batch-byte-compile to detect free variables.
+ ;; So we give some of them with common names a cl1- prefix.
+ (let ((cl1-dir command-line-default-directory)
+ cl1-tem
;; This approach loses for "-batch -L DIR --eval "(require foo)",
;; if foo is intended to be found in DIR.
;;
;; This includes our standard options' long versions
;; and long versions of what's on command-switch-alist.
(longopts
- (append '(("--funcall") ("--load") ("--insert") ("--kill")
- ("--directory") ("--eval") ("--execute") ("--no-splash")
- ("--find-file") ("--visit") ("--file") ("--no-desktop"))
- (mapcar (lambda (elt)
- (list (concat "-" (car elt))))
+ (append '("--funcall" "--load" "--insert" "--kill"
+ "--directory" "--eval" "--execute" "--no-splash"
+ "--find-file" "--visit" "--file" "--no-desktop")
+ (mapcar (lambda (elt) (concat "-" (car elt)))
command-switch-alist)))
- (line 0)
- (column 0))
+ (cl1-line 0)
+ (cl1-column 0))
;; Add the long X options to longopts.
(dolist (tem command-line-x-option-alist)
(if (string-match "^--" (car tem))
- (push (list (car tem)) longopts)))
+ (push (car tem) longopts)))
;; Add the long NS options to longopts.
(dolist (tem command-line-ns-option-alist)
(setq argi "")
;; Convert long options to ordinary options
;; and separate out an attached option argument into argval.
- (when (string-match "^\\(--[^=]*\\)=" argi)
+ (when (string-match "\\`\\(--[^=]*\\)=" argi)
(setq argval (substring argi (match-end 0))
argi (match-string 1 argi)))
- (if (equal argi "--")
- (setq completion nil)
- (setq completion (try-completion argi longopts)))
- (if (eq completion t)
- (setq argi (substring argi 1))
- (if (stringp completion)
- (let ((elt (assoc completion longopts)))
- (or elt
- (error "Option `%s' is ambiguous" argi))
- (setq argi (substring (car elt) 1)))
- (setq argval nil
- argi orig-argi))))
+ (when (string-match "\\`--." orig-argi)
+ (setq completion (try-completion argi longopts))
+ (if (eq completion t)
+ (setq argi (substring argi 1))
+ (if (stringp completion)
+ (let ((elt (member completion longopts)))
+ (or elt
+ (error "Option `%s' is ambiguous" argi))
+ (setq argi (substring (car elt) 1)))
+ (setq argval nil
+ argi orig-argi)))))
;; Execute the option.
- (cond ((setq tem (assoc argi command-switch-alist))
+ (cond ((setq cl1-tem (assoc argi command-switch-alist))
(if argval
(let ((command-line-args-left
(cons argval command-line-args-left)))
- (funcall (cdr tem) argi))
- (funcall (cdr tem) argi)))
+ (funcall (cdr cl1-tem) argi))
+ (funcall (cdr cl1-tem) argi)))
((equal argi "-no-splash")
(setq inhibit-startup-screen t))
"-funcall"
"-e")) ; what the source used to say
(setq inhibit-startup-screen t)
- (setq tem (intern (or argval (pop command-line-args-left))))
- (if (commandp tem)
- (command-execute tem)
- (funcall tem)))
+ (setq cl1-tem (intern (or argval (pop command-line-args-left))))
+ (if (commandp cl1-tem)
+ (command-execute cl1-tem)
+ (funcall cl1-tem)))
((member argi '("-eval" "-execute"))
(setq inhibit-startup-screen t)
(eval (read (or argval (pop command-line-args-left)))))
((member argi '("-L" "-directory"))
- (setq tem (expand-file-name
+ (setq cl1-tem (expand-file-name
(command-line-normalize-file-name
(or argval (pop command-line-args-left)))))
- (cond (splice (setcdr splice (cons tem (cdr splice)))
+ (cond (splice (setcdr splice (cons cl1-tem (cdr splice)))
(setq splice (cdr splice)))
- (t (setq load-path (cons tem load-path)
+ (t (setq load-path (cons cl1-tem load-path)
splice load-path))))
((member argi '("-l" "-load"))
((equal argi "-insert")
(setq inhibit-startup-screen t)
- (setq tem (or argval (pop command-line-args-left)))
- (or (stringp tem)
+ (setq cl1-tem (or argval (pop command-line-args-left)))
+ (or (stringp cl1-tem)
(error "File name omitted from `-insert' option"))
- (insert-file-contents (command-line-normalize-file-name tem)))
+ (insert-file-contents (command-line-normalize-file-name cl1-tem)))
((equal argi "-kill")
(kill-emacs t))
(message "\"--no-desktop\" ignored because the Desktop package is not loaded"))
((string-match "^\\+[0-9]+\\'" argi)
- (setq line (string-to-number argi)))
+ (setq cl1-line (string-to-number argi)))
((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi)
- (setq line (string-to-number (match-string 1 argi))
- column (string-to-number (match-string 2 argi))))
+ (setq cl1-line (string-to-number (match-string 1 argi))
+ cl1-column (string-to-number (match-string 2 argi))))
- ((setq tem (assoc argi command-line-x-option-alist))
+ ((setq cl1-tem (assoc argi command-line-x-option-alist))
;; Ignore X-windows options and their args if not using X.
(setq command-line-args-left
- (nthcdr (nth 1 tem) command-line-args-left)))
+ (nthcdr (nth 1 cl1-tem) command-line-args-left)))
- ((setq tem (assoc argi command-line-ns-option-alist))
+ ((setq cl1-tem (assoc argi command-line-ns-option-alist))
;; Ignore NS-windows options and their args if not using NS.
(setq command-line-args-left
- (nthcdr (nth 1 tem) command-line-args-left)))
+ (nthcdr (nth 1 cl1-tem) command-line-args-left)))
((member argi '("-find-file" "-file" "-visit"))
(setq inhibit-startup-screen t)
;; An explicit option to specify visiting a file.
- (setq tem (or argval (pop command-line-args-left)))
- (unless (stringp tem)
+ (setq cl1-tem (or argval (pop command-line-args-left)))
+ (unless (stringp cl1-tem)
(error "File name omitted from `%s' option" argi))
(setq file-count (1+ file-count))
(let ((file (expand-file-name
- (command-line-normalize-file-name tem) dir)))
+ (command-line-normalize-file-name cl1-tem)
+ cl1-dir)))
(if (= file-count 1)
(setq first-file-buffer (find-file file))
(find-file-other-window file)))
- (or (zerop line)
- (goto-line line))
- (setq line 0)
- (unless (< column 1)
- (move-to-column (1- column)))
- (setq column 0))
+ (unless (zerop cl1-line)
+ (goto-char (point-min))
+ (forward-line (1- cl1-line)))
+ (setq cl1-line 0)
+ (unless (< cl1-column 1)
+ (move-to-column (1- cl1-column)))
+ (setq cl1-column 0))
((equal argi "--")
(setq just-files t))
(let ((file
(expand-file-name
(command-line-normalize-file-name orig-argi)
- dir)))
+ cl1-dir)))
(cond ((= file-count 1)
(setq first-file-buffer (find-file file)))
(inhibit-startup-screen
(find-file-other-window file))
(t (find-file file))))
- (or (zerop line)
- (goto-line line))
- (setq line 0)
- (unless (< column 1)
- (move-to-column (1- column)))
- (setq column 0))))))
+ (unless (zerop cl1-line)
+ (goto-char (point-min))
+ (forward-line (1- cl1-line)))
+ (setq cl1-line 0)
+ (unless (< cl1-column 1)
+ (move-to-column (1- cl1-column)))
+ (setq cl1-column 0))))))
;; In unusual circumstances, the execution of Lisp code due
;; to command-line options can cause the last visible frame
;; to be deleted. In this case, kill emacs to avoid an
(if (or inhibit-startup-screen
initial-buffer-choice
noninteractive
- emacs-quick-startup)
+ inhibit-x-resources)
;; Not displaying a startup screen. If 3 or more files
;; visited, and not all visible, show user what they all are.
;; However, /// at the beginning is supposed to mean just /, not //.
(if (string-match "^///+" file)
(setq file (replace-match "/" t t file)))
+ (and (memq system-type '(ms-dos windows-nt))
+ (string-match "^[A-Za-z]:\\(\\\\[\\\\/]\\)" file) ; C:\/ or C:\\
+ (setq file (replace-match "/" t t file 1)))
(while (string-match "//+" file 1)
(setq file (replace-match "/" t t file)))
file))