- `(let ((temp-args
- ,(if (memq ':preserve-args (cadr options))
- macro-args
- (list 'eshell-stringify-list
- (list 'eshell-flatten-list macro-args)))))
- (let ,(append (delq nil (mapcar (lambda (opt)
- (and (listp opt) (nth 3 opt)))
- (cadr options)))
- '(usage-msg last-value ext-command args))
- ;; FIXME: `options' ends up hiding some variable names under `quote',
- ;; which is incompatible with lexical scoping!!
- (eshell-do-opt ,name ,options (lambda () ,@body-forms)))))
+ `(let* ((temp-args
+ ,(if (memq ':preserve-args (cadr options))
+ macro-args
+ (list 'eshell-stringify-list
+ (list 'eshell-flatten-list macro-args))))
+ (processed-args (eshell--do-opts ,name ,options temp-args))
+ ,@(delete-dups
+ (delq nil (mapcar (lambda (opt)
+ (and (listp opt) (nth 3 opt)
+ `(,(nth 3 opt) (pop processed-args))))
+ ;; `options' is of the form (quote OPTS).
+ (cadr options))))
+ (args processed-args))
+ ,@body-forms))