Mercurial > emacs
comparison lisp/startup.el @ 79366:9c6165181df8
Backport startup screen related changes from the trunk.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Sat, 10 Nov 2007 21:18:48 +0000 |
parents | ed7decb02144 |
children | 0d2b02ad7d19 |
comparison
equal
deleted
inserted
replaced
79365:329636cf01af | 79366:9c6165181df8 |
---|---|
36 (defvar command-line-processed nil | 36 (defvar command-line-processed nil |
37 "Non-nil once command line has been processed.") | 37 "Non-nil once command line has been processed.") |
38 | 38 |
39 (defgroup initialization nil | 39 (defgroup initialization nil |
40 "Emacs start-up procedure." | 40 "Emacs start-up procedure." |
41 :group 'internal) | 41 :group 'environment) |
42 | 42 |
43 (defcustom inhibit-splash-screen nil | 43 (defcustom inhibit-startup-screen nil |
44 "Non-nil inhibits the startup screen. | 44 "Non-nil inhibits the startup screen. |
45 It also inhibits display of the initial message in the `*scratch*' buffer. | 45 It also inhibits display of the initial message in the `*scratch*' buffer. |
46 | 46 |
47 This is for use in your personal init file (but NOT site-start.el), once | 47 This is for use in your personal init file (but NOT site-start.el), once |
48 you are familiar with the contents of the startup screen." | 48 you are familiar with the contents of the startup screen." |
49 :type 'boolean | 49 :type 'boolean |
50 :group 'initialization) | 50 :group 'initialization) |
51 | 51 |
52 (defvaralias 'inhibit-startup-message 'inhibit-splash-screen) | 52 (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen) |
53 (defvaralias 'inhibit-startup-message 'inhibit-startup-screen) | |
54 | |
55 (defvar startup-screen-inhibit-startup-screen nil) | |
53 | 56 |
54 (defcustom inhibit-startup-echo-area-message nil | 57 (defcustom inhibit-startup-echo-area-message nil |
55 "*Non-nil inhibits the initial startup echo area message. | 58 "*Non-nil inhibits the initial startup echo area message. |
56 Setting this variable takes effect | 59 Setting this variable takes effect |
57 only if you do it with the customization buffer | 60 only if you do it with the customization buffer |
292 | 295 |
293 (defvar default-frame-background-mode) | 296 (defvar default-frame-background-mode) |
294 | 297 |
295 (defvar pure-space-overflow nil | 298 (defvar pure-space-overflow nil |
296 "Non-nil if building Emacs overflowed pure space.") | 299 "Non-nil if building Emacs overflowed pure space.") |
300 | |
301 (defvar pure-space-overflow-message "\ | |
302 Warning Warning!!! Pure space overflow !!!Warning Warning | |
303 \(See the node Pure Storage in the Lisp manual for details.)\n") | |
297 | 304 |
298 (defun normal-top-level-add-subdirs-to-load-path () | 305 (defun normal-top-level-add-subdirs-to-load-path () |
299 "Add all subdirectories of current directory to `load-path'. | 306 "Add all subdirectories of current directory to `load-path'. |
300 More precisely, this uses only the subdirectories whose names | 307 More precisely, this uses only the subdirectories whose names |
301 start with letters or digits; it excludes any subdirectory named `RCS' | 308 start with letters or digits; it excludes any subdirectory named `RCS' |
821 ;; See cus-edit.el for an example. | 828 ;; See cus-edit.el for an example. |
822 (if site-run-file | 829 (if site-run-file |
823 (load site-run-file t t)) | 830 (load site-run-file t t)) |
824 | 831 |
825 ;; Sites should not disable this. Only individuals should disable | 832 ;; Sites should not disable this. Only individuals should disable |
826 ;; the startup message. | 833 ;; the startup screen. |
827 (setq inhibit-startup-message nil) | 834 (setq inhibit-startup-screen nil) |
828 | 835 |
829 ;; Warn for invalid user name. | 836 ;; Warn for invalid user name. |
830 (when init-file-user | 837 (when init-file-user |
831 (if (string-match "[~/:\n]" init-file-user) | 838 (if (string-match "[~/:\n]" init-file-user) |
832 (display-warning 'initialization | 839 (display-warning 'initialization |
916 source user-init-file) | 923 source user-init-file) |
917 (sit-for 1)) | 924 (sit-for 1)) |
918 (setq user-init-file source)))) | 925 (setq user-init-file source)))) |
919 | 926 |
920 (unless inhibit-default-init | 927 (unless inhibit-default-init |
921 (let ((inhibit-startup-message nil)) | 928 (let ((inhibit-startup-screen nil)) |
922 ;; Users are supposed to be told their rights. | 929 ;; Users are supposed to be told their rights. |
923 ;; (Plus how to get help and how to undo.) | 930 ;; (Plus how to get help and how to undo.) |
924 ;; Don't you dare turn this off for anyone | 931 ;; Don't you dare turn this off for anyone |
925 ;; except yourself. | 932 ;; except yourself. |
926 (load "default" t t))))))))) | 933 (load "default" t t))))))))) |
1115 ;; then enter the text in that file's own buffer. | 1122 ;; then enter the text in that file's own buffer. |
1116 | 1123 |
1117 ") | 1124 ") |
1118 "Initial message displayed in *scratch* buffer at startup. | 1125 "Initial message displayed in *scratch* buffer at startup. |
1119 If this is nil, no message will be displayed. | 1126 If this is nil, no message will be displayed. |
1120 If `inhibit-splash-screen' is non-nil, then no message is displayed, | 1127 If `inhibit-startup-screen' is non-nil, then no message is displayed, |
1121 regardless of the value of this variable." | 1128 regardless of the value of this variable." |
1122 :type '(choice (text :tag "Message") | 1129 :type '(choice (text :tag "Message") |
1123 (const :tag "none" nil)) | 1130 (const :tag "none" nil)) |
1124 :group 'initialization) | 1131 :group 'initialization) |
1125 | 1132 |
1126 | 1133 |
1127 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1128 ;;; Fancy splash screen | 1135 ;;; Fancy splash screen |
1129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1130 | 1137 |
1131 (defvar fancy-splash-text | 1138 (defvar fancy-startup-text |
1132 '((:face (variable-pitch :weight bold) | 1139 '((:face (variable-pitch :foreground "red") |
1133 "Important Help menu items:\n" | 1140 "Welcome to " |
1134 :face variable-pitch | 1141 :link ("GNU Emacs" |
1135 (lambda () | 1142 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/")) |
1136 (let* ((en "TUTORIAL") | 1143 "Browse http://www.gnu.org/software/emacs/") |
1137 (tut (or (get-language-info current-language-environment | 1144 ", one component of the " |
1138 'tutorial) | 1145 :link |
1139 en)) | 1146 (lambda () |
1140 (title (with-temp-buffer | 1147 (if (eq system-type 'gnu/linux) |
1141 (insert-file-contents | 1148 '("GNU/Linux" |
1142 (expand-file-name tut data-directory) | 1149 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html")) |
1143 nil 0 256) | 1150 "Browse http://www.gnu.org/gnu/linux-and-gnu.html") |
1144 (search-forward ".") | 1151 '("GNU" (lambda (button) (describe-project)) |
1145 (buffer-substring (point-min) (1- (point)))))) | 1152 "Display info on the GNU project"))) |
1146 ;; If there is a specific tutorial for the current language | 1153 " operating system.\n" |
1147 ;; environment and it is not English, append its title. | 1154 :face variable-pitch "To quit a partially entered command, type " |
1148 (concat | 1155 :face default "Control-g" |
1149 "Emacs Tutorial\t\tLearn how to use Emacs efficiently" | 1156 :face variable-pitch ".\n\n" |
1150 (if (string= en tut) | 1157 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial))) |
1151 "" | 1158 "\tLearn basic keystroke commands" |
1152 (concat " (" title ")")) | 1159 (lambda () |
1153 "\n"))) | 1160 (let* ((en "TUTORIAL") |
1154 :face variable-pitch "\ | 1161 (tut (or (get-language-info current-language-environment |
1155 Emacs FAQ\t\tFrequently asked questions and answers | 1162 'tutorial) |
1156 View Emacs Manual\t\tView the Emacs manual using Info | 1163 en)) |
1157 Absence of Warranty\tGNU Emacs comes with " | 1164 (title (with-temp-buffer |
1158 :face (variable-pitch :slant oblique) | 1165 (insert-file-contents |
1159 "ABSOLUTELY NO WARRANTY\n" | 1166 (expand-file-name tut data-directory) |
1160 :face variable-pitch | 1167 nil 0 256) |
1161 "\ | 1168 (search-forward ".") |
1162 Copying Conditions\t\tConditions for redistributing and changing Emacs | 1169 (buffer-substring (point-min) (1- (point)))))) |
1163 Getting New Versions\tHow to obtain the latest version of Emacs | 1170 ;; If there is a specific tutorial for the current language |
1164 More Manuals / Ordering Manuals Buying printed manuals from the FSF\n") | 1171 ;; environment and it is not English, append its title. |
1165 (:face variable-pitch | 1172 (if (string= en tut) |
1166 "\nTo quit a partially entered command, type " | 1173 "" |
1167 :face default | 1174 (concat " (" title ")")))) |
1168 "Control-g" | 1175 "\n" |
1169 :face variable-pitch | 1176 :face variable-pitch |
1170 ". | 1177 :link ("Emacs Guided Tour" |
1171 | 1178 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/")) |
1172 Emacs Guided Tour\t\tSee http://www.gnu.org/software/emacs/tour/ | 1179 "Browse http://www.gnu.org/software/emacs/tour/") |
1173 | 1180 "\tOverview of Emacs features\n" |
1174 " | 1181 :link ("View Emacs Manual" (lambda (button) (info-emacs-manual))) |
1175 :face (variable-pitch :weight bold) | 1182 "\tView the Emacs manual using Info\n" |
1176 "Useful File menu items:\n" | 1183 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty))) |
1177 :face variable-pitch | 1184 "\tGNU Emacs comes with " |
1178 "Exit Emacs\t\t(Or type " | 1185 :face (variable-pitch :slant oblique) |
1179 :face default | 1186 "ABSOLUTELY NO WARRANTY\n" |
1180 "Control-x" | 1187 :face variable-pitch |
1181 :face variable-pitch | 1188 :link ("Copying Conditions" (lambda (button) (describe-copying))) |
1182 " followed by " | 1189 "\tConditions for redistributing and changing Emacs\n" |
1183 :face default | 1190 :link ("Ordering Manuals" (lambda (button) (view-order-manuals))) |
1184 "Control-c" | 1191 "\tPurchasing printed copies of manuals\n" |
1185 :face variable-pitch | 1192 "\n")) |
1186 ") | |
1187 Recover Crashed Session\tRecover files you were editing before a crash\n" | |
1188 )) | |
1189 "A list of texts to show in the middle part of splash screens. | 1193 "A list of texts to show in the middle part of splash screens. |
1194 Each element in the list should be a list of strings or pairs | |
1195 `:face FACE', like `fancy-splash-insert' accepts them.") | |
1196 | |
1197 (defvar fancy-about-text | |
1198 '((:face (variable-pitch :foreground "red") | |
1199 "This is " | |
1200 :link ("GNU Emacs" | |
1201 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/")) | |
1202 "Browse http://www.gnu.org/software/emacs/") | |
1203 ", one component of the " | |
1204 :link | |
1205 (lambda () | |
1206 (if (eq system-type 'gnu/linux) | |
1207 '("GNU/Linux" | |
1208 (lambda (button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html")) | |
1209 "Browse http://www.gnu.org/gnu/linux-and-gnu.html") | |
1210 '("GNU" (lambda (button) (describe-project)) | |
1211 "Display info on the GNU project."))) | |
1212 " operating system.\n" | |
1213 :face (lambda () | |
1214 (list 'variable-pitch :foreground | |
1215 (if (eq (frame-parameter nil 'background-mode) 'dark) | |
1216 "cyan" "darkblue"))) | |
1217 "\n" | |
1218 (lambda () (emacs-version)) | |
1219 "\n" | |
1220 :face (variable-pitch :height 0.5) | |
1221 (lambda () emacs-copyright) | |
1222 "\n\n" | |
1223 :face variable-pitch | |
1224 :link ("GNU and Freedom" (lambda (button) (describe-project))) | |
1225 "\tWhy we developed GNU Emacs, and the GNU operating system\n" | |
1226 :link ("Absence of Warranty" (lambda (button) (describe-no-warranty))) | |
1227 "\tGNU Emacs comes with " | |
1228 :face (variable-pitch :slant oblique) | |
1229 "ABSOLUTELY NO WARRANTY\n" | |
1230 :face variable-pitch | |
1231 :link ("Copying Conditions" (lambda (button) (describe-copying))) | |
1232 "\tConditions for redistributing and changing Emacs\n" | |
1233 :link ("Getting New Versions" (lambda (button) (describe-distribution))) | |
1234 "\tHow to obtain the latest version of Emacs\n" | |
1235 :link ("Ordering Manuals" (lambda (button) (view-order-manuals))) | |
1236 "\tBuying printed manuals from the FSF\n" | |
1237 "\n" | |
1238 :link ("Emacs Tutorial" (lambda (button) (help-with-tutorial))) | |
1239 "\tLearn basic Emacs keystroke commands" | |
1240 (lambda () | |
1241 (let* ((en "TUTORIAL") | |
1242 (tut (or (get-language-info current-language-environment | |
1243 'tutorial) | |
1244 en)) | |
1245 (title (with-temp-buffer | |
1246 (insert-file-contents | |
1247 (expand-file-name tut data-directory) | |
1248 nil 0 256) | |
1249 (search-forward ".") | |
1250 (buffer-substring (point-min) (1- (point)))))) | |
1251 ;; If there is a specific tutorial for the current language | |
1252 ;; environment and it is not English, append its title. | |
1253 (if (string= en tut) | |
1254 "" | |
1255 (concat " (" title ")")))) | |
1256 "\n" | |
1257 :link ("Emacs Guided Tour" | |
1258 (lambda (button) (browse-url "http://www.gnu.org/software/emacs/tour/")) | |
1259 "Browse http://www.gnu.org/software/emacs/tour/") | |
1260 "\tSee an overview of the many facilities of GNU Emacs" | |
1261 )) | |
1262 "A list of texts to show in the middle part of the About screen. | |
1190 Each element in the list should be a list of strings or pairs | 1263 Each element in the list should be a list of strings or pairs |
1191 `:face FACE', like `fancy-splash-insert' accepts them.") | 1264 `:face FACE', like `fancy-splash-insert' accepts them.") |
1192 | 1265 |
1193 | 1266 |
1194 (defgroup fancy-splash-screen () | 1267 (defgroup fancy-splash-screen () |
1195 "Fancy splash screen when Emacs starts." | 1268 "Fancy splash screen when Emacs starts." |
1196 :version "21.1" | 1269 :version "21.1" |
1197 :group 'initialization) | 1270 :group 'initialization) |
1198 | |
1199 | |
1200 (defcustom fancy-splash-delay 7 | |
1201 "*Delay in seconds between splash screens." | |
1202 :group 'fancy-splash-screen | |
1203 :type 'integer) | |
1204 | |
1205 | |
1206 (defcustom fancy-splash-max-time 30 | |
1207 "*Show splash screens for at most this number of seconds. | |
1208 Values less than twice `fancy-splash-delay' are ignored." | |
1209 :group 'fancy-splash-screen | |
1210 :type 'integer) | |
1211 | |
1212 | 1271 |
1213 (defcustom fancy-splash-image nil | 1272 (defcustom fancy-splash-image nil |
1214 "*The image to show in the splash screens, or nil for defaults." | 1273 "*The image to show in the splash screens, or nil for defaults." |
1215 :group 'fancy-splash-screen | 1274 :group 'fancy-splash-screen |
1216 :type '(choice (const :tag "Default" nil) | 1275 :type '(choice (const :tag "Default" nil) |
1217 (file :tag "File"))) | 1276 (file :tag "File"))) |
1218 | 1277 |
1219 | 1278 |
1279 (defvar splash-screen-keymap | |
1280 (let ((map (make-sparse-keymap))) | |
1281 (suppress-keymap map) | |
1282 (set-keymap-parent map button-buffer-map) | |
1283 (define-key map "\C-?" 'scroll-down) | |
1284 (define-key map " " 'scroll-up) | |
1285 (define-key map "q" 'exit-splash-screen) | |
1286 map) | |
1287 "Keymap for splash screen buffer.") | |
1288 | |
1220 ;; These are temporary storage areas for the splash screen display. | 1289 ;; These are temporary storage areas for the splash screen display. |
1221 | 1290 |
1222 (defvar fancy-current-text nil) | |
1223 (defvar fancy-splash-help-echo nil) | 1291 (defvar fancy-splash-help-echo nil) |
1224 (defvar fancy-splash-stop-time nil) | |
1225 (defvar fancy-splash-outer-buffer nil) | |
1226 (defvar fancy-splash-last-input-event nil) | |
1227 | 1292 |
1228 (defun fancy-splash-insert (&rest args) | 1293 (defun fancy-splash-insert (&rest args) |
1229 "Insert text into the current buffer, with faces. | 1294 "Insert text into the current buffer, with faces. |
1230 Arguments from ARGS should be either strings, functions called | 1295 Arguments from ARGS should be either strings; functions called |
1231 with no args that return a string, or pairs `:face FACE', | 1296 with no args that return a string; pairs `:face FACE', where FACE |
1232 where FACE is a valid face specification, as it can be used with | 1297 is a face specification usable with `put-text-property'; or pairs |
1233 `put-text-property'." | 1298 `:link LINK' where LINK is a list of arguments to pass to |
1299 `insert-button', of the form (LABEL ACTION [HELP-ECHO]), which | |
1300 specifies the button's label, `action' property and help-echo string. | |
1301 FACE and LINK can also be functions, which are evaluated to obtain | |
1302 a face or button specification." | |
1234 (let ((current-face nil)) | 1303 (let ((current-face nil)) |
1235 (while args | 1304 (while args |
1236 (if (eq (car args) :face) | 1305 (cond ((eq (car args) :face) |
1237 (setq args (cdr args) current-face (car args)) | 1306 (setq args (cdr args) current-face (car args)) |
1238 (insert (propertize (let ((it (car args))) | 1307 (if (functionp current-face) |
1239 (if (functionp it) | 1308 (setq current-face (funcall current-face)))) |
1240 (funcall it) | 1309 ((eq (car args) :link) |
1241 it)) | 1310 (setq args (cdr args)) |
1242 'face current-face | 1311 (let ((spec (car args))) |
1243 'help-echo fancy-splash-help-echo))) | 1312 (if (functionp spec) |
1313 (setq spec (funcall spec))) | |
1314 (insert-button (car spec) | |
1315 'face (list 'link current-face) | |
1316 'action (cadr spec) | |
1317 'help-echo (concat "mouse-2, RET: " | |
1318 (or (nth 2 spec) | |
1319 "Follow this link")) | |
1320 'follow-link t))) | |
1321 (t (insert (propertize (let ((it (car args))) | |
1322 (if (functionp it) | |
1323 (funcall it) | |
1324 it)) | |
1325 'face current-face | |
1326 'help-echo fancy-splash-help-echo)))) | |
1244 (setq args (cdr args))))) | 1327 (setq args (cdr args))))) |
1245 | 1328 |
1246 | 1329 |
1247 (defun fancy-splash-head () | 1330 (defun fancy-splash-head () |
1248 "Insert the head part of the splash screen into the current buffer." | 1331 "Insert the head part of the splash screen into the current buffer." |
1249 (let* ((image-file (cond ((stringp fancy-splash-image) | 1332 (let* ((image-file (cond ((stringp fancy-splash-image) |
1250 fancy-splash-image) | 1333 fancy-splash-image) |
1251 ((and (display-color-p) | 1334 ((and (display-color-p) |
1252 (image-type-available-p 'xpm)) | 1335 (image-type-available-p 'xpm)) |
1253 (if (and (fboundp 'x-display-planes) | 1336 (if (and (fboundp 'x-display-planes) |
1254 (= (funcall 'x-display-planes) 8)) | 1337 (= (funcall 'x-display-planes) 8)) |
1255 "splash8.xpm" | 1338 "splash8.xpm" |
1256 "splash.xpm")) | 1339 "splash.xpm")) |
1257 (t "splash.pbm"))) | 1340 (t "splash.pbm"))) |
1258 (img (create-image image-file)) | 1341 (img (create-image image-file)) |
1259 (image-width (and img (car (image-size img)))) | 1342 (image-width (and img (car (image-size img)))) |
1260 (window-width (window-width (selected-window)))) | 1343 (window-width (window-width (selected-window)))) |
1261 (when img | 1344 (when img |
1262 (when (> window-width image-width) | 1345 (when (> window-width image-width) |
1268 ;; so that it is visible with a dark frame background. | 1351 ;; so that it is visible with a dark frame background. |
1269 (when (and (memq 'xpm img) | 1352 (when (and (memq 'xpm img) |
1270 (eq (frame-parameter nil 'background-mode) 'dark)) | 1353 (eq (frame-parameter nil 'background-mode) 'dark)) |
1271 (setq img (append img '(:color-symbols (("#000000" . "gray30")))))) | 1354 (setq img (append img '(:color-symbols (("#000000" . "gray30")))))) |
1272 | 1355 |
1273 ;; Insert the image with a help-echo and a keymap. | 1356 ;; Insert the image with a help-echo and a link. |
1274 (let ((map (make-sparse-keymap)) | 1357 (make-button (prog1 (point) (insert-image img)) (point) |
1275 (help-echo "mouse-2: browse http://www.gnu.org/")) | 1358 'face 'default |
1276 (define-key map [mouse-2] | 1359 'help-echo "mouse-2, RET: Browse http://www.gnu.org/" |
1277 (lambda () | 1360 'action (lambda (button) (browse-url "http://www.gnu.org/")) |
1278 (interactive) | 1361 'follow-link t) |
1279 (browse-url "http://www.gnu.org/") | 1362 (insert "\n\n"))))) |
1280 (throw 'exit nil))) | 1363 |
1281 (define-key map [down-mouse-2] 'ignore) | 1364 (defun fancy-startup-tail (&optional concise) |
1282 (define-key map [up-mouse-2] 'ignore) | |
1283 (insert-image img (propertize "xxx" 'help-echo help-echo | |
1284 'keymap map))) | |
1285 (insert "\n")))) | |
1286 (fancy-splash-insert | |
1287 :face '(variable-pitch :foreground "red") | |
1288 (if (eq system-type 'gnu/linux) | |
1289 "GNU Emacs is one component of the GNU/Linux operating system." | |
1290 "GNU Emacs is one component of the GNU operating system.")) | |
1291 (insert "\n") | |
1292 (fancy-splash-insert | |
1293 :face 'variable-pitch | |
1294 "You can do basic editing with the menu bar and scroll bar \ | |
1295 using the mouse.\n\n") | |
1296 (when fancy-splash-outer-buffer | |
1297 (fancy-splash-insert | |
1298 :face 'variable-pitch | |
1299 "Type " | |
1300 :face 'default | |
1301 "Control-l" | |
1302 :face 'variable-pitch | |
1303 " to begin editing" | |
1304 (if (equal (buffer-name fancy-splash-outer-buffer) | |
1305 "*scratch*") | |
1306 ".\n" | |
1307 " your file.\n")))) | |
1308 | |
1309 (defun fancy-splash-tail () | |
1310 "Insert the tail part of the splash screen into the current buffer." | 1365 "Insert the tail part of the splash screen into the current buffer." |
1311 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark) | 1366 (let ((fg (if (eq (frame-parameter nil 'background-mode) 'dark) |
1312 "cyan" "darkblue"))) | 1367 "cyan" "darkblue"))) |
1368 (unless concise | |
1369 (fancy-splash-insert | |
1370 :face 'variable-pitch | |
1371 "\nTo start... " | |
1372 :link '("Open a File" | |
1373 (lambda (button) (call-interactively 'find-file)) | |
1374 "Specify a new file's name, to edit the file") | |
1375 " " | |
1376 :link '("Open Home Directory" | |
1377 (lambda (button) (dired "~")) | |
1378 "Open your home directory, to operate on its files") | |
1379 " " | |
1380 :link '("Customize Startup" | |
1381 (lambda (button) (customize-group 'initialization)) | |
1382 "Change initialization settings including this screen") | |
1383 "\n")) | |
1313 (fancy-splash-insert :face `(variable-pitch :foreground ,fg) | 1384 (fancy-splash-insert :face `(variable-pitch :foreground ,fg) |
1314 "\nThis is " | 1385 "\nThis is " |
1315 (emacs-version) | 1386 (emacs-version) |
1316 "\n" | 1387 "\n" |
1317 :face '(variable-pitch :height 0.5) | 1388 :face '(variable-pitch :height 0.5) |
1318 "Copyright (C) 2007 Free Software Foundation, Inc.") | 1389 emacs-copyright |
1390 "\n") | |
1319 (and auto-save-list-file-prefix | 1391 (and auto-save-list-file-prefix |
1320 ;; Don't signal an error if the | 1392 ;; Don't signal an error if the |
1321 ;; directory for auto-save-list files | 1393 ;; directory for auto-save-list files |
1322 ;; does not yet exist. | 1394 ;; does not yet exist. |
1323 (file-directory-p (file-name-directory | 1395 (file-directory-p (file-name-directory |
1328 (concat "\\`" | 1400 (concat "\\`" |
1329 (regexp-quote (file-name-nondirectory | 1401 (regexp-quote (file-name-nondirectory |
1330 auto-save-list-file-prefix))) | 1402 auto-save-list-file-prefix))) |
1331 t) | 1403 t) |
1332 (fancy-splash-insert :face '(variable-pitch :foreground "red") | 1404 (fancy-splash-insert :face '(variable-pitch :foreground "red") |
1333 "\n\nIf an Emacs session crashed recently, " | 1405 "\nIf an Emacs session crashed recently, " |
1334 "type " | 1406 "type " |
1335 :face '(fixed-pitch :foreground "red") | 1407 :face '(fixed-pitch :foreground "red") |
1336 "Meta-x recover-session RET" | 1408 "Meta-x recover-session RET" |
1337 :face '(variable-pitch :foreground "red") | 1409 :face '(variable-pitch :foreground "red") |
1338 "\nto recover" | 1410 "\nto recover" |
1339 " the files you were editing.")))) | 1411 " the files you were editing.")) |
1340 | 1412 |
1341 (defun fancy-splash-screens-1 (buffer) | 1413 (when concise |
1342 "Timer function displaying a splash screen." | 1414 (fancy-splash-insert |
1343 (when (> (float-time) fancy-splash-stop-time) | 1415 :face 'variable-pitch "\n" |
1344 (throw 'stop-splashing nil)) | 1416 :link '("Dismiss this startup screen" |
1345 (unless fancy-current-text | 1417 (lambda (button) |
1346 (setq fancy-current-text fancy-splash-text)) | 1418 (when startup-screen-inhibit-startup-screen |
1347 (let ((text (car fancy-current-text))) | 1419 (customize-set-variable 'inhibit-startup-screen t) |
1348 (set-buffer buffer) | 1420 (customize-mark-to-save 'inhibit-startup-screen) |
1349 (erase-buffer) | 1421 (custom-save-all)) |
1350 (if pure-space-overflow | 1422 (let ((w (get-buffer-window "*GNU Emacs*"))) |
1351 (insert "\ | 1423 (and w (not (one-window-p)) (delete-window w))) |
1352 Warning Warning!!! Pure space overflow !!!Warning Warning | 1424 (kill-buffer "*GNU Emacs*"))) |
1353 \(See the node Pure Storage in the Lisp manual for details.)\n")) | 1425 " ") |
1354 (fancy-splash-head) | 1426 (when (or user-init-file custom-file) |
1355 (apply #'fancy-splash-insert text) | 1427 (let ((checked (create-image "\300\300\141\143\067\076\034\030" |
1356 (fancy-splash-tail) | 1428 'xbm t :width 8 :height 8 :background "grey75" |
1357 (unless (current-message) | 1429 :foreground "black" :relief -2 :ascent 'center)) |
1358 (message fancy-splash-help-echo)) | 1430 (unchecked (create-image (make-string 8 0) |
1359 (set-buffer-modified-p nil) | 1431 'xbm t :width 8 :height 8 :background "grey75" |
1360 (goto-char (point-min)) | 1432 :foreground "black" :relief -2 :ascent 'center))) |
1361 (force-mode-line-update) | 1433 (insert-button |
1362 (setq fancy-current-text (cdr fancy-current-text)))) | 1434 " " :on-glyph checked :off-glyph unchecked 'checked nil |
1363 | 1435 'display unchecked 'follow-link t |
1364 | 1436 'action (lambda (button) |
1365 (defun fancy-splash-default-action () | 1437 (if (overlay-get button 'checked) |
1366 "Stop displaying the splash screen buffer. | 1438 (progn (overlay-put button 'checked nil) |
1367 This is an internal function used to turn off the splash screen after | 1439 (overlay-put button 'display (overlay-get button :off-glyph)) |
1368 the user caused an input event by hitting a key or clicking with the | 1440 (setq startup-screen-inhibit-startup-screen nil)) |
1369 mouse." | 1441 (overlay-put button 'checked t) |
1442 (overlay-put button 'display (overlay-get button :on-glyph)) | |
1443 (setq startup-screen-inhibit-startup-screen t))))) | |
1444 (fancy-splash-insert :face '(variable-pitch :height 0.9) | |
1445 " Never show it again."))))) | |
1446 | |
1447 (defun exit-splash-screen () | |
1448 "Stop displaying the splash screen buffer." | |
1370 (interactive) | 1449 (interactive) |
1371 (if (and (memq 'down (event-modifiers last-command-event)) | 1450 (quit-window t)) |
1372 (eq (posn-window (event-start last-command-event)) | 1451 |
1373 (selected-window))) | 1452 (defun fancy-startup-screen (&optional concise) |
1374 ;; This is a mouse-down event in the spash screen window. | 1453 "Display fancy startup screen. |
1375 ;; Ignore it and consume the corresponding mouse-up event. | 1454 If CONCISE is non-nil, display a concise version of the |
1376 (read-event) | 1455 splash screen in another window." |
1377 (push last-command-event unread-command-events)) | 1456 (let ((splash-buffer (get-buffer-create "*GNU Emacs*"))) |
1378 (throw 'exit nil)) | 1457 (with-current-buffer splash-buffer |
1379 | 1458 (let ((inhibit-read-only t)) |
1380 (defun fancy-splash-special-event-action () | 1459 (erase-buffer) |
1381 "Save the last event and stop displaying the splash screen buffer. | 1460 (make-local-variable 'startup-screen-inhibit-startup-screen) |
1382 This is an internal function used to turn off the splash screen after | 1461 (if pure-space-overflow |
1383 the user caused an input event that is bound in `special-event-map'" | 1462 (insert pure-space-overflow-message)) |
1384 (interactive) | 1463 (unless concise |
1385 (setq fancy-splash-last-input-event last-input-event) | 1464 (fancy-splash-head)) |
1386 (throw 'exit nil)) | 1465 (dolist (text fancy-startup-text) |
1387 | 1466 (apply #'fancy-splash-insert text) |
1388 | 1467 (insert "\n")) |
1389 (defun fancy-splash-screens (&optional hide-on-input) | 1468 (skip-chars-backward "\n") |
1390 "Display fancy splash screens when Emacs starts." | 1469 (delete-region (point) (point-max)) |
1391 (if hide-on-input | 1470 (insert "\n") |
1392 (let ((old-hourglass display-hourglass) | 1471 (fancy-startup-tail concise)) |
1393 (fancy-splash-outer-buffer (current-buffer)) | 1472 (use-local-map splash-screen-keymap) |
1394 splash-buffer | 1473 (setq tab-width 22 |
1395 (old-minor-mode-map-alist minor-mode-map-alist) | 1474 buffer-read-only t) |
1396 (old-emulation-mode-map-alists emulation-mode-map-alists) | |
1397 (old-special-event-map special-event-map) | |
1398 (frame (fancy-splash-frame)) | |
1399 timer) | |
1400 (save-selected-window | |
1401 (select-frame frame) | |
1402 (switch-to-buffer " GNU Emacs") | |
1403 (make-local-variable 'cursor-type) | |
1404 (setq splash-buffer (current-buffer)) | |
1405 (catch 'stop-splashing | |
1406 (unwind-protect | |
1407 (let ((map (make-sparse-keymap)) | |
1408 (cursor-type nil)) | |
1409 (use-local-map map) | |
1410 (define-key map [switch-frame] 'ignore) | |
1411 (define-key map [t] 'fancy-splash-default-action) | |
1412 (define-key map [mouse-movement] 'ignore) | |
1413 (define-key map [mode-line t] 'ignore) | |
1414 ;; Temporarily bind special events to | |
1415 ;; fancy-splash-special-event-action so as to stop | |
1416 ;; displaying splash screens with such events. | |
1417 ;; Otherwise, drag-n-drop into splash screens may | |
1418 ;; leave us in recursive editing with invisible | |
1419 ;; cursors for a while. | |
1420 (setq special-event-map (make-sparse-keymap)) | |
1421 (map-keymap | |
1422 (lambda (key def) | |
1423 (define-key special-event-map (vector key) | |
1424 (if (eq def 'ignore) | |
1425 'ignore | |
1426 'fancy-splash-special-event-action))) | |
1427 old-special-event-map) | |
1428 (setq display-hourglass nil | |
1429 minor-mode-map-alist nil | |
1430 emulation-mode-map-alists nil | |
1431 buffer-undo-list t | |
1432 mode-line-format (propertize "---- %b %-" | |
1433 'face 'mode-line-buffer-id) | |
1434 fancy-splash-stop-time (+ (float-time) | |
1435 fancy-splash-max-time) | |
1436 timer (run-with-timer 0 fancy-splash-delay | |
1437 #'fancy-splash-screens-1 | |
1438 splash-buffer)) | |
1439 (message "%s" (startup-echo-area-message)) | |
1440 (recursive-edit)) | |
1441 (cancel-timer timer) | |
1442 (setq display-hourglass old-hourglass | |
1443 minor-mode-map-alist old-minor-mode-map-alist | |
1444 emulation-mode-map-alists old-emulation-mode-map-alists | |
1445 special-event-map old-special-event-map) | |
1446 (kill-buffer splash-buffer) | |
1447 (when fancy-splash-last-input-event | |
1448 (setq last-input-event fancy-splash-last-input-event | |
1449 fancy-splash-last-input-event nil) | |
1450 (command-execute (lookup-key special-event-map | |
1451 (vector last-input-event)) | |
1452 nil (vector last-input-event) t)))))) | |
1453 ;; If hide-on-input is nil, don't hide the buffer on input. | |
1454 (if (or (window-minibuffer-p) | |
1455 (window-dedicated-p (selected-window))) | |
1456 (pop-to-buffer (current-buffer)) | |
1457 (switch-to-buffer "*About GNU Emacs*")) | |
1458 (setq buffer-read-only nil) | |
1459 (erase-buffer) | |
1460 (if pure-space-overflow | |
1461 (insert "\ | |
1462 Warning Warning!!! Pure space overflow !!!Warning Warning | |
1463 \(See the node Pure Storage in the Lisp manual for details.)\n")) | |
1464 (let (fancy-splash-outer-buffer) | |
1465 (fancy-splash-head) | |
1466 (dolist (text fancy-splash-text) | |
1467 (apply #'fancy-splash-insert text) | |
1468 (insert "\n")) | |
1469 (skip-chars-backward "\n") | |
1470 (delete-region (point) (point-max)) | |
1471 (insert "\n") | |
1472 (fancy-splash-tail) | |
1473 (set-buffer-modified-p nil) | 1475 (set-buffer-modified-p nil) |
1474 (setq buffer-read-only t) | |
1475 (if (and view-read-only (not view-mode)) | 1476 (if (and view-read-only (not view-mode)) |
1476 (view-mode-enter nil 'kill-buffer)) | 1477 (view-mode-enter nil 'kill-buffer)) |
1477 (goto-char (point-min))))) | 1478 (goto-char (point-min)) |
1479 (forward-line (if concise 2 4))) | |
1480 (if concise | |
1481 (progn | |
1482 (display-buffer splash-buffer) | |
1483 ;; If the splash screen is in a split window, fit it. | |
1484 (let ((window (get-buffer-window splash-buffer t))) | |
1485 (or (null window) | |
1486 (eq window (selected-window)) | |
1487 (eq window (next-window window)) | |
1488 (fit-window-to-buffer window)))) | |
1489 (switch-to-buffer splash-buffer)))) | |
1490 | |
1491 (defun fancy-about-screen () | |
1492 "Display fancy About screen." | |
1493 (let ((frame (fancy-splash-frame))) | |
1494 (save-selected-window | |
1495 (select-frame frame) | |
1496 (switch-to-buffer "*About GNU Emacs*") | |
1497 (setq buffer-undo-list t | |
1498 mode-line-format (propertize "---- %b %-" | |
1499 'face 'mode-line-buffer-id)) | |
1500 (let ((inhibit-read-only t)) | |
1501 (erase-buffer) | |
1502 (if pure-space-overflow | |
1503 (insert pure-space-overflow-message)) | |
1504 (fancy-splash-head) | |
1505 (dolist (text fancy-about-text) | |
1506 (apply #'fancy-splash-insert text) | |
1507 (insert "\n")) | |
1508 (unless (current-message) | |
1509 (message fancy-splash-help-echo)) | |
1510 (set-buffer-modified-p nil) | |
1511 (goto-char (point-min)) | |
1512 (force-mode-line-update)) | |
1513 (use-local-map splash-screen-keymap) | |
1514 (setq tab-width 22) | |
1515 (message "%s" (startup-echo-area-message)) | |
1516 (setq buffer-read-only t) | |
1517 (goto-char (point-min)) | |
1518 (forward-line 3)))) | |
1478 | 1519 |
1479 (defun fancy-splash-frame () | 1520 (defun fancy-splash-frame () |
1480 "Return the frame to use for the fancy splash screen. | 1521 "Return the frame to use for the fancy splash screen. |
1481 Returning non-nil does not mean we should necessarily | 1522 Returning non-nil does not mean we should necessarily |
1482 use the fancy splash screen, but if we do use it, | 1523 use the fancy splash screen, but if we do use it, |
1506 ;; splash screen to be used. | 1547 ;; splash screen to be used. |
1507 (frame-height (1- (frame-height frame)))) | 1548 (frame-height (1- (frame-height frame)))) |
1508 (> frame-height (+ image-height 19))))))) | 1549 (> frame-height (+ image-height 19))))))) |
1509 | 1550 |
1510 | 1551 |
1511 (defun normal-splash-screen (&optional hide-on-input) | 1552 (defun normal-splash-screen (&optional startup) |
1512 "Display splash screen when Emacs starts." | 1553 "Display non-graphic splash screen. |
1554 If optional argument STARTUP is non-nil, display the startup screen | |
1555 after Emacs starts. If STARTUP is nil, display the About screen." | |
1513 (let ((prev-buffer (current-buffer))) | 1556 (let ((prev-buffer (current-buffer))) |
1514 (unwind-protect | 1557 (with-current-buffer (get-buffer-create "*About GNU Emacs*") |
1515 (with-current-buffer (get-buffer-create "GNU Emacs") | 1558 (setq buffer-read-only nil) |
1516 (setq buffer-read-only nil) | 1559 (erase-buffer) |
1517 (erase-buffer) | 1560 (set (make-local-variable 'tab-width) 8) |
1518 (set (make-local-variable 'tab-width) 8) | 1561 (if (not startup) |
1519 (if hide-on-input | 1562 (set (make-local-variable 'mode-line-format) |
1520 (set (make-local-variable 'mode-line-format) | 1563 (propertize "---- %b %-" 'face 'mode-line-buffer-id))) |
1521 (propertize "---- %b %-" 'face 'mode-line-buffer-id))) | 1564 |
1522 | 1565 (if pure-space-overflow |
1523 (if pure-space-overflow | 1566 (insert pure-space-overflow-message)) |
1524 (insert "\ | 1567 |
1525 Warning Warning!!! Pure space overflow !!!Warning Warning | 1568 ;; The convention for this piece of code is that |
1526 \(See the node Pure Storage in the Lisp manual for details.)\n")) | 1569 ;; each piece of output starts with one or two newlines |
1527 | 1570 ;; and does not end with any newlines. |
1528 ;; The convention for this piece of code is that | 1571 (insert (if startup "Welcome to GNU Emacs" "This is GNU Emacs")) |
1529 ;; each piece of output starts with one or two newlines | 1572 (insert |
1530 ;; and does not end with any newlines. | 1573 (if (eq system-type 'gnu/linux) |
1531 (insert "Welcome to GNU Emacs") | 1574 ", one component of the GNU/Linux operating system.\n" |
1532 (insert | 1575 ", a part of the GNU operating system.\n")) |
1533 (if (eq system-type 'gnu/linux) | 1576 |
1534 ", one component of the GNU/Linux operating system.\n" | 1577 (if startup |
1535 ", a part of the GNU operating system.\n")) | 1578 (if (display-mouse-p) |
1536 | 1579 ;; The user can use the mouse to activate menus |
1537 (if hide-on-input | 1580 ;; so give help in terms of menu items. |
1538 (insert (substitute-command-keys | 1581 (normal-mouse-startup-screen) |
1539 (concat | 1582 |
1540 "\nType \\[recenter] to begin editing" | 1583 ;; No mouse menus, so give help using kbd commands. |
1541 (if (equal (buffer-name prev-buffer) "*scratch*") | 1584 (normal-no-mouse-startup-screen)) |
1542 ".\n" | 1585 |
1543 " your file.\n"))))) | 1586 (normal-about-screen)) |
1544 | 1587 |
1545 (if (display-mouse-p) | 1588 ;; The rest of the startup screen is the same on all |
1546 ;; The user can use the mouse to activate menus | 1589 ;; kinds of terminals. |
1547 ;; so give help in terms of menu items. | 1590 |
1548 (progn | 1591 ;; Give information on recovering, if there was a crash. |
1549 (insert "\ | 1592 (and startup |
1550 You can do basic editing with the menu bar and scroll bar using the mouse. | 1593 auto-save-list-file-prefix |
1551 To quit a partially entered command, type Control-g. | 1594 ;; Don't signal an error if the |
1552 | 1595 ;; directory for auto-save-list files |
1553 Useful File menu items: | 1596 ;; does not yet exist. |
1554 Exit Emacs (or type Control-x followed by Control-c) | 1597 (file-directory-p (file-name-directory |
1555 Recover Crashed Session Recover files you were editing before a crash | 1598 auto-save-list-file-prefix)) |
1556 | 1599 (directory-files |
1557 Important Help menu items: | 1600 (file-name-directory auto-save-list-file-prefix) |
1558 Emacs Tutorial Learn how to use Emacs efficiently | 1601 nil |
1559 Emacs FAQ Frequently asked questions and answers | 1602 (concat "\\`" |
1560 Read the Emacs Manual View the Emacs manual using Info | 1603 (regexp-quote (file-name-nondirectory |
1561 \(Non)Warranty GNU Emacs comes with ABSOLUTELY NO WARRANTY | 1604 auto-save-list-file-prefix))) |
1562 Copying Conditions Conditions for redistributing and changing Emacs | 1605 t) |
1563 Getting New Versions How to obtain the latest version of Emacs | 1606 (insert "\n\nIf an Emacs session crashed recently, " |
1564 More Manuals / Ordering Manuals How to order printed manuals from the FSF | 1607 "type Meta-x recover-session RET\nto recover" |
1608 " the files you were editing.\n")) | |
1609 | |
1610 (use-local-map splash-screen-keymap) | |
1611 | |
1612 ;; Display the input that we set up in the buffer. | |
1613 (set-buffer-modified-p nil) | |
1614 (setq buffer-read-only t) | |
1615 (if (and view-read-only (not view-mode)) | |
1616 (view-mode-enter nil 'kill-buffer)) | |
1617 (switch-to-buffer "*About GNU Emacs*") | |
1618 (if startup (rename-buffer "*GNU Emacs*" t)) | |
1619 (goto-char (point-min))))) | |
1620 | |
1621 (defun normal-mouse-startup-screen () | |
1622 ;; The user can use the mouse to activate menus | |
1623 ;; so give help in terms of menu items. | |
1624 (insert "\ | |
1625 To follow a link, click Mouse-1 on it, or move to it and type RET. | |
1626 To quit a partially entered command, type Control-g.\n") | |
1627 | |
1628 (insert "\nImportant Help menu items:\n") | |
1629 (insert-button "Emacs Tutorial" | |
1630 'action (lambda (button) (help-with-tutorial)) | |
1631 'follow-link t) | |
1632 (insert "\t\tLearn basic Emacs keystroke commands\n") | |
1633 (insert-button "Read the Emacs Manual" | |
1634 'action (lambda (button) (info-emacs-manual)) | |
1635 'follow-link t) | |
1636 (insert "\tView the Emacs manual using Info\n") | |
1637 (insert-button "\(Non)Warranty" | |
1638 'action (lambda (button) (describe-no-warranty)) | |
1639 'follow-link t) | |
1640 (insert "\t\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n") | |
1641 (insert-button "Copying Conditions" | |
1642 'action (lambda (button) (describe-copying)) | |
1643 'follow-link t) | |
1644 (insert "\tConditions for redistributing and changing Emacs\n") | |
1645 (insert-button "More Manuals / Ordering Manuals" | |
1646 'action (lambda (button) (view-order-manuals)) | |
1647 'follow-link t) | |
1648 (insert " How to order printed manuals from the FSF\n") | |
1649 | |
1650 (insert "\nUseful tasks:\n") | |
1651 (insert-button "Visit New File" | |
1652 'action (lambda (button) (call-interactively 'find-file)) | |
1653 'follow-link t) | |
1654 (insert "\t\tSpecify a new file's name, to edit the file\n") | |
1655 (insert-button "Open Home Directory" | |
1656 'action (lambda (button) (dired "~")) | |
1657 'follow-link t) | |
1658 (insert "\tOpen your home directory, to operate on its files\n") | |
1659 (insert-button "Customize Startup" | |
1660 'action (lambda (button) (customize-group 'initialization)) | |
1661 'follow-link t) | |
1662 (insert "\tChange initialization settings including this screen\n") | |
1663 | |
1664 (insert "\n" (emacs-version) | |
1665 "\n" emacs-copyright)) | |
1666 | |
1667 ;; No mouse menus, so give help using kbd commands. | |
1668 (defun normal-no-mouse-startup-screen () | |
1669 | |
1670 ;; If keys have their default meanings, | |
1671 ;; use precomputed string to save lots of time. | |
1672 (if (and (eq (key-binding "\C-h") 'help-command) | |
1673 (eq (key-binding "\C-xu") 'advertised-undo) | |
1674 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal) | |
1675 (eq (key-binding "\C-ht") 'help-with-tutorial) | |
1676 (eq (key-binding "\C-hi") 'info) | |
1677 (eq (key-binding "\C-hr") 'info-emacs-manual) | |
1678 (eq (key-binding "\C-h\C-n") 'view-emacs-news)) | |
1679 (progn | |
1680 (insert " | |
1681 Get help\t C-h (Hold down CTRL and press h) | |
1565 ") | 1682 ") |
1566 (insert "\n\n" (emacs-version) | 1683 (insert-button "Emacs manual" |
1567 " | 1684 'action (lambda (button) (info-emacs-manual)) |
1568 Copyright (C) 2007 Free Software Foundation, Inc.")) | 1685 'follow-link t) |
1569 | 1686 (insert " C-h r\t") |
1570 ;; No mouse menus, so give help using kbd commands. | 1687 (insert-button "Browse manuals" |
1571 | 1688 'action (lambda (button) (Info-directory)) |
1572 ;; If keys have their default meanings, | 1689 'follow-link t) |
1573 ;; use precomputed string to save lots of time. | 1690 (insert "\t C-h i |
1574 (if (and (eq (key-binding "\C-h") 'help-command) | 1691 ") |
1575 (eq (key-binding "\C-xu") 'advertised-undo) | 1692 (insert-button "Emacs tutorial" |
1576 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-emacs) | 1693 'action (lambda (button) (help-with-tutorial)) |
1577 (eq (key-binding "\C-ht") 'help-with-tutorial) | 1694 'follow-link t) |
1578 (eq (key-binding "\C-hi") 'info) | 1695 (insert " C-h t\tUndo changes\t C-x u |
1579 (eq (key-binding "\C-hr") 'info-emacs-manual) | 1696 ") |
1580 (eq (key-binding "\C-h\C-n") 'view-emacs-news)) | 1697 (insert-button "Buy manuals" |
1581 (insert " | 1698 'action (lambda (button) (view-order-manuals)) |
1582 Get help C-h (Hold down CTRL and press h) | 1699 'follow-link t) |
1583 Emacs manual C-h r | 1700 (insert "\t C-h C-m\tExit Emacs\t C-x C-c")) |
1584 Emacs tutorial C-h t Undo changes C-x u | 1701 |
1585 Buy manuals C-h C-m Exit Emacs C-x C-c | 1702 (insert (format " |
1586 Browse manuals C-h i") | 1703 Get help\t %s |
1587 | 1704 " |
1588 (insert (substitute-command-keys | 1705 (let ((where (where-is-internal |
1589 (format "\n | 1706 'help-command nil t))) |
1590 Get help %s | 1707 (if where |
1591 Emacs manual \\[info-emacs-manual] | 1708 (key-description where) |
1592 Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo] | 1709 "M-x help")))) |
1593 Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-emacs] | 1710 (insert-button "Emacs manual" |
1594 Browse manuals \\[info]" | 1711 'action (lambda (button) (info-emacs-manual)) |
1595 (let ((where (where-is-internal | 1712 'follow-link t) |
1596 'help-command nil t))) | 1713 (insert (substitute-command-keys"\t \\[info-emacs-manual]\t")) |
1597 (if where | 1714 (insert-button "Browse manuals" |
1598 (key-description where) | 1715 'action (lambda (button) (Info-directory)) |
1599 "M-x help")))))) | 1716 'follow-link t) |
1600 | 1717 (insert (substitute-command-keys "\t \\[info] |
1601 ;; Say how to use the menu bar with the keyboard. | 1718 ")) |
1602 (if (and (eq (key-binding "\M-`") 'tmm-menubar) | 1719 (insert-button "Emacs tutorial" |
1603 (eq (key-binding [f10]) 'tmm-menubar)) | 1720 'action (lambda (button) (help-with-tutorial)) |
1604 (insert " | 1721 'follow-link t) |
1605 Activate menubar F10 or ESC ` or M-`") | 1722 (insert (substitute-command-keys |
1606 (insert (substitute-command-keys " | 1723 "\t \\[help-with-tutorial]\tUndo changes\t \\[advertised-undo] |
1607 Activate menubar \\[tmm-menubar]"))) | 1724 ")) |
1608 | 1725 (insert-button "Buy manuals" |
1609 ;; Many users seem to have problems with these. | 1726 'action (lambda (button) (view-order-manuals)) |
1610 (insert " | 1727 'follow-link t) |
1728 (insert (substitute-command-keys | |
1729 "\t \\[view-order-manuals]\tExit Emacs\t \\[save-buffers-kill-terminal]"))) | |
1730 | |
1731 ;; Say how to use the menu bar with the keyboard. | |
1732 (insert "\n") | |
1733 (insert-button "Activate menubar" | |
1734 'action (lambda (button) (tmm-menubar)) | |
1735 'follow-link t) | |
1736 (if (and (eq (key-binding "\M-`") 'tmm-menubar) | |
1737 (eq (key-binding [f10]) 'tmm-menubar)) | |
1738 (insert " F10 or ESC ` or M-`") | |
1739 (insert (substitute-command-keys " \\[tmm-menubar]"))) | |
1740 | |
1741 ;; Many users seem to have problems with these. | |
1742 (insert " | |
1611 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key. | 1743 \(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key. |
1612 If you have no Meta key, you may instead type ESC followed by the character.)") | 1744 If you have no Meta key, you may instead type ESC followed by the character.)") |
1613 | 1745 |
1614 (insert "\n\n" (emacs-version) | 1746 ;; Insert links to useful tasks |
1615 " | 1747 (insert "\nUseful tasks:\n") |
1616 Copyright (C) 2007 Free Software Foundation, Inc.") | 1748 |
1617 | 1749 (insert-button "Visit New File" |
1618 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying) | 1750 'action (lambda (button) (call-interactively 'find-file)) |
1619 (eq (key-binding "\C-h\C-d") 'describe-distribution) | 1751 'follow-link t) |
1620 (eq (key-binding "\C-h\C-w") 'describe-no-warranty)) | 1752 (insert "\t\t\t") |
1621 (insert | 1753 (insert-button "Open Home Directory" |
1622 "\n | 1754 'action (lambda (button) (dired "~")) |
1623 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details. | 1755 'follow-link t) |
1756 (insert "\n") | |
1757 | |
1758 (insert-button "Customize Startup" | |
1759 'action (lambda (button) (customize-group 'initialization)) | |
1760 'follow-link t) | |
1761 (insert "\t\t") | |
1762 (insert-button "Open *scratch* buffer" | |
1763 'action (lambda (button) (switch-to-buffer | |
1764 (get-buffer-create "*scratch*"))) | |
1765 'follow-link t) | |
1766 (insert "\n") | |
1767 (insert "\n" (emacs-version) "\n" emacs-copyright "\n") | |
1768 | |
1769 (if (and (eq (key-binding "\C-h\C-c") 'describe-copying) | |
1770 (eq (key-binding "\C-h\C-d") 'describe-distribution) | |
1771 (eq (key-binding "\C-h\C-w") 'describe-no-warranty)) | |
1772 (progn | |
1773 (insert | |
1774 " | |
1775 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for ") | |
1776 (insert-button "full details" | |
1777 'action (lambda (button) (describe-no-warranty)) | |
1778 'follow-link t) | |
1779 (insert ". | |
1624 Emacs is Free Software--Free as in Freedom--so you can redistribute copies | 1780 Emacs is Free Software--Free as in Freedom--so you can redistribute copies |
1625 of Emacs and modify it; type C-h C-c to see the conditions. | 1781 of Emacs and modify it; type C-h C-c to see ") |
1626 Type C-h C-d for information on getting the latest version.") | 1782 (insert-button "the conditions" |
1627 (insert (substitute-command-keys | 1783 'action (lambda (button) (describe-copying)) |
1628 "\n | 1784 'follow-link t) |
1629 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for full details. | 1785 (insert ". |
1786 Type C-h C-d for information on ") | |
1787 (insert-button "getting the latest version" | |
1788 'action (lambda (button) (describe-distribution)) | |
1789 'follow-link t) | |
1790 (insert ".")) | |
1791 (insert (substitute-command-keys | |
1792 " | |
1793 GNU Emacs comes with ABSOLUTELY NO WARRANTY; type \\[describe-no-warranty] for ")) | |
1794 (insert-button "full details" | |
1795 'action (lambda (button) (describe-no-warranty)) | |
1796 'follow-link t) | |
1797 (insert (substitute-command-keys ". | |
1630 Emacs is Free Software--Free as in Freedom--so you can redistribute copies | 1798 Emacs is Free Software--Free as in Freedom--so you can redistribute copies |
1631 of Emacs and modify it; type \\[describe-copying] to see the conditions. | 1799 of Emacs and modify it; type \\[describe-copying] to see ")) |
1632 Type \\[describe-distribution] for information on getting the latest version.")))) | 1800 (insert-button "the conditions" |
1633 | 1801 'action (lambda (button) (describe-copying)) |
1634 ;; The rest of the startup screen is the same on all | 1802 'follow-link t) |
1635 ;; kinds of terminals. | 1803 (insert (substitute-command-keys". |
1636 | 1804 Type \\[describe-distribution] for information on ")) |
1637 ;; Give information on recovering, if there was a crash. | 1805 (insert-button "getting the latest version" |
1638 (and auto-save-list-file-prefix | 1806 'action (lambda (button) (describe-distribution)) |
1639 ;; Don't signal an error if the | 1807 'follow-link t) |
1640 ;; directory for auto-save-list files | 1808 (insert "."))) |
1641 ;; does not yet exist. | 1809 |
1642 (file-directory-p (file-name-directory | 1810 (defun normal-about-screen () |
1643 auto-save-list-file-prefix)) | 1811 (insert "\n" (emacs-version) "\n" emacs-copyright "\n\n") |
1644 (directory-files | 1812 |
1645 (file-name-directory auto-save-list-file-prefix) | 1813 (insert "To follow a link, click Mouse-1 on it, or move to it and type RET.\n\n") |
1646 nil | 1814 |
1647 (concat "\\`" | 1815 (insert-button "GNU and Freedom" |
1648 (regexp-quote (file-name-nondirectory | 1816 'action (lambda (button) (describe-project)) |
1649 auto-save-list-file-prefix))) | 1817 'follow-link t) |
1650 t) | 1818 (insert "\t\tWhy we developed GNU Emacs and the GNU system\n") |
1651 (insert "\n\nIf an Emacs session crashed recently, " | 1819 |
1652 "type Meta-x recover-session RET\nto recover" | 1820 (insert-button "Absence of Warranty" |
1653 " the files you were editing.")) | 1821 'action (lambda (button) (describe-no-warranty)) |
1654 | 1822 'follow-link t) |
1655 ;; Display the input that we set up in the buffer. | 1823 (insert "\tGNU Emacs comes with ABSOLUTELY NO WARRANTY\n") |
1656 (set-buffer-modified-p nil) | 1824 |
1657 (setq buffer-read-only t) | 1825 (insert-button "Copying Conditions" |
1658 (if (and view-read-only (not view-mode)) | 1826 'action (lambda (button) (describe-copying)) |
1659 (view-mode-enter nil 'kill-buffer)) | 1827 'follow-link t) |
1660 (goto-char (point-min)) | 1828 (insert "\tConditions for redistributing and changing Emacs\n") |
1661 (if hide-on-input | 1829 |
1662 (if (or (window-minibuffer-p) | 1830 (insert-button "Getting New Versions" |
1663 (window-dedicated-p (selected-window))) | 1831 'action (lambda (button) (describe-distribution)) |
1664 ;; If hide-on-input is nil, creating a new frame will | 1832 'follow-link t) |
1665 ;; generate enough events that the subsequent `sit-for' | 1833 (insert "\tHow to get the latest version of GNU Emacs\n") |
1666 ;; will immediately return anyway. | 1834 |
1667 nil ;; (pop-to-buffer (current-buffer)) | 1835 (insert-button "More Manuals / Ordering Manuals" |
1668 (save-window-excursion | 1836 'action (lambda (button) (view-order-manuals)) |
1669 (switch-to-buffer (current-buffer)) | 1837 'follow-link t) |
1670 (sit-for 120))) | 1838 (insert "\tBuying printed manuals from the FSF\n")) |
1671 (condition-case nil | |
1672 (switch-to-buffer (current-buffer)) | |
1673 ;; In case the window is dedicated or something. | |
1674 (error (pop-to-buffer (current-buffer)))))) | |
1675 ;; Unwind ... ensure splash buffer is killed | |
1676 (if hide-on-input | |
1677 (kill-buffer "GNU Emacs") | |
1678 (switch-to-buffer "GNU Emacs") | |
1679 (rename-buffer "*About GNU Emacs*" t))))) | |
1680 | |
1681 | 1839 |
1682 (defun startup-echo-area-message () | 1840 (defun startup-echo-area-message () |
1683 (if (eq (key-binding "\C-h\C-p") 'describe-project) | 1841 (if (eq (key-binding "\C-h\C-p") 'describe-project) |
1684 "For information about the GNU system and GNU/Linux, type C-h C-p." | 1842 "For information about GNU Emacs and the GNU system, type C-h C-a." |
1685 (substitute-command-keys | 1843 (substitute-command-keys |
1686 "For information about the GNU system and GNU/Linux, type \ | 1844 "For information about GNU Emacs and the GNU system, type \ |
1687 \\[describe-project]."))) | 1845 \\[about-emacs]."))) |
1688 | 1846 |
1689 | 1847 |
1690 (defun display-startup-echo-area-message () | 1848 (defun display-startup-echo-area-message () |
1691 (let ((resize-mini-windows t)) | 1849 (let ((resize-mini-windows t)) |
1692 (message "%s" (startup-echo-area-message)))) | 1850 (or noninteractive ;(input-pending-p) init-file-had-error |
1693 | 1851 ;; t if the init file says to inhibit the echo area startup message. |
1694 | 1852 (and inhibit-startup-echo-area-message |
1695 (defun display-splash-screen (&optional hide-on-input) | 1853 user-init-file |
1696 "Display splash screen according to display. | 1854 (or (and (get 'inhibit-startup-echo-area-message 'saved-value) |
1697 Fancy splash screens are used on graphic displays, | 1855 (equal inhibit-startup-echo-area-message |
1698 normal otherwise. | 1856 (if (equal init-file-user "") |
1699 With a prefix argument, any user input hides the splash screen." | 1857 (user-login-name) |
1700 (interactive "P") | 1858 init-file-user))) |
1859 ;; Wasn't set with custom; see if .emacs has a setq. | |
1860 (let ((buffer (get-buffer-create " *temp*"))) | |
1861 (prog1 | |
1862 (condition-case nil | |
1863 (save-excursion | |
1864 (set-buffer buffer) | |
1865 (insert-file-contents user-init-file) | |
1866 (re-search-forward | |
1867 (concat | |
1868 "([ \t\n]*setq[ \t\n]+" | |
1869 "inhibit-startup-echo-area-message[ \t\n]+" | |
1870 (regexp-quote | |
1871 (prin1-to-string | |
1872 (if (equal init-file-user "") | |
1873 (user-login-name) | |
1874 init-file-user))) | |
1875 "[ \t\n]*)") | |
1876 nil t)) | |
1877 (error nil)) | |
1878 (kill-buffer buffer))))) | |
1879 (message "%s" (startup-echo-area-message))))) | |
1880 | |
1881 (defun display-startup-screen (&optional concise) | |
1882 "Display startup screen according to display. | |
1883 A fancy display is used on graphic displays, normal otherwise. | |
1884 | |
1885 If CONCISE is non-nil, display a concise version of the startup | |
1886 screen." | |
1887 ;; Prevent recursive calls from server-process-filter. | |
1888 (if (not (get-buffer "*GNU Emacs*")) | |
1889 (if (use-fancy-splash-screens-p) | |
1890 (fancy-startup-screen concise) | |
1891 (normal-splash-screen t)))) | |
1892 | |
1893 (defun display-about-screen () | |
1894 "Display the *About GNU Emacs* buffer. | |
1895 A fancy display is used on graphic displays, normal otherwise." | |
1896 (interactive) | |
1701 (if (use-fancy-splash-screens-p) | 1897 (if (use-fancy-splash-screens-p) |
1702 (fancy-splash-screens hide-on-input) | 1898 (fancy-about-screen) |
1703 (normal-splash-screen hide-on-input))) | 1899 (normal-splash-screen nil))) |
1704 | 1900 |
1901 (defalias 'about-emacs 'display-about-screen) | |
1902 (defalias 'display-splash-screen 'display-startup-screen) | |
1705 | 1903 |
1706 (defun command-line-1 (command-line-args-left) | 1904 (defun command-line-1 (command-line-args-left) |
1707 (or noninteractive (input-pending-p) init-file-had-error | 1905 (display-startup-echo-area-message) |
1708 ;; t if the init file says to inhibit the echo area startup message. | |
1709 (and inhibit-startup-echo-area-message | |
1710 user-init-file | |
1711 (or (and (get 'inhibit-startup-echo-area-message 'saved-value) | |
1712 (equal inhibit-startup-echo-area-message | |
1713 (if (equal init-file-user "") | |
1714 (user-login-name) | |
1715 init-file-user))) | |
1716 ;; Wasn't set with custom; see if .emacs has a setq. | |
1717 (let ((buffer (get-buffer-create " *temp*"))) | |
1718 (prog1 | |
1719 (condition-case nil | |
1720 (save-excursion | |
1721 (set-buffer buffer) | |
1722 (insert-file-contents user-init-file) | |
1723 (re-search-forward | |
1724 (concat | |
1725 "([ \t\n]*setq[ \t\n]+" | |
1726 "inhibit-startup-echo-area-message[ \t\n]+" | |
1727 (regexp-quote | |
1728 (prin1-to-string | |
1729 (if (equal init-file-user "") | |
1730 (user-login-name) | |
1731 init-file-user))) | |
1732 "[ \t\n]*)") | |
1733 nil t)) | |
1734 (error nil)) | |
1735 (kill-buffer buffer))))) | |
1736 ;; display-splash-screen at the end of command-line-1 calls | |
1737 ;; use-fancy-splash-screens-p. This can cause image.el to be | |
1738 ;; loaded, putting "Loading image... done" in the echo area. | |
1739 ;; This hides startup-echo-area-message. So | |
1740 ;; use-fancy-splash-screens-p is called here simply to get the | |
1741 ;; loading of image.el (if needed) out of the way before | |
1742 ;; display-startup-echo-area-message runs. | |
1743 (progn | |
1744 (use-fancy-splash-screens-p) | |
1745 (display-startup-echo-area-message))) | |
1746 | 1906 |
1747 ;; Delay 2 seconds after an init file error message | 1907 ;; Delay 2 seconds after an init file error message |
1748 ;; was displayed, so user can read it. | 1908 ;; was displayed, so user can read it. |
1749 (when init-file-had-error | 1909 (when init-file-had-error |
1750 (sit-for 2)) | 1910 (sit-for 2)) |
1754 (display-warning | 1914 (display-warning |
1755 'initialization | 1915 'initialization |
1756 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)" | 1916 "Building Emacs overflowed pure space. (See the node Pure Storage in the Lisp manual for details.)" |
1757 :warning)) | 1917 :warning)) |
1758 | 1918 |
1759 (when command-line-args-left | 1919 (let ((file-count 0) |
1760 ;; We have command args; process them. | 1920 first-file-buffer) |
1761 (let ((dir command-line-default-directory) | 1921 (when command-line-args-left |
1762 (file-count 0) | 1922 ;; We have command args; process them. |
1763 first-file-buffer | 1923 (let ((dir command-line-default-directory) |
1764 tem | 1924 tem |
1765 ;; This approach loses for "-batch -L DIR --eval "(require foo)", | 1925 ;; This approach loses for "-batch -L DIR --eval "(require foo)", |
1766 ;; if foo is intended to be found in DIR. | 1926 ;; if foo is intended to be found in DIR. |
1767 ;; | 1927 ;; |
1768 ;; ;; The directories listed in --directory/-L options will *appear* | 1928 ;; ;; The directories listed in --directory/-L options will *appear* |
1769 ;; ;; at the front of `load-path' in the order they appear on the | 1929 ;; ;; at the front of `load-path' in the order they appear on the |
1770 ;; ;; command-line. We cannot do this by *placing* them at the front | 1930 ;; ;; command-line. We cannot do this by *placing* them at the front |
1771 ;; ;; in the order they appear, so we need this variable to hold them, | 1931 ;; ;; in the order they appear, so we need this variable to hold them, |
1772 ;; ;; temporarily. | 1932 ;; ;; temporarily. |
1773 ;; extra-load-path | 1933 ;; extra-load-path |
1774 ;; | 1934 ;; |
1775 ;; To DTRT we keep track of the splice point and modify `load-path' | 1935 ;; To DTRT we keep track of the splice point and modify `load-path' |
1776 ;; straight away upon any --directory/-L option. | 1936 ;; straight away upon any --directory/-L option. |
1777 splice | 1937 splice |
1778 just-files ;; t if this follows the magic -- option. | 1938 just-files ;; t if this follows the magic -- option. |
1779 ;; This includes our standard options' long versions | 1939 ;; This includes our standard options' long versions |
1780 ;; and long versions of what's on command-switch-alist. | 1940 ;; and long versions of what's on command-switch-alist. |
1781 (longopts | 1941 (longopts |
1782 (append '(("--funcall") ("--load") ("--insert") ("--kill") | 1942 (append '(("--funcall") ("--load") ("--insert") ("--kill") |
1783 ("--directory") ("--eval") ("--execute") ("--no-splash") | 1943 ("--directory") ("--eval") ("--execute") ("--no-splash") |
1784 ("--find-file") ("--visit") ("--file") ("--no-desktop")) | 1944 ("--find-file") ("--visit") ("--file") ("--no-desktop")) |
1785 (mapcar (lambda (elt) | 1945 (mapcar (lambda (elt) |
1786 (list (concat "-" (car elt)))) | 1946 (list (concat "-" (car elt)))) |
1787 command-switch-alist))) | 1947 command-switch-alist))) |
1788 (line 0) | 1948 (line 0) |
1789 (column 0)) | 1949 (column 0)) |
1790 | 1950 |
1791 ;; Add the long X options to longopts. | 1951 ;; Add the long X options to longopts. |
1792 (dolist (tem command-line-x-option-alist) | 1952 (dolist (tem command-line-x-option-alist) |
1793 (if (string-match "^--" (car tem)) | 1953 (if (string-match "^--" (car tem)) |
1794 (push (list (car tem)) longopts))) | 1954 (push (list (car tem)) longopts))) |
1795 | 1955 |
1796 ;; Loop, processing options. | 1956 ;; Loop, processing options. |
1797 (while command-line-args-left | 1957 (while command-line-args-left |
1798 (let* ((argi (car command-line-args-left)) | 1958 (let* ((argi (car command-line-args-left)) |
1799 (orig-argi argi) | 1959 (orig-argi argi) |
1800 argval completion) | 1960 argval completion) |
1801 (setq command-line-args-left (cdr command-line-args-left)) | 1961 (setq command-line-args-left (cdr command-line-args-left)) |
1802 | 1962 |
1803 ;; Do preliminary decoding of the option. | 1963 ;; Do preliminary decoding of the option. |
1804 (if just-files | 1964 (if just-files |
1805 ;; After --, don't look for options; treat all args as files. | 1965 ;; After --, don't look for options; treat all args as files. |
1806 (setq argi "") | 1966 (setq argi "") |
1807 ;; Convert long options to ordinary options | 1967 ;; Convert long options to ordinary options |
1808 ;; and separate out an attached option argument into argval. | 1968 ;; and separate out an attached option argument into argval. |
1809 (when (string-match "^\\(--[^=]*\\)=" argi) | 1969 (when (string-match "^\\(--[^=]*\\)=" argi) |
1810 (setq argval (substring argi (match-end 0)) | 1970 (setq argval (substring argi (match-end 0)) |
1811 argi (match-string 1 argi))) | 1971 argi (match-string 1 argi))) |
1812 (if (equal argi "--") | 1972 (if (equal argi "--") |
1813 (setq completion nil) | 1973 (setq completion nil) |
1814 (setq completion (try-completion argi longopts))) | 1974 (setq completion (try-completion argi longopts))) |
1815 (if (eq completion t) | 1975 (if (eq completion t) |
1816 (setq argi (substring argi 1)) | 1976 (setq argi (substring argi 1)) |
1817 (if (stringp completion) | 1977 (if (stringp completion) |
1818 (let ((elt (assoc completion longopts))) | 1978 (let ((elt (assoc completion longopts))) |
1819 (or elt | 1979 (or elt |
1820 (error "Option `%s' is ambiguous" argi)) | 1980 (error "Option `%s' is ambiguous" argi)) |
1821 (setq argi (substring (car elt) 1))) | 1981 (setq argi (substring (car elt) 1))) |
1822 (setq argval nil | 1982 (setq argval nil |
1823 argi orig-argi)))) | 1983 argi orig-argi)))) |
1824 | 1984 |
1825 ;; Execute the option. | 1985 ;; Execute the option. |
1826 (cond ((setq tem (assoc argi command-switch-alist)) | 1986 (cond ((setq tem (assoc argi command-switch-alist)) |
1827 (if argval | 1987 (if argval |
1828 (let ((command-line-args-left | 1988 (let ((command-line-args-left |
1829 (cons argval command-line-args-left))) | 1989 (cons argval command-line-args-left))) |
1830 (funcall (cdr tem) argi)) | 1990 (funcall (cdr tem) argi)) |
1831 (funcall (cdr tem) argi))) | 1991 (funcall (cdr tem) argi))) |
1832 | 1992 |
1833 ((equal argi "-no-splash") | 1993 ((equal argi "-no-splash") |
1834 (setq inhibit-startup-message t)) | 1994 (setq inhibit-startup-screen t)) |
1835 | 1995 |
1836 ((member argi '("-f" ; what the manual claims | 1996 ((member argi '("-f" ; what the manual claims |
1837 "-funcall" | 1997 "-funcall" |
1838 "-e")) ; what the source used to say | 1998 "-e")) ; what the source used to say |
1839 (setq tem (intern (or argval (pop command-line-args-left)))) | 1999 (setq inhibit-startup-screen t) |
1840 (if (commandp tem) | 2000 (setq tem (intern (or argval (pop command-line-args-left)))) |
1841 (command-execute tem) | 2001 (if (commandp tem) |
1842 (funcall tem))) | 2002 (command-execute tem) |
1843 | 2003 (funcall tem))) |
1844 ((member argi '("-eval" "-execute")) | 2004 |
1845 (eval (read (or argval (pop command-line-args-left))))) | 2005 ((member argi '("-eval" "-execute")) |
1846 | 2006 (setq inhibit-startup-screen t) |
1847 ((member argi '("-L" "-directory")) | 2007 (eval (read (or argval (pop command-line-args-left))))) |
1848 (setq tem (expand-file-name | 2008 |
1849 (command-line-normalize-file-name | 2009 ((member argi '("-L" "-directory")) |
1850 (or argval (pop command-line-args-left))))) | 2010 (setq tem (expand-file-name |
1851 (cond (splice (setcdr splice (cons tem (cdr splice))) | 2011 (command-line-normalize-file-name |
1852 (setq splice (cdr splice))) | 2012 (or argval (pop command-line-args-left))))) |
1853 (t (setq load-path (cons tem load-path) | 2013 (cond (splice (setcdr splice (cons tem (cdr splice))) |
1854 splice load-path)))) | 2014 (setq splice (cdr splice))) |
1855 | 2015 (t (setq load-path (cons tem load-path) |
1856 ((member argi '("-l" "-load")) | 2016 splice load-path)))) |
1857 (let* ((file (command-line-normalize-file-name | 2017 |
1858 (or argval (pop command-line-args-left)))) | 2018 ((member argi '("-l" "-load")) |
1859 ;; Take file from default dir if it exists there; | 2019 (let* ((file (command-line-normalize-file-name |
1860 ;; otherwise let `load' search for it. | 2020 (or argval (pop command-line-args-left)))) |
1861 (file-ex (expand-file-name file))) | 2021 ;; Take file from default dir if it exists there; |
1862 (when (file-exists-p file-ex) | 2022 ;; otherwise let `load' search for it. |
1863 (setq file file-ex)) | 2023 (file-ex (expand-file-name file))) |
1864 (load file nil t))) | 2024 (when (file-exists-p file-ex) |
1865 | 2025 (setq file file-ex)) |
1866 ;; This is used to handle -script. It's not clear | 2026 (load file nil t))) |
1867 ;; we need to document it. | 2027 |
1868 ((member argi '("-scriptload")) | 2028 ;; This is used to handle -script. It's not clear |
1869 (let* ((file (command-line-normalize-file-name | 2029 ;; we need to document it. |
1870 (or argval (pop command-line-args-left)))) | 2030 ((member argi '("-scriptload")) |
1871 ;; Take file from default dir. | 2031 (let* ((file (command-line-normalize-file-name |
1872 (file-ex (expand-file-name file))) | 2032 (or argval (pop command-line-args-left)))) |
1873 (load file-ex nil t t))) | 2033 ;; Take file from default dir. |
1874 | 2034 (file-ex (expand-file-name file))) |
1875 ((equal argi "-insert") | 2035 (load file-ex nil t t))) |
1876 (setq tem (or argval (pop command-line-args-left))) | 2036 |
1877 (or (stringp tem) | 2037 ((equal argi "-insert") |
1878 (error "File name omitted from `-insert' option")) | 2038 (setq inhibit-startup-screen t) |
1879 (insert-file-contents (command-line-normalize-file-name tem))) | 2039 (setq tem (or argval (pop command-line-args-left))) |
1880 | 2040 (or (stringp tem) |
1881 ((equal argi "-kill") | 2041 (error "File name omitted from `-insert' option")) |
1882 (kill-emacs t)) | 2042 (insert-file-contents (command-line-normalize-file-name tem))) |
1883 | 2043 |
1884 ;; This is for when they use --no-desktop with -q, or | 2044 ((equal argi "-kill") |
1885 ;; don't load Desktop in their .emacs. If desktop.el | 2045 (kill-emacs t)) |
1886 ;; _is_ loaded, it will handle this switch, and we | 2046 |
1887 ;; won't see it by the time we get here. | 2047 ;; This is for when they use --no-desktop with -q, or |
1888 ((equal argi "-no-desktop") | 2048 ;; don't load Desktop in their .emacs. If desktop.el |
1889 (message "\"--no-desktop\" ignored because the Desktop package is not loaded")) | 2049 ;; _is_ loaded, it will handle this switch, and we |
1890 | 2050 ;; won't see it by the time we get here. |
1891 ((string-match "^\\+[0-9]+\\'" argi) | 2051 ((equal argi "-no-desktop") |
1892 (setq line (string-to-number argi))) | 2052 (message "\"--no-desktop\" ignored because the Desktop package is not loaded")) |
1893 | 2053 |
1894 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi) | 2054 ((string-match "^\\+[0-9]+\\'" argi) |
1895 (setq line (string-to-number (match-string 1 argi)) | 2055 (setq line (string-to-number argi))) |
1896 column (string-to-number (match-string 2 argi)))) | 2056 |
1897 | 2057 ((string-match "^\\+\\([0-9]+\\):\\([0-9]+\\)\\'" argi) |
1898 ((setq tem (assoc argi command-line-x-option-alist)) | 2058 (setq line (string-to-number (match-string 1 argi)) |
1899 ;; Ignore X-windows options and their args if not using X. | 2059 column (string-to-number (match-string 2 argi)))) |
1900 (setq command-line-args-left | 2060 |
1901 (nthcdr (nth 1 tem) command-line-args-left))) | 2061 ((setq tem (assoc argi command-line-x-option-alist)) |
1902 | 2062 ;; Ignore X-windows options and their args if not using X. |
1903 ((member argi '("-find-file" "-file" "-visit")) | 2063 (setq command-line-args-left |
1904 ;; An explicit option to specify visiting a file. | 2064 (nthcdr (nth 1 tem) command-line-args-left))) |
1905 (setq tem (or argval (pop command-line-args-left))) | 2065 |
1906 (unless (stringp tem) | 2066 ((member argi '("-find-file" "-file" "-visit")) |
1907 (error "File name omitted from `%s' option" argi)) | 2067 (setq inhibit-startup-screen t) |
1908 (setq file-count (1+ file-count)) | 2068 ;; An explicit option to specify visiting a file. |
1909 (let ((file (expand-file-name | 2069 (setq tem (or argval (pop command-line-args-left))) |
1910 (command-line-normalize-file-name tem) dir))) | 2070 (unless (stringp tem) |
1911 (if (= file-count 1) | 2071 (error "File name omitted from `%s' option" argi)) |
1912 (setq first-file-buffer (find-file file)) | 2072 (setq file-count (1+ file-count)) |
1913 (find-file-other-window file))) | 2073 (let ((file (expand-file-name |
1914 (or (zerop line) | 2074 (command-line-normalize-file-name tem) dir))) |
1915 (goto-line line)) | 2075 (if (= file-count 1) |
1916 (setq line 0) | 2076 (setq first-file-buffer (find-file file)) |
1917 (unless (< column 1) | 2077 (find-file-other-window file))) |
1918 (move-to-column (1- column))) | 2078 (or (zerop line) |
1919 (setq column 0)) | 2079 (goto-line line)) |
1920 | 2080 (setq line 0) |
1921 ((equal argi "--") | 2081 (unless (< column 1) |
1922 (setq just-files t)) | 2082 (move-to-column (1- column))) |
1923 (t | 2083 (setq column 0)) |
1924 ;; We have almost exhausted our options. See if the | 2084 |
1925 ;; user has made any other command-line options available | 2085 ((equal argi "--") |
1926 (let ((hooks command-line-functions) ;; lrs 7/31/89 | 2086 (setq just-files t)) |
1927 (did-hook nil)) | 2087 (t |
1928 (while (and hooks | 2088 ;; We have almost exhausted our options. See if the |
1929 (not (setq did-hook (funcall (car hooks))))) | 2089 ;; user has made any other command-line options available |
1930 (setq hooks (cdr hooks))) | 2090 (let ((hooks command-line-functions) |
1931 (if (not did-hook) | 2091 (did-hook nil)) |
1932 ;; Presume that the argument is a file name. | 2092 (while (and hooks |
1933 (progn | 2093 (not (setq did-hook (funcall (car hooks))))) |
1934 (if (string-match "\\`-" argi) | 2094 (setq hooks (cdr hooks))) |
1935 (error "Unknown option `%s'" argi)) | 2095 (if (not did-hook) |
1936 (setq file-count (1+ file-count)) | 2096 ;; Presume that the argument is a file name. |
1937 (let ((file | 2097 (progn |
1938 (expand-file-name | 2098 (if (string-match "\\`-" argi) |
1939 (command-line-normalize-file-name orig-argi) | 2099 (error "Unknown option `%s'" argi)) |
1940 dir))) | 2100 (unless window-system |
1941 (if (= file-count 1) | 2101 (setq inhibit-startup-screen t)) |
1942 (setq first-file-buffer (find-file file)) | 2102 (setq file-count (1+ file-count)) |
1943 (find-file-other-window file))) | 2103 (let ((file |
1944 (or (zerop line) | 2104 (expand-file-name |
1945 (goto-line line)) | 2105 (command-line-normalize-file-name orig-argi) |
1946 (setq line 0) | 2106 dir))) |
1947 (unless (< column 1) | 2107 (cond ((= file-count 1) |
1948 (move-to-column (1- column))) | 2108 (setq first-file-buffer (find-file file))) |
1949 (setq column 0)))))) | 2109 (inhibit-startup-screen |
1950 ;; In unusual circumstances, the execution of Lisp code due | 2110 (find-file-other-window file)) |
1951 ;; to command-line options can cause the last visible frame | 2111 (t (find-file file)))) |
1952 ;; to be deleted. In this case, kill emacs to avoid an | 2112 (or (zerop line) |
1953 ;; abort later. | 2113 (goto-line line)) |
1954 (unless (frame-live-p (selected-frame)) (kill-emacs nil)))) | 2114 (setq line 0) |
1955 | 2115 (unless (< column 1) |
1956 ;; If 3 or more files visited, and not all visible, | 2116 (move-to-column (1- column))) |
1957 ;; show user what they all are. But leave the last one current. | 2117 (setq column 0)))))) |
1958 (and (> file-count 2) | 2118 ;; In unusual circumstances, the execution of Lisp code due |
1959 (not noninteractive) | 2119 ;; to command-line options can cause the last visible frame |
1960 (not inhibit-startup-buffer-menu) | 2120 ;; to be deleted. In this case, kill emacs to avoid an |
1961 (or (get-buffer-window first-file-buffer) | 2121 ;; abort later. |
1962 (list-buffers))))) | 2122 (unless (frame-live-p (selected-frame)) (kill-emacs nil)))))) |
1963 | 2123 |
1964 ;; Maybe display a startup screen. | 2124 (if (or inhibit-startup-screen |
1965 (unless (or inhibit-startup-message | 2125 noninteractive |
1966 noninteractive | 2126 emacs-quick-startup) |
1967 emacs-quick-startup) | 2127 |
1968 ;; Display a startup screen, after some preparations. | 2128 ;; Not displaying a startup screen. If 3 or more files |
1969 | 2129 ;; visited, and not all visible, show user what they all are. |
1970 ;; If there are no switches to process, we might as well | 2130 (and (> file-count 2) |
1971 ;; run this hook now, and there may be some need to do it | 2131 (not noninteractive) |
1972 ;; before doing any output. | 2132 (not inhibit-startup-buffer-menu) |
1973 (run-hooks 'emacs-startup-hook) | 2133 (or (get-buffer-window first-file-buffer) |
1974 (and term-setup-hook | 2134 (list-buffers))) |
1975 (run-hooks 'term-setup-hook)) | 2135 |
1976 (setq inhibit-startup-hooks t) | 2136 ;; Display a startup screen, after some preparations. |
1977 | 2137 |
1978 ;; It's important to notice the user settings before we | 2138 ;; If there are no switches to process, we might as well |
1979 ;; display the startup message; otherwise, the settings | 2139 ;; run this hook now, and there may be some need to do it |
1980 ;; won't take effect until the user gives the first | 2140 ;; before doing any output. |
1981 ;; keystroke, and that's distracting. | 2141 (run-hooks 'emacs-startup-hook) |
1982 (when (fboundp 'frame-notice-user-settings) | 2142 (and term-setup-hook |
1983 (frame-notice-user-settings)) | 2143 (run-hooks 'term-setup-hook)) |
1984 | 2144 (setq inhibit-startup-hooks t) |
1985 ;; If there are no switches to process, we might as well | 2145 |
1986 ;; run this hook now, and there may be some need to do it | 2146 ;; It's important to notice the user settings before we |
1987 ;; before doing any output. | 2147 ;; display the startup message; otherwise, the settings |
1988 (when window-setup-hook | 2148 ;; won't take effect until the user gives the first |
1989 (run-hooks 'window-setup-hook) | 2149 ;; keystroke, and that's distracting. |
1990 ;; Don't let the hook be run twice. | 2150 (when (fboundp 'frame-notice-user-settings) |
1991 (setq window-setup-hook nil)) | 2151 (frame-notice-user-settings)) |
1992 | 2152 |
1993 ;; Do this now to avoid an annoying delay if the user | 2153 ;; If there are no switches to process, we might as well |
1994 ;; clicks the menu bar during the sit-for. | 2154 ;; run this hook now, and there may be some need to do it |
1995 (when (display-popup-menus-p) | 2155 ;; before doing any output. |
1996 (precompute-menubar-bindings)) | 2156 (when window-setup-hook |
1997 (with-no-warnings | 2157 (run-hooks 'window-setup-hook) |
1998 (setq menubar-bindings-done t)) | 2158 ;; Don't let the hook be run twice. |
1999 | 2159 (setq window-setup-hook nil)) |
2000 ;; If *scratch* exists and is empty, insert initial-scratch-message. | 2160 |
2001 (and initial-scratch-message | 2161 ;; ;; Do this now to avoid an annoying delay if the user |
2002 (get-buffer "*scratch*") | 2162 ;; ;; clicks the menu bar during the sit-for. |
2003 (with-current-buffer "*scratch*" | 2163 ;; (when (display-popup-menus-p) |
2004 (when (zerop (buffer-size)) | 2164 ;; (precompute-menubar-bindings)) |
2005 (insert initial-scratch-message) | 2165 ;; (with-no-warnings |
2006 (set-buffer-modified-p nil)))) | 2166 ;; (setq menubar-bindings-done t)) |
2007 | 2167 |
2008 ;; If user typed input during all that work, | 2168 ;; If *scratch* exists and is empty, insert initial-scratch-message. |
2009 ;; abort the startup screen. Otherwise, display it now. | 2169 (and initial-scratch-message |
2010 (unless (input-pending-p) | 2170 (get-buffer "*scratch*") |
2011 (display-splash-screen t)))) | 2171 (with-current-buffer "*scratch*" |
2012 | 2172 (when (zerop (buffer-size)) |
2173 (insert initial-scratch-message) | |
2174 (set-buffer-modified-p nil)))) | |
2175 | |
2176 (if (> file-count 0) | |
2177 (display-startup-screen t) | |
2178 (display-startup-screen nil))))) | |
2013 | 2179 |
2014 (defun command-line-normalize-file-name (file) | 2180 (defun command-line-normalize-file-name (file) |
2015 "Collapse multiple slashes to one, to handle non-Emacs file names." | 2181 "Collapse multiple slashes to one, to handle non-Emacs file names." |
2016 (save-match-data | 2182 (save-match-data |
2017 ;; Use arg 1 so that we don't collapse // at the start of the file name. | 2183 ;; Use arg 1 so that we don't collapse // at the start of the file name. |