(liece-clfns-subr-fboundp): New macro.
(last,member-if,member-if-not,delete-if,remove-if,remove-if-not,
assoc-if,rassoc-if): Use it.
* liece-inlines.el (string-list-member-ignore-case): Use
`member-ignore-case'.
(string-list-remove-ignore-case): Use remq.
(string-list-member): Abolish.
(string-list-delete-ignore-case): Use delq.
(string-equal-ignore-case): Use `compare-strings' if available.
+2000-09-03 Daiki Ueno <ueno@unixuser.org>
+
+
+ * liece-clfns.el: Require `pym'.
+ (liece-clfns-subr-fboundp): New macro.
+ (last,member-if,member-if-not,delete-if,remove-if,remove-if-not,
+ assoc-if,rassoc-if): Use it.
+
+ * liece-inlines.el (string-list-member-ignore-case): Use
+ `member-ignore-case'.
+ (string-list-remove-ignore-case): Use remq.
+ (string-list-member): Abolish.
+ (string-list-delete-ignore-case): Use delq.
+ (string-equal-ignore-case): Use `compare-strings' if available.
+
2000-09-01 Daiki Ueno <ueno@unixuser.org>
* liece-channel.el (liece-channel-change): Handle
;;; Code:
+(require 'pym)
+
+(defmacro liece-clfns-subr-fboundp (symbol)
+ "Return t if SYMBOL's function definition is a basic function."
+ (or (subr-fboundp symbol)
+ (string-equal (symbol-file symbol) "subr")))
+
(if (featurep 'xemacs)
nil
(require 'cl)
(define-compiler-macro last (&whole form x &optional n)
- (if (and (fboundp 'last)
- (subrp (symbol-function 'last)))
+ (if (liece-clfns-subr-fboundp 'last)
form
(if n
`(let* ((x ,x) (n ,n) (m 0) (p x))
x))))
(define-compiler-macro member-if (&whole form pred list)
- (if (and (fboundp 'member-if)
- (subrp (symbol-function 'member-if)))
+ (if (liece-clfns-subr-fboundp 'member-if)
form
`(let ((fn ,pred)
(seq ,list))
seq)))
(define-compiler-macro member-if-not (&whole form pred list)
- (if (and (fboundp 'member-if-not)
- (subrp (symbol-function 'member-if-not)))
+ (if (liece-clfns-subr-fboundp 'member-if-not)
form
`(let ((fn ,pred)
(seq ,list))
seq)))
(define-compiler-macro delete-if (&whole form pred list)
- (if (and (fboundp 'delete-if)
- (subrp (symbol-function 'delete-if)))
+ (if (liece-clfns-subr-fboundp 'delete-if)
form
`(let* ((fn ,pred) (seq ,list) (p seq))
(while (and p (not (funcall fn (car p))))
(if p (delq (car p) seq)))))
(define-compiler-macro remove-if (&whole form pred list)
- (if (and (fboundp 'remove-if)
- (subrp (symbol-function 'remove-if)))
+ (if (liece-clfns-subr-fboundp 'remove-if)
form
`(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
(while (and p (not (funcall fn (car p))))
(if p (delq (car p) seq) seq))))
(define-compiler-macro remove-if-not (&whole form pred list)
- (if (and (fboundp 'remove-if-not)
- (subrp (symbol-function 'remove-if-not)))
+ (if (liece-clfns-subr-fboundp 'remove-if-not)
form
`(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
(while (and p (funcall fn (car p)))
(if p (delq (car p) seq) seq))))
(define-compiler-macro assoc-if (&whole form pred list)
- (if (and (fboundp 'assoc-if)
- (subrp (symbol-function 'assoc-if)))
+ (if (liece-clfns-subr-fboundp 'assoc-if)
form
`(let ((fn ,pred) (seq ,list))
(while (and seq (not (funcall fn (caar seq))))
(car seq))))
(define-compiler-macro rassoc-if (&whole form pred list)
- (if (and (fboundp 'rassoc-if)
- (subrp (symbol-function 'rassoc-if)))
+ (if (liece-clfns-subr-fboundp 'rassoc-if)
form
`(let ((fn ,pred) (seq ,list))
(while (and seq (not (funcall fn (cdar seq))))
(defmacro string-join (strlst &optional del)
`(mapconcat #'identity ,strlst ,del))
-(defsubst string-equal-ignore-case (s1 s2)
- (string-equal (upcase s1) (upcase s2)))
-
-(defsubst string-list-member-ignore-case (thing list)
- "Returns t if thing is member of list, not funcallable"
- (member-if
- (lambda (item)
- (and (stringp item) (string-equal-ignore-case thing item)))
- list))
-
-(defsubst string-list-member (thing list)
- "Returns t if thing is member of list, not funcallable"
- (member-if
- (lambda (item)
- (and (stringp item) (string-equal thing item)))
- list))
+(static-if (subr-fboundp 'compare-strings)
+ (defmacro string-equal-ignore-case (s1 s2)
+ `(compare-strings ,s1 0 nil ,s2 0 nil 'ignore-case))
+ (defmacro string-equal-ignore-case (s1 s2)
+ (string-equal (upcase ,s1) (upcase ,s2))))
+
+(static-if (fboundp 'member-ignore-case)
+ (defalias 'string-list-member-ignore-case
+ 'member-ignore-case)
+ (defsubst string-list-member-ignore-case (thing list)
+ "Returns t if thing is member of list, not funcallable"
+ (member-if
+ (lambda (item)
+ (and (stringp item) (string-equal-ignore-case thing item)))
+ list)))
(defsubst string-list-remove-ignore-case (thing list)
- (remove-if
- (lambda (item)
- (and (stringp item) (string-equal-ignore-case item thing)))
- list))
+ (let ((element (string-list-member-ignore-case thing list)))
+ (if element
+ (remq element list)
+ list)))
(defsubst string-list-delete-ignore-case (thing list)
- (delete-if
- (lambda (item)
- (and (stringp item) (string-equal-ignore-case item thing)))
- list))
+ (let ((element (string-list-delete-ignore-case thing list)))
+ (if element
+ (delq element list)
+ list)))
(defsubst string-list-remove (thing list)
- (remove-if
- (lambda (item)
- (and (stringp item) (string-equal item thing)))
- list))
+ (let ((element (member thing list)))
+ (if element
+ (remq element list)
+ list)))
(defsubst string-list-delete (thing list)
- (delete-if
- (lambda (item)
- (and (stringp item) (string-equal item thing)))
- list))
+ (let ((element (member thing list)))
+ (if element
+ (delq element list)
+ list)))
(defsubst string-list-modify-ignore-case (modifiers list)
(dolist (modifier modifiers)
(setq p (cdr p)))))
list)
-(defsubst string-assoc-ignore-case (key list)
- (assoc-if
- (lambda (item) (string-equal-ignore-case item key))
- list))
+(static-if (fboundp 'assoc-ignore-case)
+ (defalias 'string-assoc-ignore-case 'assoc-ignore-case)
+ (defsubst string-assoc-ignore-case (key list)
+ (assoc-if
+ (lambda (item) (string-equal-ignore-case item key))
+ list)))
(defsubst regexp-assoc-ignore-case (key list)
"Assoc with REGEXP-KEY from LIST."