Synch up with main trunk and following:
[elisp/wanderlust.git] / elmo / elmo-util.el
index 4f019e2..309a424 100644 (file)
@@ -948,6 +948,7 @@ the directory becomes empty after deletion."
 
 (defmacro elmo-get-hash-val (string hashtable)
   `(and (stringp ,string)
+       ,hashtable
        (let ((sym (intern-soft ,string ,hashtable)))
          (if (boundp sym)
              (symbol-value sym)))))
@@ -1264,7 +1265,6 @@ But if optional argument AUTO is non-nil, DEFAULT is returned."
     (y-or-n-p prompt)))
 
 (defun elmo-string-member (string slist)
-  "Return t if STRING is a member of the SLIST."
   (catch 'found
     (while slist
       (if (and (stringp (car slist))
@@ -1272,6 +1272,25 @@ But if optional argument AUTO is non-nil, DEFAULT is returned."
          (throw 'found t))
       (setq slist (cdr slist)))))
 
+(cond ((fboundp 'member-ignore-case)
+       (defalias 'elmo-string-member-ignore-case 'member-ignore-case))
+      ((fboundp 'compare-strings)
+       (defun elmo-string-member-ignore-case (elt list)
+        "Like `member', but ignores differences in case and text representation.
+ELT must be a string.  Upper-case and lower-case letters are treated as equal.
+Unibyte strings are converted to multibyte for comparison."
+        (while (and list (not (eq t (compare-strings elt 0 nil (car list) 0 nil t))))
+          (setq list (cdr list)))
+        list))
+      (t
+       (defun elmo-string-member-ignore-case (elt list)
+        "Like `member', but ignores differences in case and text representation.
+ELT must be a string.  Upper-case and lower-case letters are treated as equal."
+        (let ((str (downcase elt)))
+          (while (and list (not (string= str (downcase (car list)))))
+            (setq list (cdr list)))
+          list))))
+
 (defun elmo-string-match-member (str list &optional case-ignore)
   (let ((case-fold-search case-ignore))
     (catch 'member