[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
some trivial simplifications of `command-line-1'
From: |
Matt Swift |
Subject: |
some trivial simplifications of `command-line-1' |
Date: |
Mon, 17 Feb 2003 19:39:49 -0500 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 |
Some trivial simplifications of `command-line-1'.
+ Each iteration of the `while' reset `extra-load-path' and
`initial-load-path', so they are unnecessary variables.
+ Why say in four lines what it is just as clear to say in one?
--- startup.el.~1.312.~ 2003-02-05 00:19:06.000000000 -0500
+++ startup.el 2003-02-17 19:27:46.000000000 -0500
@@ -1581,11 +1581,7 @@
(while (and command-line-args-left)
(let* ((argi (car command-line-args-left))
(orig-argi argi)
- argval completion
- ;; List of directories specified in -L/--directory,
- ;; in reverse of the order specified.
- extra-load-path
- (initial-load-path load-path))
+ argval completion)
(setq command-line-args-left (cdr command-line-args-left))
;; Do preliminary decoding of the option.
@@ -1623,50 +1619,32 @@
((member argi '("-f" ;what the manual claims
"-funcall"
"-e")) ; what the source used to say
- (if argval
- (setq tem (intern argval))
- (setq tem (intern (car command-line-args-left)))
- (setq command-line-args-left (cdr command-line-args-left)))
+ (setq tem (intern (or argval (pop command-line-args-left))))
(if (arrayp (symbol-function tem))
(command-execute tem)
(funcall tem)))
((member argi '("-eval" "-execute"))
- (if argval
- (setq tem argval)
- (setq tem (car command-line-args-left))
- (setq command-line-args-left (cdr command-line-args-left)))
- (eval (read tem)))
+ (eval (read (or argval (pop command-line-args-left)))))
;; Set the default directory as specified in -L.
((member argi '("-L" "-directory"))
- (if argval
- (setq tem argval)
- (setq tem (car command-line-args-left)
- command-line-args-left (cdr command-line-args-left)))
- (setq tem (command-line-normalize-file-name tem))
- (setq extra-load-path
- (cons (expand-file-name tem) extra-load-path))
- (setq load-path (append (nreverse extra-load-path)
- initial-load-path)))
+ (setq tem (or argval (pop command-line-args-left)))
+ (push
+ (expand-file-name (command-line-normalize-file-name tem))
+ load-path))
((member argi '("-l" "-load"))
- (if argval
- (setq tem argval)
- (setq tem (car command-line-args-left)
- command-line-args-left (cdr command-line-args-left)))
- (let ((file (command-line-normalize-file-name tem)))
- ;; Take file from default dir if it exists there;
- ;; otherwise let `load' search for it.
- (if (file-exists-p (expand-file-name file))
- (setq file (expand-file-name file)))
+ (let* ((file (command-line-normalize-file-name
+ (or argval (pop command-line-args-left))))
+ ;; Take file from default dir if it exists there;
+ ;; otherwise let `load' search for it.
+ (file-ex (expand-file-name file))
+ (file (and (file-exists-p file-ex) file-ex)))
(load file nil t)))
((string-equal argi "-insert")
- (if argval
- (setq tem argval)
- (setq tem (car command-line-args-left)
- command-line-args-left (cdr command-line-args-left)))
+ (setq tem (or argval (pop command-line-args-left)))
(or (stringp tem)
(error "File name omitted from `-insert' option"))
(insert-file-contents (command-line-normalize-file-name
tem)))
@@ -1688,10 +1666,7 @@
((member argi '("-find-file" "-file" "-visit"))
;; An explicit option to specify visiting a file.
- (if argval
- (setq tem argval)
- (setq tem (car command-line-args-left)
- command-line-args-left (cdr command-line-args-left)))
+ (setq tem (or argval (pop command-line-args-left)))
(unless (stringp tem)
(error "File name omitted from `%s' option" argi))
(setq file-count (1+ file-count))
@@ -1712,13 +1687,13 @@
(t
;; We have almost exhausted our options. See if the
;; user has made any other command-line options available
- (let ((hooks command-line-functions) ;; lrs 7/31/89
+ (let ((hooks command-line-functions) ;; lrs 7/31/89
(did-hook nil))
(while (and hooks
(not (setq did-hook (funcall (car hooks)))))
(setq hooks (cdr hooks)))
(if (not did-hook)
- ;; Ok, presume that the argument is a file name
+ ;; Ok, presume that the argument is a file name
(progn
(if (string-match "\\`-" argi)
(error "Unknown option `%s'" argi))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- some trivial simplifications of `command-line-1',
Matt Swift <=