From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Stefan Kangas <stefan@marxist.se>
Cc: 44205@debbugs.gnu.org
Subject: bug#44205: [PATCH] Add new function seq-remove-item
Date: Tue, 27 Oct 2020 13:45:46 +0000 [thread overview]
Message-ID: <87blgnvl2t.fsf@tcd.ie> (raw)
In-Reply-To: <CADwFkmnygDtrTEHqWVJ1watMswR8NPy_XAioa5rh8bKNyqbMeA@mail.gmail.com> (Stefan Kangas's message of "Sat, 24 Oct 2020 17:52:04 -0700")
Stefan Kangas <stefan@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
prev parent reply other threads:[~2020-10-27 13:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-25 0:52 bug#44205: [PATCH] Add new function seq-remove-item Stefan Kangas
2020-10-25 12:49 ` Lars Ingebrigtsen
2020-10-27 13:36 ` Basil L. Contovounesios
2020-11-13 0:07 ` Stefan Kangas
2020-11-18 17:17 ` Stefan Kangas
2020-10-25 16:25 ` Unknown
2020-10-25 19:12 ` Juri Linkov
2020-10-27 13:45 ` Basil L. Contovounesios [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87blgnvl2t.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=44205@debbugs.gnu.org \
--cc=stefan@marxist.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).