Mercurial > emacs
comparison lisp/gnus/gnus-util.el @ 110779:9d935b7bf464
Eliminate `remove-if-not' that is a cl function.
gnus-util.el (gnus-remove-if): Allow hash table.
gnus-util.el (gnus-remove-if-not): New function.
gnus-art.el (gnus-mime-view-part-as-type): Replace remove-if-not with gnus-remove-if-not.
gnus-score.el (gnus-summary-score-effect): Replace remove-if-not with gnus-remove-if-not.
gnus-sum.el (gnus-read-move-group-name): Replace remove-if-not with gnus-remove-if-not.
gnus-group.el (gnus-group-completing-read): Regard collection as a hash table if it is not a list.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Wed, 06 Oct 2010 01:09:32 +0000 |
parents | 22b487462b5a |
children | d2b45bb936b6 |
comparison
equal
deleted
inserted
replaced
110778:5a595f515d1c | 110779:9d935b7bf464 |
---|---|
1305 (and (boundp 'gnus-group-buffer) | 1305 (and (boundp 'gnus-group-buffer) |
1306 (get-buffer gnus-group-buffer) | 1306 (get-buffer gnus-group-buffer) |
1307 (with-current-buffer gnus-group-buffer | 1307 (with-current-buffer gnus-group-buffer |
1308 (eq major-mode 'gnus-group-mode)))) | 1308 (eq major-mode 'gnus-group-mode)))) |
1309 | 1309 |
1310 (defun gnus-remove-if (predicate list) | 1310 (defun gnus-remove-if (predicate sequence &optional hash-table-p) |
1311 "Return a copy of LIST with all items satisfying PREDICATE removed." | 1311 "Return a copy of SEQUENCE with all items satisfying PREDICATE removed. |
1312 SEQUENCE should be a list, a vector, or a string. Returns always a list. | |
1313 If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table." | |
1312 (let (out) | 1314 (let (out) |
1313 (while list | 1315 (if hash-table-p |
1314 (unless (funcall predicate (car list)) | 1316 (mapatoms (lambda (symbol) |
1315 (push (car list) out)) | 1317 (unless (funcall predicate symbol) |
1316 (setq list (cdr list))) | 1318 (push symbol out))) |
1319 sequence) | |
1320 (unless (listp sequence) | |
1321 (setq sequence (append sequence nil))) | |
1322 (while sequence | |
1323 (unless (funcall predicate (car sequence)) | |
1324 (push (car sequence) out)) | |
1325 (setq sequence (cdr sequence)))) | |
1326 (nreverse out))) | |
1327 | |
1328 (defun gnus-remove-if-not (predicate sequence &optional hash-table-p) | |
1329 "Return a copy of SEQUENCE with all items not satisfying PREDICATE removed. | |
1330 SEQUENCE should be a list, a vector, or a string. Returns always a list. | |
1331 If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table." | |
1332 (let (out) | |
1333 (if hash-table-p | |
1334 (mapatoms (lambda (symbol) | |
1335 (when (funcall predicate symbol) | |
1336 (push symbol out))) | |
1337 sequence) | |
1338 (unless (listp sequence) | |
1339 (setq sequence (append sequence nil))) | |
1340 (while sequence | |
1341 (when (funcall predicate (car sequence)) | |
1342 (push (car sequence) out)) | |
1343 (setq sequence (cdr sequence)))) | |
1317 (nreverse out))) | 1344 (nreverse out))) |
1318 | 1345 |
1319 (if (fboundp 'assq-delete-all) | 1346 (if (fboundp 'assq-delete-all) |
1320 (defalias 'gnus-delete-alist 'assq-delete-all) | 1347 (defalias 'gnus-delete-alist 'assq-delete-all) |
1321 (defun gnus-delete-alist (key alist) | 1348 (defun gnus-delete-alist (key alist) |