(mapc): Add the compiler macro for Emacs 20.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 25 Nov 2003 04:18:57 +0000 (04:18 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 25 Nov 2003 04:18:57 +0000 (04:18 +0000)
lisp/ChangeLog
lisp/dgnushack.el

index 8716d80..dfa9f5f 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-25  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * dgnushack.el (mapc): Add the compiler macro for Emacs 20.
+
 2003-11-24  Kevin Greiner <kgreiner@xpediantsolutions.com>
        * gnus-srvr.el (gnus-server-insert-server-line): The server names
        used in gnus-agent are different (for example, the native server
index dc88a22..b505717 100644 (file)
   (define-compiler-macro remove (&whole form item seq)
     (if (>= emacs-major-version 21)
        form
-      `(delete ,item (copy-sequence ,seq)))))
+      `(delete ,item (copy-sequence ,seq))))
+
+  (define-compiler-macro mapc (&whole form fn seq &rest rest)
+    (if (>= emacs-major-version 21)
+       form
+      (if rest
+         `(let* ((fn ,fn)
+                 (seq ,seq)
+                 (args (list seq ,@rest))
+                 (m (apply (function min) (mapcar (function length) args)))
+                 (n 0))
+            (while (< n m)
+              (apply fn (mapcar (function (lambda (arg) (nth n arg))) args))
+              (setq n (1+ n)))
+            seq)
+       `(let ((seq ,seq))
+          (mapcar ,fn seq)
+          seq)))))
 
 ;; If we are building w3 in a different directory than the source
 ;; directory, we must read *.el from source directory and write *.elc