emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114286: * lisp/eshell/esh-cmd.el (eshell--local-var


From: Glenn Morris
Subject: [Emacs-diffs] trunk r114286: * lisp/eshell/esh-cmd.el (eshell--local-vars): New variable.
Date: Sun, 15 Sep 2013 00:10:50 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114286
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/15372
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Sat 2013-09-14 17:10:45 -0700
message:
  * lisp/eshell/esh-cmd.el (eshell--local-vars): New variable. 
  (eshell-rewrite-for-command): Add for loop vars to eshell--local-vars.
  
  * lisp/eshell/esh-var.el (eshell-get-variable): Respect eshell--local-vars.
  
  * test/automated/eshell.el (eshell-test/for-name-shadow-loop):
  New test.
  (eshell-test/for-loop, eshell-test/for-name-loop): Doc fix.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/eshell/esh-cmd.el         eshcmd.el-20091113204419-o5vbwnq5f7feedwu-1850
  lisp/eshell/esh-var.el         eshvar.el-20091113204419-o5vbwnq5f7feedwu-1877
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/eshell.el       eshtest.el-20091113204419-o5vbwnq5f7feedwu-1875
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-09-14 23:55:15 +0000
+++ b/lisp/ChangeLog    2013-09-15 00:10:45 +0000
@@ -1,3 +1,9 @@
+2013-09-15  Glenn Morris  <address@hidden>
+
+       * eshell/esh-cmd.el (eshell--local-vars): New variable.  (Bug#15372)
+       (eshell-rewrite-for-command): Add for loop vars to eshell--local-vars.
+       * eshell/esh-var.el (eshell-get-variable): Respect eshell--local-vars.
+
 2013-09-14  Glenn Morris  <address@hidden>
 
        * eshell/esh-var.el (eshell-variable-aliases-list): Fix doc typo.

=== modified file 'lisp/eshell/esh-cmd.el'
--- a/lisp/eshell/esh-cmd.el    2013-09-12 20:15:53 +0000
+++ b/lisp/eshell/esh-cmd.el    2013-09-15 00:10:45 +0000
@@ -473,6 +473,8 @@
     arg))
 
 (defvar eshell-last-command-status)     ;Define in esh-io.el.
+(defvar eshell--local-vars nil
+  "List of locally bound vars that should take precedence over env-vars.")
 
 (defun eshell-rewrite-for-command (terms)
   "Rewrite a `for' command into its equivalent Eshell command form.
@@ -495,7 +497,9 @@
               (eshell-command-body '(nil))
                (eshell-test-body '(nil)))
           (while (car for-items)
-            (let ((,(intern (cadr terms)) (car for-items)))
+            (let ((,(intern (cadr terms)) (car for-items))
+                  (eshell--local-vars (cons ',(intern (cadr terms))
+                                           eshell--local-vars)))
               (eshell-protect
                ,(eshell-invokify-arg body t)))
             (setcar for-items (cadr for-items))

=== modified file 'lisp/eshell/esh-var.el'
--- a/lisp/eshell/esh-var.el    2013-09-14 23:55:15 +0000
+++ b/lisp/eshell/esh-var.el    2013-09-15 00:10:45 +0000
@@ -502,6 +502,7 @@
         (let ((sym (intern-soft var)))
           (if (and sym (boundp sym)
                    (or eshell-prefer-lisp-variables
+                       (memq sym eshell--local-vars) ; bug#15372
                        (not (getenv var))))
               (symbol-value sym)
             (getenv var))))

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2013-09-13 17:13:52 +0000
+++ b/test/ChangeLog    2013-09-15 00:10:45 +0000
@@ -1,3 +1,9 @@
+2013-09-15  Glenn Morris  <address@hidden>
+
+       * automated/eshell.el (eshell-test/for-name-shadow-loop):
+       New test.  (Bug#15372)
+       (eshell-test/for-loop, eshell-test/for-name-loop): Doc fix.
+
 2013-09-13  Glenn Morris  <address@hidden>
 
        * automated/eshell.el (with-temp-eshell):

=== modified file 'test/automated/eshell.el'
--- a/test/automated/eshell.el  2013-09-13 17:13:52 +0000
+++ b/test/automated/eshell.el  2013-09-15 00:10:45 +0000
@@ -75,17 +75,23 @@
   (should (equal (eshell-test-command-result "(+ 1 2)") 3)))
 
 (ert-deftest eshell-test/for-loop ()
-  "Test `eshell-command-result' with an elisp command."
+  "Test `eshell-command-result' with a for loop.."
   (let ((process-environment (cons "foo" process-environment)))
     (should (equal (eshell-test-command-result
                     "for foo in 5 { echo $foo }") 5))))
 
 (ert-deftest eshell-test/for-name-loop () ;Bug#15231
-  "Test `eshell-command-result' with an elisp command."
+  "Test `eshell-command-result' with a for loop using `name'."
   (let ((process-environment (cons "name" process-environment)))
     (should (equal (eshell-test-command-result
                     "for name in 3 { echo $name }") 3))))
 
+(ert-deftest eshell-test/for-name-shadow-loop () ; bug#15372
+  "Test `eshell-command-result' with a for loop using an env-var."
+  (let ((process-environment (cons "name=env-value" process-environment)))
+    (should (equal (eshell-test-command-result
+                    "for name in 3 { echo $name }") 3))))
+
 (ert-deftest eshell-test/lisp-command-args ()
   "Test `eshell-command-result' with elisp and trailing args.
 Test that trailing arguments outside the S-expression are


reply via email to

[Prev in Thread] Current Thread [Next in Thread]