]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/esh-opt.el
Merge from emacs-24; up to 2012-05-08T15:19:18Z!monnier@iro.umontreal.ca
[gnu-emacs] / lisp / eshell / esh-opt.el
index 91d3cac198a4c9e278da85abe5b12bed68b77ab2..fed2d8f1c624acaededf3cad088c923abe563166 100644 (file)
@@ -1,6 +1,6 @@
 ;;; esh-opt.el --- command options processing
 
-;; Copyright (C) 1999-2011  Free Software Foundation, Inc.
+;; Copyright (C) 1999-2012  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -106,7 +106,9 @@ interned variable `args' (created using a `let' form)."
                                       (and (listp opt) (nth 3 opt)))
                                     (cadr options)))
                   '(usage-msg last-value ext-command args))
-       (eshell-do-opt ,name ,options (quote ,body-forms)))))
+       ;; FIXME: `options' ends up hiding some variable names under `quote',
+       ;; which is incompatible with lexical scoping!!
+       (eshell-do-opt ,name ,options (lambda () ,@body-forms)))))
 
 ;;; Internal Functions:
 
@@ -117,7 +119,7 @@ interned variable `args' (created using a `let' form)."
 ;; Documented part of the interface; see eshell-eval-using-options.
 (defvar args)
 
-(defun eshell-do-opt (name options body-forms)
+(defun eshell-do-opt (name options body-fun)
   "Helper function for `eshell-eval-using-options'.
 This code doesn't really need to be macro expanded everywhere."
   (setq args temp-args)
@@ -133,8 +135,7 @@ This code doesn't really need to be macro expanded everywhere."
                      (throw 'eshell-usage
                             (eshell-show-usage name options)))
                  (setq args (eshell-process-args name args options)
-                       last-value (eval (append (list 'progn)
-                                                body-forms)))
+                       last-value (funcall body-fun))
                  nil))
           (error "%s" usage-msg))))
       (throw 'eshell-external
@@ -218,10 +219,8 @@ switch is unrecognized."
         found)
     (while opts
       (if (and (listp (car opts))
-                (nth kind (car opts))
-                (if (= kind 0)
-                    (eq switch (nth kind (car opts)))
-                  (string= switch (nth kind (car opts)))))
+               (nth kind (car opts))
+               (equal switch (nth kind (car opts))))
          (progn
            (eshell-set-option name ai (car opts) options)
            (setq found t opts nil))