GNU bug report logs -
#44205
[PATCH] Add new function seq-remove-item
Previous Next
Reported by: Stefan Kangas <stefan <at> marxist.se>
Date: Sun, 25 Oct 2020 00:53:01 UTC
Severity: normal
Tags: patch, wontfix
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Stefan Kangas <stefan <at> marxist.se> writes:
> diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
> index 4656277ea1..82daae6f48 100644
> --- a/lisp/emacs-lisp/seq.el
> +++ b/lisp/emacs-lisp/seq.el
> @@ -331,6 +331,13 @@ seq-remove
> (seq-filter (lambda (elt) (not (funcall pred elt)))
> sequence))
>
> +;;;###autoload
> +(cl-defgeneric seq-remove-item (item sequence)
> + "Return a list of all the elements in SEQUENCE that are not ITEM.
> +The comparison is done using `equal'. "
> + (seq-filter (lambda (elt) (not (equal item elt)))
> + sequence))
Why not replace seq-filter with seq-remove and do away with the 'not'?
Is the indentation right here?
> ;;;###autoload
> (cl-defgeneric seq-reduce (function sequence initial-value)
> "Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE.
> diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el
> index acc7d13195..20cfd6e295 100644
> --- a/lisp/emacs-lisp/shortdoc.el
> +++ b/lisp/emacs-lisp/shortdoc.el
> @@ -730,6 +730,8 @@ sequence
> :eval (seq-filter #'numberp '(a b 3 4 f 6)))
> (seq-remove
> :eval (seq-remove #'numberp '(1 2 c d 5)))
> + (seq-remove-item
> + :eval (seq-remove-item 3 '(1 2 3 4 5)))
> (seq-group-by
> :eval (seq-group-by #'cl-plusp '(-1 2 3 -4 -5 6)))
> (seq-difference
> diff --git a/lisp/tab-line.el b/lisp/tab-line.el
> index 46bf89f14e..26f5f750b4 100644
> --- a/lisp/tab-line.el
> +++ b/lisp/tab-line.el
> @@ -385,11 +385,11 @@ tab-line-tabs-window-buffers
> variable `tab-line-tabs-function'."
> (let* ((window (selected-window))
> (buffer (window-buffer window))
> - (next-buffers (seq-remove (lambda (b) (eq b buffer))
> - (window-next-buffers window)))
> + (next-buffers (seq-remove-item buffer
> + (window-next-buffers window)))
> (next-buffers (seq-filter #'buffer-live-p next-buffers))
> - (prev-buffers (seq-remove (lambda (b) (eq b buffer))
> - (mapcar #'car (window-prev-buffers window))))
> + (prev-buffers (seq-remove-item buffer
> + (mapcar #'car (window-prev-buffers window))))
> (prev-buffers (seq-filter #'buffer-live-p prev-buffers))
> ;; Remove next-buffers from prev-buffers
> (prev-buffers (seq-difference prev-buffers next-buffers)))
> @@ -622,10 +622,10 @@ tab-line-select-tab
>
> (defun tab-line-select-tab-buffer (buffer &optional window)
> (let* ((window-buffer (window-buffer window))
> - (next-buffers (seq-remove (lambda (b) (eq b window-buffer))
> - (window-next-buffers window)))
> - (prev-buffers (seq-remove (lambda (b) (eq b window-buffer))
> - (mapcar #'car (window-prev-buffers window))))
> + (next-buffers (seq-remove-item window-buffer
> + (window-next-buffers window)))
> + (prev-buffers (seq-remove-item window-buffer
> + (mapcar #'car (window-prev-buffers window))))
As others have pointed out, these would be better served by remq, and/or
fusing multiple loops into a single one.
Thanks,
--
Basil
This bug report was last modified 4 years and 186 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.