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

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

Re: ask for the value of several variables at once


From: Robert L.
Subject: Re: ask for the value of several variables at once
Date: Fri, 9 Mar 2018 20:07:43 +0000 (UTC)
User-agent: XanaNews/1.18.1.6

On 3/9/2018, Emanuel Berg wrote:

> > OK, but better (and much more difficult) to do
> > a function/macro which is used like this,
> > NB with no string or quotes to protect the
> > original symbols:
> > 
> >     (vars-and-values var-1 ... var-n)
> > 
> > which should give a list:
> > 
> >     (var-1 var-1-value ... var-n var-n-value)
> > 
> > or
> > 
> >     ((var-1 var-1-value) ... (var-n var-n-value))
> > 
> > Do it today - in a different way :)
> 
> This is how far I got - next step to make it
> work with a list of vars...
> 
>     (defmacro echo-var (var)
>       `(list ,(symbol-name var) ,var) )
>     ;; (echo-var fill-column) ; ("fill-column" 47)


(defun syms-status (&rest sym-list)
  (mapcar (lambda (s) (list s (symbol-value s))) sym-list))

(defmacro vars-status (&rest sym-list)
  `(quote ,(apply #'syms-status sym-list)))

(setq  foo 22  bar 88)
(vars-status foo bar)
 ===>
((foo 22) (bar 88))

-- 
[Amazon bans history book after it received 300 5-star reviews.]
http://archive.org/details/nolies


reply via email to

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