]> code.delx.au - gnu-emacs-elpa/commitdiff
Use old advice for Emacs 24.3.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 20 Jun 2015 11:41:04 +0000 (04:41 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 20 Jun 2015 11:41:04 +0000 (04:41 -0700)
test/context-coloring-test.el

index 272ee1de3ffcb4f203993997690d01ce2a923cc4..c84ae67213dccacf4d11d604e2b39eacd246b348 100644 (file)
@@ -198,20 +198,29 @@ signaled."
   (let ((name (intern (format "context-coloring-test-%s-mode" name))))
     `(define-derived-mode ,name fundamental-mode "Testing")))
 
+(defvar context-coloring-test-caused-p nil
+  "Dumb flag tracking for lambdas inside old advice definitions
+which don't seem to have lexical binding.")
+
 (defmacro context-coloring-test-assert-causes-coloring (&rest body)
   "Assert that BODY causes coloring."
-  (let ((colorized-p (make-symbol "colorized-p")))
-    `(let (,colorized-p)
-       (advice-add #'context-coloring-colorize
-                   :after (lambda ()
-                            (setq ,colorized-p t))
-                   '((name . assert-causes-coloring)))
-       ,@body
-       (when (not ,colorized-p)
-         (ert-fail "Expected to have colorized, but it didn't.")))))
+  `(progn
+     ;; Gross, but I want this to pass on 24.3.
+     (ad-add-advice #'context-coloring-colorize
+                    '(assert-causes-coloring
+                      nil t
+                      (advice . (lambda ()
+                                  (setq context-coloring-test-caused-p t))))
+                    'after
+                    0)
+     (ad-activate #'context-coloring-colorize)
+     ,@body
+     (when (not context-coloring-test-caused-p)
+       (ert-fail "Expected to have colorized, but it didn't."))))
 
 (defun context-coloring-test-cleanup-assert-causes-coloring ()
-  (advice-remove #'context-coloring-colorize 'assert-causes-coloring))
+  (ad-unadvise #'context-coloring-colorize)
+  (setq context-coloring-test-caused-p nil))
 
 (context-coloring-test-define-derived-mode mode-startup)