From: Jackson Ray Hamilton Date: Sat, 20 Jun 2015 11:41:04 +0000 (-0700) Subject: Use old advice for Emacs 24.3. X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/f0bc797b6c5c2b297fc981ab943cfb5696065dc1 Use old advice for Emacs 24.3. --- diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index 272ee1de3..c84ae6721 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -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)