5aa21c941482f961b6d4ce55d502dc556195cdb4
[riece] / lisp / riece-inlines.el
1 ;;; riece-inlines.el --- inline functions
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece
7
8 ;; This file is part of Riece.
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;;; Code:
26
27 (defsubst string-equal-ignore-case (s1 s2)
28   (string-equal (upcase s1) (upcase s2)))
29
30 (defsubst string-list-member-ignore-case (thing list)
31   "Returns t if thing is member of list, not funcallable"
32   (catch 'found
33     (while list
34       (if (and (stringp (car list))
35                (string-equal-ignore-case (car list) thing))
36           (throw 'found list)
37         (setq list (cdr list))))))
38
39 (defsubst string-list-delete-ignore-case (thing list)
40   (let ((pointer (string-list-member-ignore-case thing list)))
41     (if pointer
42         (delq (car pointer) list)
43       list)))
44
45 (defsubst string-list-delete (thing list)
46   (let ((pointer (member thing list)))
47     (if pointer
48         (delq (car pointer) list)
49       list)))
50
51 (defsubst string-list-modify-ignore-case (modifiers list)
52   (while modifiers
53     (let ((pointer (string-list-member-ignore-case
54                     (car (car modifiers)) list)))
55       (if pointer
56           (setcar pointer (cdr (car modifiers))))
57       (setq modifiers (cdr modifiers)))))
58
59 (defsubst string-assoc-ignore-case (key list)
60   (catch 'found
61     (while list
62       (if (and (car-safe (car list))
63                (string-equal-ignore-case key (car (car list))))
64           (throw 'found (car list))
65         (setq list (cdr list))))))
66
67 (provide 'riece-inlines)
68
69 ;;; riece-inlines.el ends here