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

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

RE: [External] : Use of an associated list with completing-read


From: Heime
Subject: RE: [External] : Use of an associated list with completing-read
Date: Fri, 19 Apr 2024 19:09:22 +0000

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 via email to

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