Commit b9687971 authored by Thien-Thi Nguyen's avatar Thien-Thi Nguyen
Browse files

(command-line-1): Make option

--directory/-L modify `load-path' straight away.
parent bc9447bc
...@@ -1479,12 +1479,19 @@ normal otherwise." ...@@ -1479,12 +1479,19 @@ normal otherwise."
(file-count 0) (file-count 0)
first-file-buffer first-file-buffer
tem tem
;; The directories listed in --directory/-L options will *appear* ;; This approach loses for "-batch -L DIR --eval "(require foo)",
;; at the front of `load-path' in the order they appear on the ;; if foo is intended to be found in DIR.
;; 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, ;; ;; The directories listed in --directory/-L options will *appear*
;; temporarily. ;; ;; at the front of `load-path' in the order they appear on the
extra-load-path ;; ;; 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. just-files ;; t if this follows the magic -- option.
;; This includes our standard options' long versions ;; This includes our standard options' long versions
;; and long versions of what's on command-switch-alist. ;; and long versions of what's on command-switch-alist.
...@@ -1553,15 +1560,15 @@ normal otherwise." ...@@ -1553,15 +1560,15 @@ normal otherwise."
((member argi '("-eval" "-execute")) ((member argi '("-eval" "-execute"))
(eval (read (or argval (pop command-line-args-left))))) (eval (read (or argval (pop command-line-args-left)))))
;; Set the default directory as specified in -L.
((member argi '("-L" "-directory")) ((member argi '("-L" "-directory"))
(setq tem (or argval (pop command-line-args-left))) (setq tem (expand-file-name
;; We will reverse `extra-load-path' and prepend it to (command-line-normalize-file-name
;; `load-path' after all the arguments have been processed. (or argval (pop command-line-args-left)))))
(push (cond (splice (setcdr splice (cons tem (cdr splice)))
(expand-file-name (command-line-normalize-file-name tem)) (setq splice (cdr splice)))
extra-load-path)) (t (setq load-path (cons tem load-path)
splice load-path))))
((member argi '("-l" "-load")) ((member argi '("-l" "-load"))
(let* ((file (command-line-normalize-file-name (let* ((file (command-line-normalize-file-name
...@@ -1642,10 +1649,6 @@ normal otherwise." ...@@ -1642,10 +1649,6 @@ normal otherwise."
(move-to-column (1- column))) (move-to-column (1- column)))
(setq column 0)))))))) (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, ;; If 3 or more files visited, and not all visible,
;; show user what they all are. But leave the last one current. ;; show user what they all are. But leave the last one current.
(and (> file-count 2) (and (> file-count 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment