Merge handling of lists and alists
The principal issue here is that a alist may contain non-cons-cells,
while a "regular" list shouldn't contain any. Given a cons-cell, it
would only be possible to decide this by traversing the list, before
processing it (or perhaps while processing it), until a cons-cell is
found (or not).
The approach taken here is to be flexible and interpret the a
cons-cell based collection as a sort of mix of both a alist and
regular list, matching both cons-cell entries and non-cons-cell string
or symbols. This is strictly speaking not correct (at least going by
functions like 'assoc'), but consistent with other completion styles:
(all-completions "f" '("foobar" "foobaz")) ;=> ("foobar" "foobaz")
(all-completions "f" '(("foobar" . 3) "foobaz")) ;=> ("foobar" "foobaz")
(all-completions "f" '("foobaz" ("foobar" . 3))) ;=> ("foobaz" "foobar")
Also note that this patch addresses the bug pointed out by Visuwesh in
[0], in that typo completion would raise an error when completing a
list containing symbols.
[0] https://lists.sr.ht/~pkal/public-inbox/%3C87pm4ywqus.fsf%40gmail.com%3E#%3C87pm4ywqus.fsf@gmail.com%3E