branch: elpa/logview commit 9f879fd2a2bd460e76d924a8dce1e410c3733626 Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Fix a byte-compilation warning in the last commit. --- test/logview.el | 65 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/test/logview.el b/test/logview.el index 5561f5f10f..b5224c882c 100644 --- a/test/logview.el +++ b/test/logview.el @@ -31,39 +31,40 @@ ;; Copied from Eldev source code, see documentation there. -(defmacro logview--advised (spec &rest body) - (declare (indent 1) (debug (sexp body))) - (let ((symbol (nth 0 spec)) - (where (nth 1 spec)) - (function (nth 2 spec)) - (props (nthcdr 3 spec)) - (fn (make-symbol "$fn"))) - `(let ((,fn ,function)) - (when ,fn - (if (advice-member-p ,fn ,symbol) - (setf ,fn nil) - (advice-add ,symbol ,where ,fn ,@props))) - (unwind-protect - ,(macroexp-progn body) +(eval-when-compile + (defmacro logview--advised (spec &rest body) + (declare (indent 1) (debug (sexp body))) + (let ((symbol (nth 0 spec)) + (where (nth 1 spec)) + (function (nth 2 spec)) + (props (nthcdr 3 spec)) + (fn (make-symbol "$fn"))) + `(let ((,fn ,function)) (when ,fn - (advice-remove ,symbol ,fn)))))) - -(defmacro logview-ert-defargtest (name arguments values &rest body) - (declare (indent 3)) - (let ((function (make-symbol (format "%s:impl" name)))) - `(progn - ;; Implementation of `skip-unless' is copied from Emacs source. - (cl-macrolet ((skip-unless (form) `(ert--skip-unless ,form))) - ;; Apparently we cannot get away with unnamed lambdas here. - (defun ,function ,arguments ,@body)) - ,@(mapcar (lambda (arg-values) - `(ert-deftest ,(intern (format "%s/%s" name (logview--ert-defargtest-format-arguments arg-values))) () - (,function ,@(if (= (length arguments) 1) (list arg-values) arg-values)))) - values)))) - -(defun logview--ert-defargtest-format-arguments (arguments) - (let ((print-quoted t)) - (downcase (replace-regexp-in-string " " "/" (replace-regexp-in-string (rx (not (any word "-" " "))) "" (prin1-to-string arguments)))))) + (if (advice-member-p ,fn ,symbol) + (setf ,fn nil) + (advice-add ,symbol ,where ,fn ,@props))) + (unwind-protect + ,(macroexp-progn body) + (when ,fn + (advice-remove ,symbol ,fn)))))) + + (defmacro logview-ert-defargtest (name arguments values &rest body) + (declare (indent 3)) + (let ((function (make-symbol (format "%s:impl" name)))) + `(progn + ;; Implementation of `skip-unless' is copied from Emacs source. + (cl-macrolet ((skip-unless (form) `(ert--skip-unless ,form))) + ;; Apparently we cannot get away with unnamed lambdas here. + (defun ,function ,arguments ,@body)) + ,@(mapcar (lambda (arg-values) + `(ert-deftest ,(intern (format "%s/%s" name (logview--ert-defargtest-format-arguments arg-values))) () + (,function ,@(if (= (length arguments) 1) (list arg-values) arg-values)))) + values)))) + + (defun logview--ert-defargtest-format-arguments (arguments) + (let ((print-quoted t)) + (downcase (replace-regexp-in-string " " "/" (replace-regexp-in-string (rx (not (any word "-" " "))) "" (prin1-to-string arguments))))))) (defmacro logview--test-with-restriction (start end locking-label &rest body)