comparison lisp/startup.el @ 57002:5ce2d0959cd2

(command-line-1): Make option --directory/-L modify `load-path' straight away.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 08 Sep 2004 11:43:30 +0000
parents e4b0dc013442
children 9bc06f7dfca8 42acc7fa8a4f cce1c0ee76ee
comparison
equal deleted inserted replaced
57001:01ad85e53516 57002:5ce2d0959cd2
1477 ;; We have command args; process them. 1477 ;; We have command args; process them.
1478 (let ((dir command-line-default-directory) 1478 (let ((dir command-line-default-directory)
1479 (file-count 0) 1479 (file-count 0)
1480 first-file-buffer 1480 first-file-buffer
1481 tem 1481 tem
1482 ;; The directories listed in --directory/-L options will *appear* 1482 ;; This approach loses for "-batch -L DIR --eval "(require foo)",
1483 ;; at the front of `load-path' in the order they appear on the 1483 ;; if foo is intended to be found in DIR.
1484 ;; command-line. We cannot do this by *placing* them at the front 1484 ;;
1485 ;; in the order they appear, so we need this variable to hold them, 1485 ;; ;; The directories listed in --directory/-L options will *appear*
1486 ;; temporarily. 1486 ;; ;; at the front of `load-path' in the order they appear on the
1487 extra-load-path 1487 ;; ;; command-line. We cannot do this by *placing* them at the front
1488 ;; ;; in the order they appear, so we need this variable to hold them,
1489 ;; ;; temporarily.
1490 ;; extra-load-path
1491 ;;
1492 ;; To DTRT we keep track of the splice point and modify `load-path'
1493 ;; straight away upon any --directory/-L option.
1494 splice
1488 just-files ;; t if this follows the magic -- option. 1495 just-files ;; t if this follows the magic -- option.
1489 ;; This includes our standard options' long versions 1496 ;; This includes our standard options' long versions
1490 ;; and long versions of what's on command-switch-alist. 1497 ;; and long versions of what's on command-switch-alist.
1491 (longopts 1498 (longopts
1492 (append '(("--funcall") ("--load") ("--insert") ("--kill") 1499 (append '(("--funcall") ("--load") ("--insert") ("--kill")
1551 (command-execute tem) 1558 (command-execute tem)
1552 (funcall tem))) 1559 (funcall tem)))
1553 1560
1554 ((member argi '("-eval" "-execute")) 1561 ((member argi '("-eval" "-execute"))
1555 (eval (read (or argval (pop command-line-args-left))))) 1562 (eval (read (or argval (pop command-line-args-left)))))
1556 ;; Set the default directory as specified in -L.
1557 1563
1558 ((member argi '("-L" "-directory")) 1564 ((member argi '("-L" "-directory"))
1559 (setq tem (or argval (pop command-line-args-left))) 1565 (setq tem (expand-file-name
1560 ;; We will reverse `extra-load-path' and prepend it to 1566 (command-line-normalize-file-name
1561 ;; `load-path' after all the arguments have been processed. 1567 (or argval (pop command-line-args-left)))))
1562 (push 1568 (cond (splice (setcdr splice (cons tem (cdr splice)))
1563 (expand-file-name (command-line-normalize-file-name tem)) 1569 (setq splice (cdr splice)))
1564 extra-load-path)) 1570 (t (setq load-path (cons tem load-path)
1571 splice load-path))))
1565 1572
1566 ((member argi '("-l" "-load")) 1573 ((member argi '("-l" "-load"))
1567 (let* ((file (command-line-normalize-file-name 1574 (let* ((file (command-line-normalize-file-name
1568 (or argval (pop command-line-args-left)))) 1575 (or argval (pop command-line-args-left))))
1569 ;; Take file from default dir if it exists there; 1576 ;; Take file from default dir if it exists there;
1640 (setq line 0) 1647 (setq line 0)
1641 (unless (< column 1) 1648 (unless (< column 1)
1642 (move-to-column (1- column))) 1649 (move-to-column (1- column)))
1643 (setq column 0)))))))) 1650 (setq column 0))))))))
1644 1651
1645 ;; See --directory/-L option above.
1646 (when extra-load-path
1647 (setq load-path (append (nreverse extra-load-path) load-path)))
1648
1649 ;; If 3 or more files visited, and not all visible, 1652 ;; If 3 or more files visited, and not all visible,
1650 ;; show user what they all are. But leave the last one current. 1653 ;; show user what they all are. But leave the last one current.
1651 (and (> file-count 2) 1654 (and (> file-count 2)
1652 (not noninteractive) 1655 (not noninteractive)
1653 (not inhibit-startup-buffer-menu) 1656 (not inhibit-startup-buffer-menu)