diff options
| author | Richard M. Stallman | 1998-04-29 20:33:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-29 20:33:11 +0000 |
| commit | 9f0f00d759e6752448520344f85ff0440e4b2351 (patch) | |
| tree | be4149b397c036b90e4ce4736ec4ad53b726308f | |
| parent | 201d8c78ac2d25d339781927fe767684c144cfe3 (diff) | |
| download | emacs-9f0f00d759e6752448520344f85ff0440e4b2351.tar.gz emacs-9f0f00d759e6752448520344f85ff0440e4b2351.zip | |
(assoc-ignore-representation): New function.
(assoc-ignore-case): Use compare-strings.
| -rw-r--r-- | lisp/simple.el | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 1f547861886..2b9e0266020 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -3425,11 +3425,23 @@ The properties used on SYMBOL are `composefunc', `sendfunc', | |||
| 3425 | (put symbol 'hookvar (or hookvar 'mail-send-hook))) | 3425 | (put symbol 'hookvar (or hookvar 'mail-send-hook))) |
| 3426 | 3426 | ||
| 3427 | (defun assoc-ignore-case (key alist) | 3427 | (defun assoc-ignore-case (key alist) |
| 3428 | "Like `assoc', but assumes KEY is a string and ignores case when comparing." | 3428 | "Like `assoc', but ignores differences in case and text representation. |
| 3429 | (setq key (downcase key)) | 3429 | KEY must be a string. Upper-case and lower-case letters are treated as equal. |
| 3430 | Unibyte strings are converted to multibyte for comparison." | ||
| 3430 | (let (element) | 3431 | (let (element) |
| 3431 | (while (and alist (not element)) | 3432 | (while (and alist (not element)) |
| 3432 | (if (equal key (downcase (car (car alist)))) | 3433 | (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil t)) |
| 3434 | (setq element (car alist))) | ||
| 3435 | (setq alist (cdr alist))) | ||
| 3436 | element)) | ||
| 3437 | |||
| 3438 | (defun assoc-ignore-representation (key alist) | ||
| 3439 | "Like `assoc', but ignores differences in text representation. | ||
| 3440 | KEY must be a string. | ||
| 3441 | Unibyte strings are converted to multibyte for comparison." | ||
| 3442 | (let (element) | ||
| 3443 | (while (and alist (not element)) | ||
| 3444 | (if (eq t (compare-strings key 0 nil (car (car alist)) 0 nil)) | ||
| 3433 | (setq element (car alist))) | 3445 | (setq element (car alist))) |
| 3434 | (setq alist (cdr alist))) | 3446 | (setq alist (cdr alist))) |
| 3435 | element)) | 3447 | element)) |