help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: completing-read() with explanations of the possible alternatives


From: Drew Adams
Subject: RE: completing-read() with explanations of the possible alternatives
Date: Fri, 30 May 2008 10:05:51 -0700

> I would like to extend completing-read() and completing-read-
> multiple() in such a way that I get extra help for the alternatives
> that are provided in the TABLE argument.
> 
> I thought that completing-read() would give this functionality by
> default as the documentation for it says:
>         "TABLE is an alist whose elements' cars are strings, or an
>          obarray."
> I thought that the car was what displayed during completing-read() and
> its corresponding cdr's were gathered in the return value.
> 
> But I only return the cars of these elements. Is it meant to be this
> way? Should I perform the lookup of crds by using the return value of
> completing-read(). If so how do I accomplish that for the different
> possible TABLE types.
> 
> Example:
> I want the interface for my completing-read-function to list the
> alternatives something like this (preferrablly with vector or list in
> font-lock-type-face and explanations in font-lock-comment-face)
> - vector - Vector Container is ...
> - list - List Container is ...
> and return for example in the form '("vector")

Hi Per,

Yes, `completing-read' returns only the car, not the entire alist element.

You can then look up the cdr separately, of course. However, if you have
duplicate elements, then something like `assoc' will give you only the first
such, which might not be what you want. There are various ways you can work
around this, all of which are, well, workarounds.

Since you are an Icicles user, you can find various examples in the Icicles code
of dealing with this. Mail me off list if you want to discuss specifics.

However, if all you want to do is add extra help, then you should be able to use
annotations. See the doc for `display-completion-list'. In Icicles, you can
instead use multi-completions - see
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Programming_Multi-Completions
for how to use multi-completions in Emacs Lisp, and see 
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Multi-Completions for the user
point of view. The second page also provides a comparison with
`completing-read-multiple'.

HTH.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]