1 ;;; gnus-clfns.el --- compiler macros for emulating cl functions
2 ;; Copyright (C) 2000 Free Software Foundation, Inc.
4 ;; Author: Kastsumi Yamaoka <yamaoka@jpl.org>
5 ;; Keywords: cl, compile
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 ;; Avoid cl runtime functions for FSF Emacsen.
30 (if (featurep 'xemacs)
34 (define-compiler-macro last (&whole form x &optional n)
35 (if (and (fboundp 'last)
36 (subrp (symbol-function 'last)))
52 (while (consp (cdr x))
56 (define-compiler-macro mapc (&whole form fn seq &rest rest)
57 (if (and (fboundp 'mapc)
58 (subrp (symbol-function 'mapc)))
63 (args (list seq ,@rest))
64 (m (apply (function min) (mapcar (function length) args)))
67 (apply fn (mapcar (function (lambda (arg) (nth n arg))) args))
74 (define-compiler-macro mapcon (&whole form fn seq &rest rest)
75 (if (and (fboundp 'mapcon)
76 (subrp (symbol-function 'mapcon)))
81 (args (list ,seq ,@rest))
83 (while (not (memq nil args))
84 (push (apply ,fn args) res)
87 (setcar p (cdr (pop p)))
89 (apply (function nconc) (nreverse res)))
94 (push (funcall ,fn arg) res)
96 (apply (function nconc) (nreverse res))))))
98 (define-compiler-macro member-if (&whole form pred list)
99 (if (and (fboundp 'member-if)
100 (subrp (symbol-function 'member-if)))
105 (not (funcall fn (car seq))))
109 (define-compiler-macro union (&whole form list1 list2)
110 (if (and (fboundp 'union)
111 (subrp (symbol-function 'union)))
119 (or (>= (length a) (length b))
120 (setq a (prog1 b (setq b a))))
128 (provide 'gnus-clfns)
130 ;;; gnus-clfns.el ends here