emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 8e84383: * lisp/subr.el (when): Use `macroexp-progn


From: Artur Malabarba
Subject: [Emacs-diffs] master 8e84383: * lisp/subr.el (when): Use `macroexp-progn'
Date: Wed, 04 Nov 2015 12:56:47 +0000

branch: master
commit 8e843831eaf271801836b7a3e4dd3b4fb0bb72b8
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    * lisp/subr.el (when): Use `macroexp-progn'
    
    * test/automated/subr-tests.el (subr-test-when): New test
---
 lisp/subr.el                 |    2 +-
 test/automated/subr-tests.el |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index ea926ae..91647a6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -179,7 +179,7 @@ value of last one, or nil if there are none.
 
 \(fn COND BODY...)"
   (declare (indent 1) (debug t))
-  (list 'if cond (cons 'progn body)))
+  (list 'if cond (macroexp-progn body)))
 
 (defmacro unless (cond &rest body)
   "If COND yields nil, do BODY, else return nil.
diff --git a/test/automated/subr-tests.el b/test/automated/subr-tests.el
index 28a423f..85d5d11 100644
--- a/test/automated/subr-tests.el
+++ b/test/automated/subr-tests.el
@@ -82,5 +82,19 @@
   (should (string-greaterp 'acb 'abc))
   (should (string-greaterp "acb" 'abc)))
 
+(ert-deftest subr-test-when ()
+  (should (equal (when t 1) 1))
+  (should (equal (when t 2) 2))
+  (should (equal (when nil 1) nil))
+  (should (equal (when nil 2) nil))
+  (should (equal (when t 'x 1) 1))
+  (should (equal (when t 'x 2) 2))
+  (should (equal (when nil 'x 1) nil))
+  (should (equal (when nil 'x 2) nil))
+  (should (equal (macroexpand-all '(when a b))
+                 '(if a b)))
+  (should (equal (macroexpand-all '(when a b c d))
+                 '(if a (progn b c d)))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here



reply via email to

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