unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: RE: [External] : Use of an associated list with completing-read
Date: Fri, 19 Apr 2024 19:09:22 +0000	[thread overview]
Message-ID: <6IDPPDE6NaK72davfT7rnK8S553m9H8sBdCDy8UqV81_uCoMjrGuIjErQYACxxx5LZjd2Np0R9S2RPCqIFanRLNpVZhEGvXNYfqBrYI0ahw=@protonmail.com> (raw)
In-Reply-To: <SJ0PR10MB548864294DFC3FB812470546F30D2@SJ0PR10MB5488.namprd10.prod.outlook.com>

On Saturday, April 20th, 2024 at 3:10 AM, Drew Adams <drew.adams@oracle.com> wrote:

> > How can I get the value associated with a key.
> > The following does not get me the value
> > associated with my-key.
> > 
> > (let ( (lnum (cdr (rassoc my-key my-alist))))
> > (when lnum (goto-line lnum))))) )
> 
> 
> You don't show your key or alist.
> And you include the irrelevant code `goto-line'. If` my-key' is `((4 score (and 7) years) ago)' and` my-alist' is `((humpty . dumpty) (sat . on-a-wall))', then it's no wonder you're not getting the value associated with` my-key',
> because there isn't any.

Originally I had the associated list made by

    ;; First  Version
    (setq-local tema-lugar
                (append tema--lugar (list (cons lnum strg))))

But the key I was looking for is in the cdr of each element, a string
named strg.

Then changed so that the key is the the car, thusly I have

   ;; Second Version
   (setq-local tema-lugar
                (append tema--lugar (list (cons strg lnum))))

But rassoc was taking the cdr as the key, corresponding to the first
version.

Example:  (("Preamble" . 82) ("Conditions" . 167)) 







  reply	other threads:[~2024-04-19 19:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 23:48 Use of an associated list with completing-read Heime
2024-04-19  2:14 ` [External] : " Drew Adams
2024-04-19  2:59   ` Heime
2024-04-19  3:10     ` Heime
2024-04-19 15:10       ` Drew Adams
2024-04-19 19:09         ` Heime [this message]
2024-04-19 23:32           ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-04-20  1:13             ` Drew Adams
2024-04-20  1:52               ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-04-20  1:59                 ` Emanuel Berg
2024-04-20  6:14                 ` Heime
2024-04-20  6:37                   ` Heime
2024-04-23  4:44 ` Jean Louis

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='6IDPPDE6NaK72davfT7rnK8S553m9H8sBdCDy8UqV81_uCoMjrGuIjErQYACxxx5LZjd2Np0R9S2RPCqIFanRLNpVZhEGvXNYfqBrYI0ahw=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --cc=drew.adams@oracle.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).