[STUMP] :require-match for completions on alists
Eric Abrahamsen <[email protected]>
| Newsgroups | gmane.comp.window-managers.stumpwm.devel |
|---|---|
| Message-ID | <[email protected]> |
Also...
Using an alist for the completions argument to completing-read is
supported, but not if you use the :require-match key. Ie this works:
(completing-read (current-screen) "Pick a direction: "
'(("up" :up) ("down" :down)))
but not this:
(completing-read (current-screen) "Pick a direction: "
'(("up" :up) ("down" :down))
:require-match t)
The attached patch lets :require-match handle alist values correctly.
Eric
_______________________________________________
Stumpwm-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
0002-Improve-completing-read-s-handling-of-completions.patch
(text/x-diff, 1.1 KB)
From f49f1163276ba4898f9b74ad6bab10e01d6e3a0b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen <[email protected]> Date: Fri, 21 Mar 2014 10:56:40 +0800 Subject: [PATCH 2/2] Improve completing-read's handling of completions Using an alist for completions is supported, but did not work properly with the :require-match key, this fixes that --- input.lisp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/input.lisp b/input.lisp index 4f7cf6a..0daf925 100644 --- a/input.lisp +++ b/input.lisp @@ -214,7 +214,9 @@ match with an element of the completions." (let* ((in (string-trim " " (input-line-string input))) (compls (input-find-completions in *input-completions*))) (and (consp compls) - (string= in (car compls))))) + (string= in (if (consp (car compls)) + (caar compls) + (car compls)))))) (key-loop () (loop for key = (read-key-or-selection) do (cond ((stringp key) -- 1.9.1