[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68863: Add support for using setf with seq-subseq
From: |
Eli Zaretskii |
Subject: |
bug#68863: Add support for using setf with seq-subseq |
Date: |
Thu, 08 Feb 2024 13:39:48 +0200 |
> Date: Thu, 01 Feb 2024 03:31:10 +0000
> From: Okamsn via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> This patch adds support for using `seq-subseq` with `setf`, as in
>
> ;; => [0 1 2 10 11]
> (let ((seq (vector 0 1 2 3 4)))
> (setf (seq-subseq seq -2) (list 10 11 12 13 14))
> seq)
>
> The patch adds a generic version which uses the existing `setf` support
> of `seq-elt` and a specialized version for modifying lists. Both
> versions use `seq-do` to map a function over the values that should
> replace the values in the modified sequence.
>
> To avoid modifying more values than specified, that modifying function
> uses a `when` condition. I'm not sure of a good way to stop `seq-do`
> early when we know that it can stop calling the modifying function.
> Normally, I would use `cl-block` and `cl-return`. Is it OK to use those
> features in `seq.el`? If not, is it worth adding something like a
> `seq-map-while` or a `seq-do-while`?
Thanks.
Nicolas, Stefan: any comments? seq.el is preloaded, so we should
consider whether this addition is important enough to have it in seq
or elsewhere, if we think it's useful.
- bug#68863: Add support for using setf with seq-subseq,
Eli Zaretskii <=