Mercurial > hg > xemacs-beta
comparison lisp/startup.el @ 2456:f4e405a9d18d
[xemacs-hg @ 2004-12-27 12:25:14 by michaels]
2004-12-18 Mike Sperber <mike@xemacs.org>
* package-admin.el:
* startup.el: Reflect the changes made in packages.el.
* packages.el:
* loadup.el:
* make-docfile.el:
* package-admin.el:
* startup.el:
* update-elc.el (early-package-hierarchies)
(late-package-hierarchies)
(last-package-hierarchies): Renamed these from `early-packages',
`late-packages' and `last-packages'.
* packages.el: Rewrote package-finding logic to separate the
concepts of "package directories" and "package hierarchies".
Added explanation of these concepts.
* setup-paths.el:
* find-paths.el: Added parameter descriptions to some of the
docstrings.
* packages.el, setup-paths.el: Make terminology more explicit
about "package hierarchies"
* startup.el (emacs-roots, emacs-data-roots)
(user-init-directory-base, user-init-directory)
(user-init-file-base, user-init-file-base-list)
(user-home-init-file-base-list)
(load-home-init-file, load-user-init-file-p)
(startup-find-load-path, startup-setup-paths)
(startup-find-load-path-for-packages): Moved these back from
setup-paths.el where they belong---setup-paths.el now again, as
documented, contains no code that sets global variables. (They
were moved from startup.el to setup-paths.el on 2003-02-28.)
Clarify that in the comment at the top.
* setup-paths.el (paths-find-emacs-roots): Restored
`invocation-directory' 'invocation-name' parameters removed on
2003-02-28; they're useful for debugging.
author | michaels |
---|---|
date | Mon, 27 Dec 2004 12:27:05 +0000 |
parents | 69a0933b86f1 |
children | 3e5a2d0d57e1 |
comparison
equal
deleted
inserted
replaced
2455:3e06061baa0e | 2456:f4e405a9d18d |
---|---|
127 XEmacs runs this hook after processing the command line arguments and loading | 127 XEmacs runs this hook after processing the command line arguments and loading |
128 the user's init file.") | 128 the user's init file.") |
129 | 129 |
130 (defconst initial-major-mode 'lisp-interaction-mode | 130 (defconst initial-major-mode 'lisp-interaction-mode |
131 "Major mode command symbol to use for the initial *scratch* buffer.") | 131 "Major mode command symbol to use for the initial *scratch* buffer.") |
132 | 132 |
133 ;;; Path-related variables. | |
134 ;;; NOTE: Many of them (`lisp-directory', `data-directory', etc.) are | |
135 ;;; built-in. | |
136 | |
137 (defvar emacs-roots nil | |
138 "List of plausible roots of the XEmacs hierarchy. | |
139 This is a list of plausible directories in which to search for the important | |
140 directories used by XEmacs at run-time, for example `exec-directory', | |
141 `data-directory' and `lisp-directory'. | |
142 | |
143 Normally set at startup by calling `paths-find-emacs-roots'.") | |
144 | |
145 (defvar emacs-data-roots nil | |
146 "List of plausible data roots of the XEmacs hierarchy.") | |
147 | |
148 (defvar user-init-directory-base ".xemacs" | |
149 "Base of directory where user-installed init files may go.") | |
150 | |
151 (defvar user-init-directory | |
152 (file-name-as-directory | |
153 (paths-construct-path (list "~" user-init-directory-base))) | |
154 "Directory where user-installed init files may go.") | |
155 | |
156 (defvar user-init-file-base "init.el" | |
157 "Default name of the user init file if uncompiled. | |
158 This should be used for migration purposes only.") | |
159 | |
160 (defvar user-init-file-base-list '("init.el") | |
161 "List of allowed init files in the user's init directory. | |
162 The first one found takes precedence. .elc files do not need to be listed.") | |
163 | |
164 (defvar user-home-init-file-base-list | |
165 (append '(".emacs.el" ".emacs") | |
166 (and (eq system-type 'windows-nt) | |
167 '("_emacs.el" "_emacs"))) | |
168 "List of allowed init files in the user's home directory. | |
169 The first one found takes precedence. .elc files do not need to be listed.") | |
170 | |
171 (defvar load-home-init-file nil | |
172 "Non-nil if XEmacs should load the init file from the home directory. | |
173 Otherwise, XEmacs will offer migration to the init directory.") | |
174 | |
175 (defvar load-user-init-file-p t | |
176 "Non-nil if XEmacs should load the user's init file.") | |
177 | |
133 ;; #### called `site-run-file' in FSFmacs | 178 ;; #### called `site-run-file' in FSFmacs |
134 | 179 |
135 (defvar site-start-file "site-start" | 180 (defvar site-start-file "site-start" |
136 "File containing site-wide run-time initializations. | 181 "File containing site-wide run-time initializations. |
137 It is loaded at run-time before the user's init file (see `user-init-file'). | 182 It is loaded at run-time before the user's init file (see `user-init-file'). |
1345 (or invocation-directory (setq invocation-directory default-directory)) | 1390 (or invocation-directory (setq invocation-directory default-directory)) |
1346 (setq invocation-directory | 1391 (setq invocation-directory |
1347 ;; don't let /tmp_mnt/... get into the load-path or exec-path. | 1392 ;; don't let /tmp_mnt/... get into the load-path or exec-path. |
1348 (abbreviate-file-name invocation-directory))) | 1393 (abbreviate-file-name invocation-directory))) |
1349 | 1394 |
1395 ;;; High-level functions to set up the paths. | |
1396 | |
1397 (defun startup-find-load-path (&optional inhibit-packages | |
1398 set-global-package-paths) | |
1399 "Determine the value for `load-path'. | |
1400 INHIBIT-PACKAGES says which types of packages, if any, to omit from the | |
1401 returned value. It can be `t' (omit all), one of the symbols `early', | |
1402 `late', or `last', or a list of one or more of the symbols. | |
1403 | |
1404 If SET-GLOBAL-PACKAGE-PATHS is non-nil, initialize the global package path | |
1405 variables referring to the particular types of packages | |
1406 (`early-package-hierarchies', `early-package-load-path', | |
1407 `late-package-hierarchies', `late-package-load-path', | |
1408 `last-package-hierarchies', `last-package-load-path')." | |
1409 (let (earlyp latep lastp earlyp-lp latep-lp lastp-lp) | |
1410 (apply #'(lambda (early late last) | |
1411 (setq earlyp (and (not (memq 'early inhibit-packages)) early)) | |
1412 (setq latep (and (not (memq 'late inhibit-packages)) late)) | |
1413 (setq lastp (and (not (memq 'last inhibit-packages)) last))) | |
1414 (packages-find-all-package-hierarchies | |
1415 emacs-data-roots)) | |
1416 | |
1417 (setq earlyp-lp (packages-find-package-load-path earlyp)) | |
1418 (setq latep-lp (packages-find-package-load-path latep)) | |
1419 (setq lastp-lp (packages-find-package-load-path lastp)) | |
1420 | |
1421 (when set-global-package-paths | |
1422 (setq early-package-hierarchies earlyp | |
1423 late-package-hierarchies latep | |
1424 last-package-hierarchies lastp | |
1425 early-package-load-path earlyp-lp | |
1426 late-package-load-path latep-lp | |
1427 last-package-load-path lastp-lp)) | |
1428 | |
1429 (paths-construct-load-path emacs-roots earlyp-lp latep-lp lastp-lp | |
1430 lisp-directory site-directory | |
1431 mule-lisp-directory))) | |
1432 | |
1433 (defun startup-setup-paths (&optional inhibit-packages called-early) | |
1434 "Setup all the various paths. | |
1435 INHIBIT-PACKAGES says which types of packages, if any, to omit from the | |
1436 returned value. It can be `t' (omit all), one of the symbols `early', | |
1437 `late', or `last', or a list of one or more of the symbols. | |
1438 | |
1439 This function is idempotent, so call this as often as you like!" | |
1440 | |
1441 (setq debug-paths (or debug-paths | |
1442 (and (getenv "EMACSDEBUGPATHS") | |
1443 t))) | |
1444 | |
1445 (setq emacs-roots (paths-find-emacs-roots invocation-directory invocation-name | |
1446 #'paths-emacs-data-root-p)) | |
1447 | |
1448 (setq emacs-data-roots (paths-find-emacs-roots invocation-directory invocation-name | |
1449 #'paths-emacs-data-root-p)) | |
1450 | |
1451 (if (null emacs-roots) | |
1452 (save-excursion | |
1453 (set-buffer (get-buffer-create " *warning-tmp*")) | |
1454 (erase-buffer) | |
1455 (buffer-disable-undo (current-buffer)) | |
1456 | |
1457 (insert "Couldn't find an obvious default for the root of the\n" | |
1458 "XEmacs hierarchy.") | |
1459 | |
1460 (princ "\nWARNING:\n" 'external-debugging-output) | |
1461 (princ (buffer-string) 'external-debugging-output))) | |
1462 | |
1463 (if (eq inhibit-packages t) | |
1464 (setq inhibit-packages '(early late last))) | |
1465 (if (not (listp inhibit-packages)) | |
1466 (setq inhibit-packages (list inhibit-packages))) | |
1467 | |
1468 (when debug-paths | |
1469 (princ (format | |
1470 "startup-setup-paths arguments: | |
1471 inhibit-packages: %S | |
1472 inhibit-site-lisp: %S | |
1473 called-early: %S | |
1474 " inhibit-packages inhibit-site-lisp called-early) | |
1475 'external-debugging-output) | |
1476 (princ (format | |
1477 "emacs-roots: | |
1478 %S | |
1479 emacs-data-roots: | |
1480 %S | |
1481 user-init-directory: %S | |
1482 configure-package-path: %S | |
1483 " emacs-roots emacs-data-roots user-init-directory configure-package-path) | |
1484 'external-debugging-output) | |
1485 ) | |
1486 | |
1487 (setq lisp-directory (paths-find-lisp-directory emacs-roots)) | |
1488 | |
1489 (if debug-paths | |
1490 (princ (format "lisp-directory:\n%S\n" lisp-directory) | |
1491 'external-debugging-output)) | |
1492 | |
1493 (if (featurep 'mule) | |
1494 (progn | |
1495 (setq mule-lisp-directory | |
1496 (paths-find-mule-lisp-directory emacs-roots | |
1497 lisp-directory)) | |
1498 (if debug-paths | |
1499 (princ (format "mule-lisp-directory:\n%S\n" | |
1500 mule-lisp-directory) | |
1501 'external-debugging-output))) | |
1502 (setq mule-lisp-directory '())) | |
1503 | |
1504 (setq site-directory (and (null inhibit-site-lisp) | |
1505 (paths-find-site-lisp-directory emacs-roots))) | |
1506 | |
1507 (if (and debug-paths (null inhibit-site-lisp)) | |
1508 (princ (format "site-directory:\n%S\n" site-directory) | |
1509 'external-debugging-output)) | |
1510 | |
1511 (setq load-path (startup-find-load-path inhibit-packages t)) | |
1512 | |
1513 (when debug-paths | |
1514 (princ (format "early-package-hierarchies and early-package-load-path:\n%S\n%S\n" | |
1515 early-package-hierarchies early-package-load-path) | |
1516 'external-debugging-output) | |
1517 (princ (format "late-package-hierarchies and late-package-load-path:\n%S\n%S\n" | |
1518 late-package-hierarchies late-package-load-path) | |
1519 'external-debugging-output) | |
1520 (princ (format "last-package-hierarchies and last-package-load-path:\n%S\n%S\n" | |
1521 last-package-hierarchies last-package-load-path) | |
1522 'external-debugging-output)) | |
1523 | |
1524 (if debug-paths | |
1525 (princ (format "load-path:\n%S\n" load-path) | |
1526 'external-debugging-output)) | |
1527 (setq module-directory (paths-find-module-directory emacs-roots)) | |
1528 (if debug-paths | |
1529 (princ (format "module-directory:\n%S\n" module-directory) | |
1530 'external-debugging-output)) | |
1531 (setq site-module-directory (and (null inhibit-site-modules) | |
1532 (paths-find-site-module-directory | |
1533 emacs-roots))) | |
1534 (if (and debug-paths (null inhibit-site-modules)) | |
1535 (princ (format "site-module-directory:\n%S\n" | |
1536 site-module-directory) | |
1537 'external-debugging-output)) | |
1538 | |
1539 (setq module-load-path (paths-construct-module-load-path | |
1540 emacs-roots | |
1541 module-directory | |
1542 site-module-directory)) | |
1543 | |
1544 (unless called-early | |
1545 (setq Info-directory-list | |
1546 (paths-construct-info-path | |
1547 emacs-roots | |
1548 early-package-hierarchies late-package-hierarchies last-package-hierarchies)) | |
1549 | |
1550 (if debug-paths | |
1551 (princ (format "Info-directory-list:\n%S\n" Info-directory-list) | |
1552 'external-debugging-output)) | |
1553 | |
1554 (setq exec-directory (paths-find-exec-directory emacs-roots)) | |
1555 | |
1556 (if debug-paths | |
1557 (princ (format "exec-directory:\n%s\n" exec-directory) | |
1558 'external-debugging-output)) | |
1559 | |
1560 (setq exec-path | |
1561 (paths-construct-exec-path emacs-roots exec-directory | |
1562 early-package-hierarchies late-package-hierarchies | |
1563 last-package-hierarchies)) | |
1564 | |
1565 (if debug-paths | |
1566 (princ (format "exec-path:\n%S\n" exec-path) | |
1567 'external-debugging-output)) | |
1568 | |
1569 (setq doc-directory (paths-find-doc-directory emacs-roots)) | |
1570 | |
1571 (if debug-paths | |
1572 (princ (format "doc-directory:\n%S\n" doc-directory) | |
1573 'external-debugging-output)) | |
1574 | |
1575 (setq data-directory (paths-find-data-directory emacs-roots)) | |
1576 | |
1577 (if debug-paths | |
1578 (princ (format "data-directory:\n%S\n" data-directory) | |
1579 'external-debugging-output)) | |
1580 | |
1581 (setq data-directory-list (paths-construct-data-directory-list | |
1582 data-directory early-package-hierarchies | |
1583 late-package-hierarchies last-package-hierarchies)) | |
1584 (if debug-paths | |
1585 (princ (format "data-directory-list:\n%S\n" data-directory-list) | |
1586 'external-debugging-output)))) | |
1587 | |
1588 (defun startup-find-load-path-for-packages (packages) | |
1589 "Return a suitable load-path for PACKAGES. | |
1590 PACKAGES is a list of package names (strings). This looks for package | |
1591 directories in the load path whose last component is one of the members of | |
1592 PACKAGES." | |
1593 (mapcan | |
1594 #'(lambda (package) | |
1595 (and (member (file-name-nondirectory (directory-file-name package)) | |
1596 packages) | |
1597 (list package))) | |
1598 (startup-find-load-path))) | |
1599 | |
1600 ; (defun startup-set-basic-packages-load-path () | |
1601 ; "#### This is a hack. When recompiling .el files, we use -no-packages | |
1602 ; to avoid problems with packages shadowing standard Lisp files | |
1603 ; (e.g. unicode.el), but we really still need the stuff in xemacs-base and | |
1604 ; xemacs-devel." | |
1605 ; (setq load-path (startup-find-load-path-for-packages | |
1606 ; '("xemacs-base" "xemacs-devel")))) | |
1607 | |
1350 (defun startup-setup-paths-warning () | 1608 (defun startup-setup-paths-warning () |
1351 (let ((warnings '())) | 1609 (let ((warnings '())) |
1352 (cond | 1610 (cond |
1353 ((null (and lisp-directory exec-directory data-directory doc-directory | 1611 ((null (and lisp-directory exec-directory data-directory doc-directory |
1354 load-path)) | 1612 load-path)) |
1377 (princ "\nWARNING:\n" 'external-debugging-output) | 1635 (princ "\nWARNING:\n" 'external-debugging-output) |
1378 (princ (buffer-string) 'external-debugging-output) | 1636 (princ (buffer-string) 'external-debugging-output) |
1379 (erase-buffer) | 1637 (erase-buffer) |
1380 t))))) | 1638 t))))) |
1381 | 1639 |
1640 | |
1641 ;;; Now actually set the paths up, for bootstrapping purposes. This is run | |
1642 ;;; at early dump time and in certain cases where we use a minimal temacs | |
1643 ;;; to do useful things, like rebuild DOC. | |
1644 | |
1645 (startup-setup-paths (if inhibit-all-packages t '(early last)) t) | |
1646 | |
1647 | |
1382 (defun startup-load-autoloads () | 1648 (defun startup-load-autoloads () |
1383 (when (and (not inhibit-autoloads) lisp-directory) | 1649 (when (and (not inhibit-autoloads) lisp-directory) |
1384 (load (expand-file-name (file-name-sans-extension autoload-file-name) | 1650 (load (expand-file-name (file-name-sans-extension autoload-file-name) |
1385 lisp-directory) | 1651 lisp-directory) |
1386 nil t) | 1652 nil t) |