1 ;;; liece-clfns.el --- compiler macros for emulating cl functions
2 ;; Copyright (C) 1998-2000 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: cl, compile
8 ;; This file is part of Liece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;; This file is borrowed from `gnus-clfns.el' from T-gnus.
29 ;; Avoid cl runtime functions for FSF Emacsen.
33 (defun liece-clfns-subr-fboundp (symbol)
34 "Return t if SYMBOL's function definition is a basic function."
36 (or (subrp (symbol-function symbol))
37 (string-equal (symbol-file symbol) "subr"))))
39 (if (featurep 'xemacs)
43 (define-compiler-macro last (&whole form x &optional n)
44 (if (liece-clfns-subr-fboundp 'last)
47 `(let* ((x ,x) (n ,n) (m 0) (p x))
57 (while (consp (cdr x))
61 (define-compiler-macro remq (&whole form elt list)
62 (if (liece-clfns-subr-fboundp 'remq)
67 (delq elt (copy-sequence list))
70 (define-compiler-macro member-if (&whole form pred list)
71 (if (liece-clfns-subr-fboundp 'member-if)
75 (while (and seq (not (funcall fn (car seq))))
79 (define-compiler-macro member-if-not (&whole form pred list)
80 (if (liece-clfns-subr-fboundp 'member-if-not)
84 (while (and seq (funcall fn (car seq)))
88 (define-compiler-macro delete-if (&whole form pred list)
89 (if (liece-clfns-subr-fboundp 'delete-if)
91 `(let* ((fn ,pred) (seq ,list) (p seq))
92 (while (and p (not (funcall fn (car p))))
94 (if p (delq (car p) seq)))))
96 (define-compiler-macro remove-if (&whole form pred list)
97 (if (liece-clfns-subr-fboundp 'remove-if)
99 `(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
100 (while (and p (not (funcall fn (car p))))
102 (if p (delq (car p) seq) seq))))
104 (define-compiler-macro remove-if-not (&whole form pred list)
105 (if (liece-clfns-subr-fboundp 'remove-if-not)
107 `(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
108 (while (and p (funcall fn (car p)))
110 (if p (delq (car p) seq) seq))))
112 (define-compiler-macro assoc-if (&whole form pred list)
113 (if (liece-clfns-subr-fboundp 'assoc-if)
115 `(let ((fn ,pred) (seq ,list))
116 (while (and seq (not (funcall fn (caar seq))))
120 (define-compiler-macro rassoc-if (&whole form pred list)
121 (if (liece-clfns-subr-fboundp 'rassoc-if)
123 `(let ((fn ,pred) (seq ,list))
124 (while (and seq (not (funcall fn (cdar seq))))
128 (provide 'liece-clfns)
130 ;;; liece-clfns.el ends here