branch: externals/yaml commit b0d95e7e815a59ec099b16d036c65339d8b065a6 Author: Jake Shilling <shilling.j...@gmail.com> Commit: Jake Shilling <shilling.j...@gmail.com>
Use `alist-get` to converting alist to hash table Using `seq-map` to iterate over an alist an inserting the car-cdr-pair as each came ends up calling `puthash` for each cons in order; however, the idiomatic way to override previous entries in an alist is to insert a new entry for a key earlier in the list. Calling `puthash` in order causes the opposite behavior and ends up using the last value for each key instead of the first. This uses `alist-get` to grab the value for each key instead of assuming that the value should be the same as the current cdr, so that the resulting hash table key-value mappings as the original alist. --- yaml.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yaml.el b/yaml.el index 835efab913..8fe332b1a4 100644 --- a/yaml.el +++ b/yaml.el @@ -2429,8 +2429,8 @@ auto-detecting the indentation. Functionality defers to (when (and (listp l) (seq-every-p (lambda (x) (and (consp x) (atom (car x)))) l)) (let ((h (make-hash-table))) (seq-map (lambda (cpair) - (let ((k (car cpair)) - (v (cdr cpair))) + (let* ((k (car cpair)) + (v (alist-get k l))) (puthash k v h))) l) h)))