Re: Print key-value pairs from both plist and alist

Heime <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <PEM0b3upnwN1XC7Fk6Yhc4ZGdH1GOtkd7yY3AZQ0hf2IFGTqxFOnkfLe1OLAgeXigZnNIgvIg90wQHrFIKedxqgLwhFKhnBLI1qgk9EDv5w=@protonmail.com>
On Saturday, April 11th, 2026 at 11:03 AM, [email protected] <[email protected]> wrote:

> Heime <[email protected]> writes:
> 
> >
> > I need to adapt this to plists and alists
> >
> >             (maphash
> >                ;; FUNCITON
> >                (lambda (key value)
> >                  (let* ( (fkey  (format "%s" key))
> >                          (fval  (format "%s" value))
> > 			 (sgnl  (if (file-directory-p fval)
> >                                       (propertize " " 'face lmps)
> >                                   (propertize " " 'face lmpw)))
> >                          (pkey  (if (file-directory-p fval)
> >                                       (propertize fkey 'face gjsf)
> >                                   (propertize fkey 'face gjwf))) )
> >                    (insert (format fmt-str sgnl pkey fval))))
> >               ;; TABLE
> >               datenstruk)
> >
> >
> 
> This should work after you have resolved your problem
> loading ‘map-do’.  The two changes to your Emacs Lisp source
> file should be:
> 
>   1. Add ‘(require 'map)’
>   2. Change ‘maphash’ to ‘map-do’.

I needed to add (require 'map)

And with the change to map-do, the result is as expected,
whether the input is a hash-table, plist or alist.

> Example:
> 
> (setq amap '((pine . cones)
>              (oak . acorns)
>              (maple . seeds)))
> 
> (defun print-pair (key val)
>   (princ (format "(%S, %S)\n" key val)))
> 
> (map-do #'print-pair amap)
> =>
> (pine, cones)
> (oak, acorns)
> (maple, seeds)
> 
> nil
> 
> --
> The lyf so short, the craft so long to lerne.
> - Geoffrey Chaucer, The Parliament of Birds.
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.