From: Adam Porter <adam@alphapapa.net>
To: devel@hugot.nl
Cc: Emacs-devel@gnu.org
Subject: Re: Add seq-shuffle
Date: Sat, 14 Sep 2024 20:44:16 -0500 [thread overview]
Message-ID: <a52c96db-e0a0-4a3c-9661-eb45a923f610@alphapapa.net> (raw)
In-Reply-To: <86ldzuy8u4.fsf@hugot.nl>
Hi Hugo,
Thanks, this is a gap in functionality that should be filled.
FWIW, in my listen.el package on ELPA, I have this function, the
algorithm of which I copied from Chris Wellons's elfeed-shuffle function
in his Elfeed package (which he placed into the Public Domain).
(defun listen-queue-shuffle (queue)
"Shuffle QUEUE."
(interactive (list (listen-queue-complete)))
;; Copied from `elfeed-shuffle'.
(let* ((tracks (listen-queue-tracks queue))
(current-track (listen-queue-current queue))
n)
(when current-track
(cl-callf2 delete current-track tracks))
(setf n (length tracks))
;; Don't use dotimes result (bug#16206)
(dotimes (i n)
(cl-rotatef (elt tracks i) (elt tracks (+ i (cl-random (- n i))))))
(when current-track
(push current-track tracks))
(setf (listen-queue-tracks queue) tracks))
(listen-queue--update-buffer queue))
I haven't benchmarked it against the version you posted, but I know that
Chris did write it specifically for the sake of performance, so it would
probably be worth considering.
--Adam
next prev parent reply other threads:[~2024-09-15 1:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-14 7:48 Add seq-shuffle Hugo Thunnissen
2024-09-14 8:42 ` Philip Kaludercic
2024-09-16 5:08 ` Emanuel Berg
2024-09-16 19:17 ` Adam Porter
2024-09-17 4:09 ` Emanuel Berg
2024-09-17 18:37 ` Philip Kaludercic
2024-09-17 22:26 ` Adam Porter
2024-09-18 1:27 ` Emanuel Berg
2024-09-17 18:53 ` Yuri Khan
2024-09-15 1:44 ` Adam Porter [this message]
2024-09-15 6:27 ` Eli Zaretskii
2024-09-15 6:45 ` Adam Porter
2024-09-15 11:58 ` Stefan Kangas
2024-09-15 7:48 ` Hugo Thunnissen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a52c96db-e0a0-4a3c-9661-eb45a923f610@alphapapa.net \
--to=adam@alphapapa.net \
--cc=Emacs-devel@gnu.org \
--cc=devel@hugot.nl \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.