Function: with-argument-repetition

with-argument-repetition is a macro defined in combobulate-navigation.el.

Signature

(with-argument-repetition ARG &rest BODY)

Documentation

Repeats BODY an ARG number of times

This is designed to handle the prefix argument and negative modifier you can pass to many interactive movement commands.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-navigation.el
(defmacro with-argument-repetition (arg &rest body)
  "Repeats BODY an ARG number of times

This is designed to handle the prefix argument and negative
modifier you can pass to many interactive movement commands."
  (declare (indent 1) (debug (atom body)))
  (let ((--arg (gensym))
        (--inc (gensym))
        (--result (gensym)))
    `(let* ((,--arg (or ,arg 1))
            (,--inc (if (> ,--arg 0) 1 -1))
            (,--result))
       (while (/= ,--arg 0)
         (setq ,--result
               (prog1 (progn ,@body)
                 (setq ,--arg (- ,--arg ,--inc)))))
       ,--result)))