unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nordlöw <per.nordlow@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: completing-read() on list of vectors
Date: Fri, 12 Sep 2008 03:30:53 -0700 (PDT)	[thread overview]
Message-ID: <728990ea-9650-49dc-b4c3-4f9578856039@8g2000hse.googlegroups.com> (raw)

If I have the following association list (alist):

(defvar c++-stl-algorithms
  '(
    ("adjacent_difference" "<numeric>" "Compute the differences
between adjacent elements in a range")
    ("adjacent_find" "<algorithm>" "Finds two items that are adjacent
to eachother")
  ))

how can I modify the use of completing-read() to make the function

(defun read-c++-stl-algorithm ()
  (let* ((sym (thing-at-point 'symbol))
         (cont (completing-read (concat "C++ STL Algorithm (default "
sym "): ")
                                c++-stl-algorithms nil t nil nil
sym)))
    (list cont)))

to instead work on this list of vectors:

(defvar c++-stl-algorithms
  '(
    ["adjacent_difference" "<numeric>" "Compute the differences
between adjacent elements in a range"]
    ["adjacent_find" "<algorithm>" "Finds two items that are adjacent
to eachother"]
  ))

I guess I need to give it an explicit completion function (as second
argument) to achieve lookups of list of vectors where for example
"accumulate" is used as key and the return value is the whole list
element (vector).

Why doesn't completing-read() already work on list of vectors where
first vector element is a string aswell?

Thanks in advance,
Nordlöw


             reply	other threads:[~2008-09-12 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 10:30 Nordlöw [this message]
2008-09-12 11:19 ` completing-read() on list of vectors Nordlöw
2008-09-12 17:58 ` Nikolaj Schumacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=728990ea-9650-49dc-b4c3-4f9578856039@8g2000hse.googlegroups.com \
    --to=per.nordlow@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).