1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-11 00:30:17 -08:00

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.
This commit is contained in:
Katsumi Yamaoka 2010-10-06 01:09:32 +00:00
parent a0ec382af2
commit 61c47336fe
6 changed files with 75 additions and 24 deletions

View file

@ -1,3 +1,16 @@
2010-10-06 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-util.el (gnus-remove-if): Allow hash table.
(gnus-remove-if-not): New function.
* gnus-art.el (gnus-mime-view-part-as-type)
* gnus-score.el (gnus-summary-score-effect)
* 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.
2010-10-05 Lars Magne Ingebrigtsen <larsi@gnus.org> 2010-10-05 Lars Magne Ingebrigtsen <larsi@gnus.org>
* shr.el (shr-render-td): Allow blank/missing <TD>s. * shr.el (shr-render-td): Allow blank/missing <TD>s.

View file

@ -5139,7 +5139,7 @@ available media-types."
(let ((default (gnus-mime-view-part-as-type-internal))) (let ((default (gnus-mime-view-part-as-type-internal)))
(gnus-completing-read (gnus-completing-read
"View as MIME type" "View as MIME type"
(remove-if-not pred (mailcap-mime-types)) (gnus-remove-if-not pred (mailcap-mime-types))
nil nil nil nil nil nil
(car default))))) (car default)))))
(gnus-article-check-buffer) (gnus-article-check-buffer)

View file

@ -2163,23 +2163,33 @@ be permanent."
(goto-char start))))) (goto-char start)))))
(defun gnus-group-completing-read (&optional prompt collection (defun gnus-group-completing-read (&optional prompt collection
require-match initial-input hist def) require-match initial-input hist
def)
"Read a group name with completion. Non-ASCII group names are allowed. "Read a group name with completion. Non-ASCII group names are allowed.
The arguments are the same as `completing-read' except that COLLECTION The arguments are the same as `completing-read' except that COLLECTION
and HIST default to `gnus-active-hashtb' and `gnus-group-history' and HIST default to `gnus-active-hashtb' and `gnus-group-history'
respectively if they are omitted." respectively if they are omitted. Regards COLLECTION as a hash table
(let* ((collection (or collection (or gnus-active-hashtb [0]))) if it is not a list."
(choices (mapcar (lambda (symbol) (or collection (setq collection gnus-active-hashtb))
(let ((group (symbol-name symbol))) (let (choices group)
(if (string-match "[^\000-\177]" group) (if (listp collection)
(gnus-group-decoded-name group) (dolist (symbol collection)
group))) (setq group (symbol-name symbol))
(remove-if-not 'symbolp collection))) (push (if (string-match "[^\000-\177]" group)
(group (gnus-group-decoded-name group)
(gnus-completing-read (or prompt "Group") choices group)
require-match initial-input choices))
(or hist 'gnus-group-history) (mapatoms (lambda (symbol)
def))) (setq group (symbol-name symbol))
(push (if (string-match "[^\000-\177]" group)
(gnus-group-decoded-name group)
group)
choices))
collection))
(setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
require-match initial-input
(or hist 'gnus-group-history)
def))
(if (symbol-value (intern-soft group collection)) (if (symbol-value (intern-soft group collection))
group group
(mm-encode-coding-string group (gnus-group-name-charset nil group))))) (mm-encode-coding-string group (gnus-group-name-charset nil group)))))

View file

@ -916,7 +916,7 @@ EXTRA is the possible non-standard header."
(interactive (list (gnus-completing-read "Header" (interactive (list (gnus-completing-read "Header"
(mapcar (mapcar
'car 'car
(remove-if-not (gnus-remove-if-not
(lambda (x) (fboundp (nth 2 x))) (lambda (x) (fboundp (nth 2 x)))
gnus-header-index)) gnus-header-index))
t) t)

View file

@ -11926,11 +11926,12 @@ save those articles instead."
((null split-name) ((null split-name)
(gnus-group-completing-read (gnus-group-completing-read
prom prom
(remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb) (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
nil prefix nil default)) nil prefix nil default))
((= 1 (length split-name)) ((= 1 (length split-name))
(gnus-group-completing-read (gnus-group-completing-read
prom (remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb) prom
(gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
nil prefix 'gnus-group-history (car split-name))) nil prefix 'gnus-group-history (car split-name)))
(t (t
(gnus-completing-read (gnus-completing-read

View file

@ -1307,13 +1307,40 @@ This function saves the current buffer."
(with-current-buffer gnus-group-buffer (with-current-buffer gnus-group-buffer
(eq major-mode 'gnus-group-mode)))) (eq major-mode 'gnus-group-mode))))
(defun gnus-remove-if (predicate list) (defun gnus-remove-if (predicate sequence &optional hash-table-p)
"Return a copy of LIST with all items satisfying PREDICATE removed." "Return a copy of SEQUENCE with all items satisfying PREDICATE removed.
SEQUENCE should be a list, a vector, or a string. Returns always a list.
If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table."
(let (out) (let (out)
(while list (if hash-table-p
(unless (funcall predicate (car list)) (mapatoms (lambda (symbol)
(push (car list) out)) (unless (funcall predicate symbol)
(setq list (cdr list))) (push symbol out)))
sequence)
(unless (listp sequence)
(setq sequence (append sequence nil)))
(while sequence
(unless (funcall predicate (car sequence))
(push (car sequence) out))
(setq sequence (cdr sequence))))
(nreverse out)))
(defun gnus-remove-if-not (predicate sequence &optional hash-table-p)
"Return a copy of SEQUENCE with all items not satisfying PREDICATE removed.
SEQUENCE should be a list, a vector, or a string. Returns always a list.
If HASH-TABLE-P is non-nil, regards SEQUENCE as a hash table."
(let (out)
(if hash-table-p
(mapatoms (lambda (symbol)
(when (funcall predicate symbol)
(push symbol out)))
sequence)
(unless (listp sequence)
(setq sequence (append sequence nil)))
(while sequence
(when (funcall predicate (car sequence))
(push (car sequence) out))
(setq sequence (cdr sequence))))
(nreverse out))) (nreverse out)))
(if (fboundp 'assq-delete-all) (if (fboundp 'assq-delete-all)