all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* completing-read() with explanations of the possible alternatives
@ 2008-05-30 16:36 Nordlöw
  2008-05-30 17:05 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Nordlöw @ 2008-05-30 16:36 UTC (permalink / raw)
  To: help-gnu-emacs

Hi there!

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")

Thanks in advance,
Nordlöw


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: completing-read() with explanations of the possible alternatives
  2008-05-30 16:36 completing-read() with explanations of the possible alternatives Nordlöw
@ 2008-05-30 17:05 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2008-05-30 17:05 UTC (permalink / raw)
  To: 'Nordlöw', help-gnu-emacs

> 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-30 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-30 16:36 completing-read() with explanations of the possible alternatives Nordlöw
2008-05-30 17:05 ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.