Function: nrepl--bencode-dict
nrepl--bencode-dict is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl--bencode-dict DICT)
Documentation
Encode DICT with bencode.
According to the Bittorrent protocol specification[1], when bencoding dictionaries, keys must be strings and appear in sorted order (sorted as raw strings, not alphanumerics).
[1] https://www.bittorrent.org/beps/bep_0003.html#bencoding
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/nrepl-client.el
(defun nrepl--bencode-dict (dict)
"Encode DICT with bencode.
According to the Bittorrent protocol specification[1], when bencoding
dictionaries, keys must be strings and appear in sorted order (sorted as
raw strings, not alphanumerics).
[1] https://www.bittorrent.org/beps/bep_0003.html#bencoding"
(let* ((sorted-keys (sort (nrepl-dict-keys dict)
(lambda (a b)
(string< a b))))
(sorted-dict (nrepl-dict)))
(dolist (k sorted-keys sorted-dict)
(nrepl-dict-put sorted-dict
k
(nrepl-dict-get dict k)))
(mapconcat #'nrepl-bencode (cdr sorted-dict) "")))