1

I'm using completing-read to get an argument for an interactive command. The argument is a non-intuitive word (required for my application), so the completion list looks like this:

Possible completions are:
faz   foo   bar   baz

I'd like it to also show some help, something like this:

Possible completions are:
faz   Pogo quote part 2
foo   Regular fubar
bar   All the soap
baz   Pogo quote part 1

Is there a straight-forward way to accomplish this, or something similar?

1 Answer 1

1

I don't know about "straight-forward", but you can do it as follows:

(let* ((comps '(("faz" "Pogo quote part 2")
                ("foo" "Regular fubar")
                ...))
       (completion-extra-properties
        `(:annotation-function
          ,(lambda (s) (format "  %s" (cadr (assoc s comps)))))))
  (completing-read "Prompt: " comps))
1
  • Excellent, thanks!
    – John H.
    Commented Sep 11, 2020 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.