diff 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
line wrap: on
line diff
--- a/lisp/startup.el	Wed Sep 08 11:37:16 2004 +0000
+++ b/lisp/startup.el	Wed Sep 08 11:43:30 2004 +0000
@@ -1479,12 +1479,19 @@
           (file-count 0)
           first-file-buffer
           tem
-          ;; The directories listed in --directory/-L options will *appear*
-          ;; at the front of `load-path' in the order they appear on the
-          ;; command-line.  We cannot do this by *placing* them at the front
-          ;; in the order they appear, so we need this variable to hold them,
-          ;; temporarily.
-          extra-load-path
+          ;; This approach loses for "-batch -L DIR --eval "(require foo)",
+          ;; if foo is intended to be found in DIR.
+          ;;
+          ;; ;; The directories listed in --directory/-L options will *appear*
+          ;; ;; at the front of `load-path' in the order they appear on the
+          ;; ;; command-line.  We cannot do this by *placing* them at the front
+          ;; ;; in the order they appear, so we need this variable to hold them,
+          ;; ;; temporarily.
+          ;; extra-load-path
+          ;;
+          ;; To DTRT we keep track of the splice point and modify `load-path'
+          ;; straight away upon any --directory/-L option.
+          splice
           just-files ;; t if this follows the magic -- option.
           ;; This includes our standard options' long versions
           ;; and long versions of what's on command-switch-alist.
@@ -1553,15 +1560,15 @@
 
                 ((member argi '("-eval" "-execute"))
                  (eval (read (or argval (pop command-line-args-left)))))
-                ;; Set the default directory as specified in -L.
 
                 ((member argi '("-L" "-directory"))
-                 (setq tem (or argval (pop command-line-args-left)))
-                 ;; We will reverse `extra-load-path' and prepend it to
-                 ;; `load-path' after all the arguments have been processed.
-                 (push
-                  (expand-file-name (command-line-normalize-file-name tem))
-                  extra-load-path))
+                 (setq tem (expand-file-name
+                            (command-line-normalize-file-name
+                             (or argval (pop command-line-args-left)))))
+                 (cond (splice (setcdr splice (cons tem (cdr splice)))
+                               (setq splice (cdr splice)))
+                       (t (setq load-path (cons tem load-path)
+                                splice load-path))))
 
                 ((member argi '("-l" "-load"))
                  (let* ((file (command-line-normalize-file-name
@@ -1642,10 +1649,6 @@
                            (move-to-column (1- column)))
                          (setq column 0))))))))
 
-      ;; See --directory/-L option above.
-      (when extra-load-path
-        (setq load-path (append (nreverse extra-load-path) load-path)))
-
       ;; If 3 or more files visited, and not all visible,
       ;; show user what they all are.  But leave the last one current.
       (and (> file-count 2)