all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* ask for the value of several variables at once
@ 2018-03-08 15:52 Uwe Brauer
  2018-03-08 16:08 ` tomas
  0 siblings, 1 reply; 40+ messages in thread
From: Uwe Brauer @ 2018-03-08 15:52 UTC (permalink / raw)
  To: help-gnu-emacs

Hi

I am having problems with the mail yank prefix, so it would be 
convenient to ask for the value of several variables and the 
returned values would be in a list.

The most obvious choice
(defun my-ask-mail-yank () 
  (interactive) (describe-variable 'sc-citation-leader) 
  (describe-variable     'sc-reference-tag-string) 
  (describe-variable   'message-yank-cited-prefix) 
  (describe-variable   'message-yank-prefix)) 
 
 
 
Does not work.

Does there exist a command I oversee or a package I don't know?

Uwe Brauer




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-08 15:52 ask for the value of several variables at once Uwe Brauer
@ 2018-03-08 16:08 ` tomas
  2018-03-08 17:56   ` Uwe Brauer
  0 siblings, 1 reply; 40+ messages in thread
From: tomas @ 2018-03-08 16:08 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Mar 08, 2018 at 04:52:27PM +0100, Uwe Brauer wrote:
> Hi
> 
> I am having problems with the mail yank prefix, so it would be
> convenient to ask for the value of several variables and the
> returned values would be in a list.

That's called `list' :-)
> 
> The most obvious choice
> (defun my-ask-mail-yank ()  (interactive) (describe-variable
> 'sc-citation-leader)  (describe-variable
> 'sc-reference-tag-string)  (describe-variable
> 'message-yank-cited-prefix)  (describe-variable
> 'message-yank-prefix))

Try this (I did some indentation cosmetics, hope that's OK)

  (defun my-ask-mail-yank ()
    (interactive)
    (list
      (describe-variable 'sc-citation-leader)
      (describe-variable 'sc-reference-tag-string)
      (describe-variable 'message-yank-cited-prefix)
      (describe-variable 'message-yank-prefix)))

If you want to get fancy, you might try:

  
  (defun my-ask-mail-yank ()
    (interactive)
    (mapcar #'describe-variable
            '(sc-citation-leader sc-reference-tag-string
              message-yank-cited-prefix message-yank-prefix)))

Although I'm a bit confused on what you really want to
achieve, I must admit.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqhYAYACgkQBcgs9XrR2kZD2ACdHDxNExDJIN0iR4WmLn3QJIaW
zzsAnjh3XPf68lfLwxXL0xQYSrezNzqY
=5Scb
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-08 16:08 ` tomas
@ 2018-03-08 17:56   ` Uwe Brauer
  2018-03-08 21:55     ` tomas
                       ` (3 more replies)
  0 siblings, 4 replies; 40+ messages in thread
From: Uwe Brauer @ 2018-03-08 17:56 UTC (permalink / raw)
  To: help-gnu-emacs


   > On Thu, Mar 08, 2018 at 04:52:27PM +0100, Uwe Brauer wrote:

   > That's called `list' :-)

   > Try this (I did some indentation cosmetics, hope that's OK)

   >   (defun my-ask-mail-yank ()
   >     (interactive)
   >     (list
   >       (describe-variable 'sc-citation-leader)
   >       (describe-variable 'sc-reference-tag-string)
   >       (describe-variable 'message-yank-cited-prefix)
   >       (describe-variable 'message-yank-prefix)))

   > If you want to get fancy, you might try:


   >   (defun my-ask-mail-yank ()
   >     (interactive)
   >     (mapcar #'describe-variable
   >             '(sc-citation-leader sc-reference-tag-string
   >               message-yank-cited-prefix message-yank-prefix)))

Thanks but none worked as I expected.

I want to have  an output like this


sc-citation-leader "    "
sc-reference-tag-string ">>"
message-yank-cited-prefix "   >"    
message-yank-prefix "  >"

Say, best with the documentation text suppressed.




   > Although I'm a bit confused on what you really want to
   > achieve, I must admit.

What is the purpose? Well I have since ages set
these variables in a way to obtain and indentations + the >



This is why you see your quotations with that indentation space. Now in
some newsgroup this is disliked and no indentation is preferred. I am
using gnus so I thought that via gnus-group-customize I could set these
variables just for the group. But for some reasons this does not work.

Since I was not sure which of the variable really is responsible for the
indentation I wanted to find a way to ask their values in one go.





^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-08 17:56   ` Uwe Brauer
@ 2018-03-08 21:55     ` tomas
  2018-03-09 18:13       ` Uwe Brauer
       [not found]       ` <mailman.10340.1520619259.27995.help-gnu-emacs@gnu.org>
       [not found]     ` <mailman.10293.1520546129.27995.help-gnu-emacs@gnu.org>
                       ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: tomas @ 2018-03-08 21:55 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Mar 08, 2018 at 06:56:34PM +0100, Uwe Brauer wrote:
> 
>    > On Thu, Mar 08, 2018 at 04:52:27PM +0100, Uwe Brauer wrote:
> 
>    > That's called `list' :-)
> 
>    > Try this (I did some indentation cosmetics, hope that's OK)
> 
>    >   (defun my-ask-mail-yank ()
>    >     (interactive)
>    >     (list
>    >       (describe-variable 'sc-citation-leader)
>    >       (describe-variable 'sc-reference-tag-string)
>    >       (describe-variable 'message-yank-cited-prefix)
>    >       (describe-variable 'message-yank-prefix)))
> 
>    > If you want to get fancy, you might try:
> 
> 
>    >   (defun my-ask-mail-yank ()
>    >     (interactive)
>    >     (mapcar #'describe-variable
>    >             '(sc-citation-leader sc-reference-tag-string
>    >               message-yank-cited-prefix message-yank-prefix)))
> 
> Thanks but none worked as I expected.
> 
> I want to have  an output like this
> 
> 
> sc-citation-leader "    "
> sc-reference-tag-string ">>"
> message-yank-cited-prefix "   >"    
> message-yank-prefix "  >"

Oh. That makes it clearer :-)

You want the variable's name and the variable's value. Then
`describe-variable' is far too verbose.

Try `symbol-value', that may be closer to what you want.

> Say, best with the documentation text suppressed.
> 
>    > Although I'm a bit confused on what you really want to
>    > achieve, I must admit.

Now a bit clearer.

> What is the purpose? Well I have since ages set
> these variables in a way to obtain and indentations + the >
> 
> 
> 
> This is why you see your quotations with that indentation space. Now in
> some newsgroup this is disliked and no indentation is preferred. I am
> using gnus so I thought that via gnus-group-customize I could set these
> variables just for the group. But for some reasons this does not work.
> 
> Since I was not sure which of the variable really is responsible for the
> indentation I wanted to find a way to ask their values in one go.

Try this (beware: not thoroughly tested):

  (defun my-ask-mail-yank ()
    (interactive)
    (mapconcat
      (lambda (sym)
        (format "%s: %s" sym (symbol-value sym)))
      '(sc-citation-leader sc-reference-tag-string
        message-yank-cited-prefix message-yank-prefix)
      "\n"))

Season to taste :-)

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqhsUUACgkQBcgs9XrR2kacjACeKlSHsVA+Lq1AAwtmepEgBo3o
i64An1RN8Nhwo/LfwA6N3KW8PRERX46L
=9Jdu
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]     ` <mailman.10293.1520546129.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09  8:01       ` Emanuel Berg
  2018-03-09  8:32         ` Emanuel Berg
  0 siblings, 1 reply; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09  8:01 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> Try this (beware: not thoroughly tested):
>
>   (defun my-ask-mail-yank ()
>     (interactive)
>     (mapconcat
>       (lambda (sym)
>         (format "%s: %s" sym (symbol-value sym)))
>       '(sc-citation-leader sc-reference-tag-string
>         message-yank-cited-prefix message-yank-prefix)
>       "\n"))

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 :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09  8:01       ` Emanuel Berg
@ 2018-03-09  8:32         ` Emanuel Berg
  2018-03-09  9:18           ` Emanuel Berg
                             ` (3 more replies)
  0 siblings, 4 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09  8:32 UTC (permalink / raw)
  To: help-gnu-emacs

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)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09  8:32         ` Emanuel Berg
@ 2018-03-09  9:18           ` Emanuel Berg
  2018-03-09 10:14             ` tomas
       [not found]             ` <mailman.10313.1520590498.27995.help-gnu-emacs@gnu.org>
  2018-03-09  9:19           ` tomas
                             ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09  9:18 UTC (permalink / raw)
  To: help-gnu-emacs

> 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)

BTW in general, what is the easiest way to just
prevent a function or arbitrary "in-out data
processing unit" to *not* evaluate the
arguments and then if/when need be do that
manually in the body?

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09  8:32         ` Emanuel Berg
  2018-03-09  9:18           ` Emanuel Berg
@ 2018-03-09  9:19           ` tomas
       [not found]           ` <mailman.10308.1520587214.27995.help-gnu-emacs@gnu.org>
  2018-03-09 20:07           ` Robert L.
  3 siblings, 0 replies; 40+ messages in thread
From: tomas @ 2018-03-09  9:19 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 09, 2018 at 09:32:07AM +0100, Emanuel Berg wrote:
> 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
       ^^^^^^^^^^^^^^^^^^^^^^^^
       it has to be a macro then...

> > 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)

That's a good first step. The question now is whether to delegate
the looping over the list to a function or not.

Whatever it is what catches the argument list has to be a macro,
due to you "no quotes" requirement...

Thanks
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqiUb8ACgkQBcgs9XrR2kb4qwCeOaQG1ipnJVZ0uIaIqr7+rFF6
v4QAn1u4p29kGduD8Dnf5C1+on/tD/Su
=NrWL
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-08 17:56   ` Uwe Brauer
  2018-03-08 21:55     ` tomas
       [not found]     ` <mailman.10293.1520546129.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 10:03     ` Yuri Khan
  2018-03-09 18:15       ` Uwe Brauer
       [not found]     ` <mailman.10310.1520589843.27995.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 40+ messages in thread
From: Yuri Khan @ 2018-03-09 10:03 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, Mar 9, 2018 at 12:56 AM, Uwe Brauer <oub@mat.ucm.es> wrote:
> I want to have  an output like this
>
> sc-citation-leader "    "
> sc-reference-tag-string ">>"
> message-yank-cited-prefix "   >"
> message-yank-prefix "  >"
>
> Say, best with the documentation text suppressed.

Why not just go for a simple solution for a simple need?

(defun my-ask-mail-yank ()
  (interactive)
  (message "sc-citation-leader %S
sc-reference-tag-string %S
message-yank-cited-prefix %S
message-yank-prefix %S"
           sc-citation-leader
           sc-reference-tag-string
           message-yank-cited-prefix
           message-yank-prefix))



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]     ` <mailman.10310.1520589843.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 10:05       ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 10:05 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

> Why not just go for a simple solution for
> a simple need?

Answer: Because next time one cannot reuse the
simple solution, despite the need being equally
simple...

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]           ` <mailman.10308.1520587214.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 10:09             ` Emanuel Berg
  2018-03-09 10:21               ` tomas
  0 siblings, 1 reply; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 10:09 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

>>     (defmacro echo-var (var)
>>       `(list ,(symbol-name var) ,var) )
>>     ;; (echo-var fill-column) ; ("fill-column" 47)
>
> That's a good first step. The question now is
> whether to delegate the looping over the list
> to a function or not.

I don't get it to work with the set functions
and &rest. But I almost didn't write a single
macro all my Elisp life! Some guys do it all
the time and I suspect for them this task is
all but trivial...

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09  9:18           ` Emanuel Berg
@ 2018-03-09 10:14             ` tomas
       [not found]             ` <mailman.10313.1520590498.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 40+ messages in thread
From: tomas @ 2018-03-09 10:14 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 09, 2018 at 10:18:32AM +0100, Emanuel Berg wrote:
> > 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)
> 
> BTW in general, what is the easiest way to just
> prevent a function or arbitrary "in-out data
> processing unit" to *not* evaluate the
> arguments and then if/when need be do that
> manually in the body?

In "classical" Lisps the functions always evaluate their args.
The "other" way is what macros are for (or special forms).

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqiXpkACgkQBcgs9XrR2kaQLgCeIn0g5I7wESpO7+qudHFV+TOM
U0QAn3l15Sg77up7s4vPg6vBDkxkrv0g
=nQ/S
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 10:09             ` Emanuel Berg
@ 2018-03-09 10:21               ` tomas
  0 siblings, 0 replies; 40+ messages in thread
From: tomas @ 2018-03-09 10:21 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 09, 2018 at 11:09:11AM +0100, Emanuel Berg wrote:
> tomas wrote:
> 
> >>     (defmacro echo-var (var)
> >>       `(list ,(symbol-name var) ,var) )
> >>     ;; (echo-var fill-column) ; ("fill-column" 47)
> >
> > That's a good first step. The question now is
> > whether to delegate the looping over the list
> > to a function or not.
> 
> I don't get it to work with the set functions
> and &rest. But I almost didn't write a single
> macro all my Elisp life! Some guys do it all
> the time and I suspect for them this task is
> all but trivial...

Ah, macro and varargs. You might take the "cheap" cop-out
and decree that your macro takes *one list* as argument
instead of a variable number of arguments. You'd be in good
company there (cf. the `let' special form). If you're a
perfectionist, more work might be involved (I've no ready
solution for you at the moment, sorry)

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqiYC0ACgkQBcgs9XrR2kZ86QCdG6T9YXwRpn0BK4vZijVsuulj
DXYAn2vJI4oOhSAGDu4PwsSPcBz7+KMt
=z2hG
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]             ` <mailman.10313.1520590498.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 10:42               ` Emanuel Berg
  2018-03-09 11:49                 ` tomas
                                   ` (3 more replies)
  0 siblings, 4 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 10:42 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> In "classical" Lisps the functions always
> evaluate their args. The "other" way is what
> macros are for (or special forms).

Here is a "classical" solution. How to rewrite
it the "other" way, only Jehovah knows...

    (defun echo-vars (&rest vars)
      (mapcar
       (lambda (v) (list (symbol-name v) (symbol-value  v)))
       vars))
    ;; (echo-vars 'fill-column 'buffer-file-name)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 10:42               ` Emanuel Berg
@ 2018-03-09 11:49                 ` tomas
       [not found]                 ` <mailman.10316.1520596187.27995.help-gnu-emacs@gnu.org>
                                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 40+ messages in thread
From: tomas @ 2018-03-09 11:49 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 09, 2018 at 11:42:47AM +0100, Emanuel Berg wrote:
> tomas wrote:
> 
> > In "classical" Lisps the functions always
> > evaluate their args. The "other" way is what
> > macros are for (or special forms).
> 
> Here is a "classical" solution. How to rewrite
> it the "other" way, only Jehovah knows...
> 
>     (defun echo-vars (&rest vars)
>       (mapcar
>        (lambda (v) (list (symbol-name v) (symbol-value  v)))
>        vars))
>     ;; (echo-vars 'fill-column 'buffer-file-name)

But then, in the "classical" setting, you'd have to pass the
names as symbols (otherwise they are evaluated), as in

  (echo-vars 'foo 'bar 'meep 'boop)

To be honest, then I'd prefer echo-vars took a list instead.
Being pathologically lazy, I might prefer to write

  (echo-vars '(foo bar meep boop))

which is one keystroke less ;-D

(don't take me too seriously, though).

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlqidNIACgkQBcgs9XrR2kb51ACfUY+Emm+LV/sO0gUVDjS66atZ
CI0AnAiHdECY3WztKNbU+wkQxRmOoRu3
=guQY
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                 ` <mailman.10316.1520596187.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 14:23                   ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 14:23 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> But then, in the "classical" setting, you'd
> have to pass the names as symbols (otherwise
> they are evaluated), as in
>
>   (echo-vars 'foo 'bar 'meep 'boop)

Yes, that's what I wrote:

    ;; (echo-vars 'fill-column 'buffer-file-name)

However much "symbols" that is, quoted literals
at best.

No, here is one ocasion macros should do it.
Holly would if she could...

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-08 21:55     ` tomas
@ 2018-03-09 18:13       ` Uwe Brauer
  2018-03-09 20:07         ` Nick Dokos
       [not found]         ` <mailman.10352.1520626056.27995.help-gnu-emacs@gnu.org>
       [not found]       ` <mailman.10340.1520619259.27995.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 40+ messages in thread
From: Uwe Brauer @ 2018-03-09 18:13 UTC (permalink / raw)
  To: help-gnu-emacs


   > On Thu, Mar 08, 2018 at 06:56:34PM +0100, Uwe Brauer wrote:

   > Oh. That makes it clearer :-)

   > You want the variable's name and the variable's value. Then
   > `describe-variable' is far too verbose.

   > Try `symbol-value', that may be closer to what you want.


   > Now a bit clearer.


   > Try this (beware: not thoroughly tested):

   >   (defun my-ask-mail-yank ()
   >     (interactive)
   >     (mapconcat
   >       (lambda (sym)
   >         (format "%s: %s" sym (symbol-value sym)))
   >       '(sc-citation-leader sc-reference-tag-string
   >         message-yank-cited-prefix message-yank-prefix)
   >       "\n"))

Thanks, I just tried it out but it does not return anything neither in
the minibuffer nor in the message buffer.

What do I miss?

Uwe 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 10:03     ` Yuri Khan
@ 2018-03-09 18:15       ` Uwe Brauer
  0 siblings, 0 replies; 40+ messages in thread
From: Uwe Brauer @ 2018-03-09 18:15 UTC (permalink / raw)
  To: help-gnu-emacs


   > On Fri, Mar 9, 2018 at 12:56 AM, Uwe Brauer <oub@mat.ucm.es> wrote:

   > Why not just go for a simple solution for a simple need?

   > (defun my-ask-mail-yank ()
   >   (interactive)
   >   (message "sc-citation-leader %S
   > sc-reference-tag-string %S
   > message-yank-cited-prefix %S
   > message-yank-prefix %S"
   >            sc-citation-leader
   >            sc-reference-tag-string
   >            message-yank-cited-prefix
   >            message-yank-prefix))



Thanks! This does precisely what I expected and it is rather simple




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 10:42               ` Emanuel Berg
  2018-03-09 11:49                 ` tomas
       [not found]                 ` <mailman.10316.1520596187.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 18:18                 ` Uwe Brauer
       [not found]                 ` <mailman.10342.1520619737.27995.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 40+ messages in thread
From: Uwe Brauer @ 2018-03-09 18:18 UTC (permalink / raw)
  To: help-gnu-emacs


   > tomas wrote:

   > Here is a "classical" solution. How to rewrite
   > it the "other" way, only Jehovah knows...

   >     (defun echo-vars (&rest vars)
   >       (mapcar
   >        (lambda (v) (list (symbol-name v) (symbol-value  v)))
   >        vars))
   >     ;; (echo-vars 'fill-column 'buffer-file-name)

Well but how is this supposed to work? So far, for me only Yuri's
solution returned what I was looking for. I wonder what I miss?




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                 ` <mailman.10342.1520619737.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 19:30                   ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 19:30 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

>> (defun echo-vars (&rest vars) (mapcar
>> (lambda (v) (list (symbol-name v)
>> (symbol-value v))) vars)) ;; (echo-vars
>> 'fill-column 'buffer-file-name)
>
> Well but how is this supposed to work?
> So far, for me only Yuri's solution returned
> what I was looking for. I wonder what I miss?

You are missing a wrapper that will put the
general solution to work for your specific
use-case...

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]       ` <mailman.10340.1520619259.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 19:36         ` Emanuel Berg
  2018-03-14  9:26           ` Uwe Brauer
       [not found]           ` <mailman.10591.1521019620.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 19:36 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

>> (defun my-ask-mail-yank () (interactive)
>> (mapconcat (lambda (sym) (format "%s: %s"
>> sym (symbol-value sym)))
>> '(sc-citation-leader
>> sc-reference-tag-string
>> message-yank-cited-prefix
>> message-yank-prefix) "\n"))
>
> Thanks, I just tried it out but it does not
> return anything neither in the minibuffer nor
> in the message buffer.
>
> What do I miss?

What is missing here is explicit output as it
only returns the correct answer, and for
interactive calls that doesn't show. Call it
from Elisp (evaluate the form) and you'll see.

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 18:13       ` Uwe Brauer
@ 2018-03-09 20:07         ` Nick Dokos
       [not found]         ` <mailman.10352.1520626056.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 40+ messages in thread
From: Nick Dokos @ 2018-03-09 20:07 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer <oub@mat.ucm.es> writes:

>    > On Thu, Mar 08, 2018 at 06:56:34PM +0100, Uwe Brauer wrote:
>
>    > Oh. That makes it clearer :-)
>
>    > You want the variable's name and the variable's value. Then
>    > `describe-variable' is far too verbose.
>
>    > Try `symbol-value', that may be closer to what you want.
>
>
>    > Now a bit clearer.
>
>
>    > Try this (beware: not thoroughly tested):
>
>    >   (defun my-ask-mail-yank ()
>    >     (interactive)
>    >     (mapconcat
>    >       (lambda (sym)
>    >         (format "%s: %s" sym (symbol-value sym)))
>    >       '(sc-citation-leader sc-reference-tag-string
>    >         message-yank-cited-prefix message-yank-prefix)
>    >       "\n"))
>
> Thanks, I just tried it out but it does not return anything neither in
> the minibuffer nor in the message buffer.
>
> What do I miss?
>
I don't know, but it does return a string, which I get in the echo area and in the *Messages* buffer.
Try to paste the defun into your *scratch* buffer (make sure that it is in lisp-interaction mode),
then evaluate it with C-x C-e and then call it (I don't use supercite, so I replaced the two supercite
variables with gnus-cite-prefix-alist):

   (defun my-ask-mail-yank ()
     (interactive)
     (mapconcat
       (lambda (sym)
         (format "%s: %s" sym (symbol-value sym)))
       '(gnus-cite-prefix-alist
         message-yank-cited-prefix message-yank-prefix)
       "\n")) ;;; press C-j here
my-ask-mail-yank

(my-ask-mail-yank) ;;; press C-j here
"gnus-cite-prefix-alist: nil
message-yank-cited-prefix: >
message-yank-prefix: > "

-- 
Nick




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09  8:32         ` Emanuel Berg
                             ` (2 preceding siblings ...)
       [not found]           ` <mailman.10308.1520587214.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 20:07           ` Robert L.
  2018-03-09 20:17             ` Emanuel Berg
  3 siblings, 1 reply; 40+ messages in thread
From: Robert L. @ 2018-03-09 20:07 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 20:07           ` Robert L.
@ 2018-03-09 20:17             ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 20:17 UTC (permalink / raw)
  To: help-gnu-emacs

Robert L. wrote:

> (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)))

OK, backtick, quote, apply - plain and simple!

Didn't think of that :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]         ` <mailman.10352.1520626056.27995.help-gnu-emacs@gnu.org>
@ 2018-03-09 20:24           ` Emanuel Berg
  2018-03-09 23:44             ` Nick Dokos
  0 siblings, 1 reply; 40+ messages in thread
From: Emanuel Berg @ 2018-03-09 20:24 UTC (permalink / raw)
  To: help-gnu-emacs

Nick Dokos wrote:

> I don't know, but it does return a string,
> which I get in the echo area and in the
> *Messages* buffer. Try to paste the defun
> into your *scratch* buffer (make sure that it
> is in lisp-interaction mode), then evaluate
> it

(defun my-name-is-neo ()
  (interactive)
  1)

;; now try evaluating:
;; 
;;     (my-name-is-neo)
;;
;; but then do
;;
;;     M-x my-name-is-neo RET   <silence>
;;
;; only this also shows it so perhaps the
;; interactive rule only "holds" sometimes :)
;;
;;     (call-interactively #'my-name-is-neo)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 20:24           ` Emanuel Berg
@ 2018-03-09 23:44             ` Nick Dokos
  0 siblings, 0 replies; 40+ messages in thread
From: Nick Dokos @ 2018-03-09 23:44 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <moasen@zoho.com> writes:

> Nick Dokos wrote:
>
>> I don't know, but it does return a string,
>> which I get in the echo area and in the
>> *Messages* buffer. Try to paste the defun
>> into your *scratch* buffer (make sure that it
>> is in lisp-interaction mode), then evaluate
>> it
>
> (defun my-name-is-neo ()
>   (interactive)
>   1)
>
> ;; now try evaluating:
> ;; 
> ;;     (my-name-is-neo)
> ;;
> ;; but then do
> ;;
> ;;     M-x my-name-is-neo RET   <silence>
> ;;
> ;; only this also shows it so perhaps the
> ;; interactive rule only "holds" sometimes :)
> ;;
> ;;     (call-interactively #'my-name-is-neo)

Ah, I did miss the interactive part - thanks!
-- 
Nick




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-09 19:36         ` Emanuel Berg
@ 2018-03-14  9:26           ` Uwe Brauer
  2018-03-14  9:42             ` Yuri Khan
       [not found]             ` <mailman.10592.1521020572.27995.help-gnu-emacs@gnu.org>
       [not found]           ` <mailman.10591.1521019620.27995.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 40+ messages in thread
From: Uwe Brauer @ 2018-03-14  9:26 UTC (permalink / raw)
  To: help-gnu-emacs

>>> "Emanuel" == Emanuel Berg <moasen@zoho.com> writes:

   > Uwe Brauer wrote:
   >>> (defun my-ask-mail-yank () (interactive)
   >>> (mapconcat (lambda (sym) (format "%s: %s"
   >>> sym (symbol-value sym)))
   >>> '(sc-citation-leader
   >>> sc-reference-tag-string
   >>> message-yank-cited-prefix
   >>> message-yank-prefix) "\n"))
   >> 
   >> Thanks, I just tried it out but it does not
   >> return anything neither in the minibuffer nor
   >> in the message buffer.
   >> 
   >> What do I miss?

   > What is missing here is explicit output as it
   > only returns the correct answer, and for
   > interactive calls that doesn't show. Call it
   > from Elisp (evaluate the form) and you'll see.

Do you mean
(call-interactively 'my-ask-mail-yank)

That works nicely. Thanks

Just out of curiosity what is the advantage over Yuri's solution?


(defun my-ask-mail-yank ()
  (interactive)
  (message "sc-citation-leader %S
sc-reference-tag-string %S
message-yank-cited-prefix %S
message-yank-prefix %S"
           sc-citation-leader
           sc-reference-tag-string
           message-yank-cited-prefix
           message-yank-prefix))




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]           ` <mailman.10591.1521019620.27995.help-gnu-emacs@gnu.org>
@ 2018-03-14  9:39             ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-14  9:39 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer wrote:

> Do you mean (call-interactively
> 'my-ask-mail-yank)
>
> That works nicely. Thanks

Well, I don't mean it should be used in your
code, but posted it to show the difference, why
the function was both verbose and silent
in execution.

In your case, instead use `message' to output
the message you want to see.

> Just out of curiosity what is the advantage
> over Yuri's solution?

By using a general solution, you achieve the
specific functionality you seek, only the
general solution is then added to the arsenal
so the next time the same situation appears,
only in another context, you don't have to do
anything but write a simple wrapper, and you
can look at the specific interface already
there if you forgot how it looked. Also, again
having the general part in your arsenal, it
might be useful in some completely different
situation, and then it'll be really nice to
just dust it off and use again for new
wonders :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-14  9:26           ` Uwe Brauer
@ 2018-03-14  9:42             ` Yuri Khan
       [not found]             ` <mailman.10592.1521020572.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 40+ messages in thread
From: Yuri Khan @ 2018-03-14  9:42 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, Mar 14, 2018 at 4:26 PM, Uwe Brauer <oub@mat.ucm.es> wrote:
>>>> "Emanuel" == Emanuel Berg <moasen@zoho.com> writes:
>
>    >>> (defun my-ask-mail-yank ()
>    >>>   (interactive)
>    >>>   (mapconcat (lambda (sym) (format "%s: %s" sym (symbol-value sym)))
>    >>>              '(sc-citation-leader
>    >>>                sc-reference-tag-string
>    >>>                message-yank-cited-prefix
>    >>>                message-yank-prefix)
>    >>>              "\n"))
>
> Just out of curiosity what is the advantage over Yuri's solution?

The main advantage as I see it is that you don’t have to repeat each
variable’s name(once in the format string, again in the arguments to
‘message’). Could become significant if you later want to make many
more commands of this kind, displaying many other variables.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]             ` <mailman.10592.1521020572.27995.help-gnu-emacs@gnu.org>
@ 2018-03-14 10:31               ` Emanuel Berg
  2018-03-14 11:53                 ` Yuri Khan
       [not found]                 ` <mailman.10597.1521028463.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-14 10:31 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

> The main advantage as I see it is that you
> don’t have to repeat each variable’s
> name(once in the format string, again in the
> arguments to ‘message’).

? Who is repeating, you or me?

BTW, what exactly is "my" suggestion? I feel
like I just dumped a bunch of code. Did anyone
put it together to solve this particular issue?
I'm going to the public library right now to
look for trouble, but if no one did it I'll do
it tonight God willing.

Here are the building blocks of the universe.
I guess I like it fine - so far.

(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)))

;; eval us:
;; (setq  foo 22  bar 88)
;; (vars-status foo bar)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-14 10:31               ` Emanuel Berg
@ 2018-03-14 11:53                 ` Yuri Khan
       [not found]                 ` <mailman.10597.1521028463.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 40+ messages in thread
From: Yuri Khan @ 2018-03-14 11:53 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

On Wed, Mar 14, 2018 at 5:31 PM, Emanuel Berg <moasen@zoho.com> wrote:

>> The main advantage as I see it is that you
>> don’t have to repeat each variable’s
>> name(once in the format string, again in the
>> arguments to ‘message’).
>
> ? Who is repeating, you or me?

I am.

> BTW, what exactly is "my" suggestion?

Sorry, I (actually, we collectively) mixed up the attribution. I took
Uwe’s question as asking about advantages of the partial solution by
Tomas, augmented by your suggestion on how to call that in a way that
displays the result, over my attempt.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                 ` <mailman.10597.1521028463.27995.help-gnu-emacs@gnu.org>
@ 2018-03-14 12:47                   ` Emanuel Berg
  2018-03-17 16:44                   ` Emanuel Berg
  1 sibling, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-14 12:47 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> ? Who is repeating, you or me?
>
> I am.

OK, but its not needed for either which are the
same in principle by the way, if boiled down to
a single case.

>> BTW, what exactly is "my" suggestion?
>
> Sorry, I (actually, we collectively) mixed up
> the attribution. I took Uwe’s question as
> asking about advantages of the partial
> solution by Tomas, augmented by your
> suggestion

Actually it was Robert L. who did it :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                 ` <mailman.10597.1521028463.27995.help-gnu-emacs@gnu.org>
  2018-03-14 12:47                   ` Emanuel Berg
@ 2018-03-17 16:44                   ` Emanuel Berg
  2018-03-17 17:25                     ` Emanuel Berg
                                       ` (2 more replies)
  1 sibling, 3 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-17 16:44 UTC (permalink / raw)
  To: help-gnu-emacs

Here it is! Only I don't have

;; sc-citation-leader
;; sc-reference-tag-string

so add them manually. I wonder tho if the
"verbose" version should be a macro as well?
That would be better, I think.

But as I've said, I'm not good with macros, and
it shows, because as much as this seems to work
when eval'd and executed, the byte compiler
doesn't like it:

    geh.el:24:1:Error: Symbol's function definition
    is void: syms-status

(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)

(require 'cl-lib)
(defun all-systems-ready ()
  (interactive)
  (let ((report (vars-status message-yank-cited-prefix message-yank-prefix))
        (output ""))
    (cl-loop
     for (var val) in report do
     (setq output (concat output (format "%s: [%s]  " var val))) )
    (message output) ))
;; (all-systems-ready)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-17 16:44                   ` Emanuel Berg
@ 2018-03-17 17:25                     ` Emanuel Berg
  2018-03-17 20:59                     ` John Mastro
       [not found]                     ` <mailman.10810.1521320411.27995.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-17 17:25 UTC (permalink / raw)
  To: help-gnu-emacs

> (require 'cl-lib)
> (defun all-systems-ready ()
>   (interactive)
>   (let ((report (vars-status message-yank-cited-prefix message-yank-prefix))
>         (output ""))
>     (cl-loop
>      for (var val) in report do
>      (setq output (concat output (format "%s: [%s]  " var val))) )
>     (message output) ))
> ;; (all-systems-ready)

Maybe one doesn't have to require cl-lib,
because cl-loop is autoloaded...

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-17 16:44                   ` Emanuel Berg
  2018-03-17 17:25                     ` Emanuel Berg
@ 2018-03-17 20:59                     ` John Mastro
       [not found]                     ` <mailman.10810.1521320411.27995.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 40+ messages in thread
From: John Mastro @ 2018-03-17 20:59 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Emanuel Berg <moasen@zoho.com> wrote:
> But as I've said, I'm not good with macros, and
> it shows, because as much as this seems to work
> when eval'd and executed, the byte compiler
> doesn't like it:
>
>     geh.el:24:1:Error: Symbol's function definition
>     is void: syms-status
>
> (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)

I think what you really want for vars-status is:

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

Or, equivalently (if the quasiquote syntax makes it harder to see what's
going on):

(defmacro vars-status (&rest sym-list)
  (list 'apply '(function syms-status) (list 'quote sym-list)))

The difference is that your implementation above will call syms-status
at macro-expansion time, whereas this will call it at run-time.

        John



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                     ` <mailman.10810.1521320411.27995.help-gnu-emacs@gnu.org>
@ 2018-03-18 12:14                       ` Emanuel Berg
  2018-03-18 12:30                         ` Emanuel Berg
                                           ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-18 12:14 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro wrote:

> I think what you really want for vars-status is:
>
> (defmacro vars-status (&rest sym-list)
>   `(apply #'syms-status ',sym-list))

Right, that did it! Now there is no
error message.

(BTW I was wrong about `cl-lib' not being
needed to be required for `cl-loop', it does.)

Here is the final (?) version. See, macros
aren't that difficult! It only takes half
a dozen of people to solve a problem one would
think would be right up the macro alley...

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

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

(require 'cl-lib)
(require 'subr-x)
(defun all-systems-ready ()
  (interactive)
  (let ((report (vars-status message-yank-cited-prefix message-yank-prefix))
        (output ""))
    (cl-loop
     for (var val) in report do
     (setq output (concat output (format "[%s] %s " val var))) )
    (message (string-trim output)) ))
;; (all-systems-ready)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-18 12:14                       ` Emanuel Berg
@ 2018-03-18 12:30                         ` Emanuel Berg
  2018-03-19 21:14                           ` John Mastro
  2018-03-18 15:00                         ` Stefan Monnier
       [not found]                         ` <mailman.10837.1521385252.27995.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 40+ messages in thread
From: Emanuel Berg @ 2018-03-18 12:30 UTC (permalink / raw)
  To: help-gnu-emacs

> See, macros aren't that difficult! It only
> takes half a dozen of people to solve
> a problem one would think would be right up
> the macro alley...

Is there any trick of thinking or otherwise
sparring exercises if you will to get into the
mind frame of macros? Obviously doing it on
gnu.emacs.help wasn't the way :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-18 12:14                       ` Emanuel Berg
  2018-03-18 12:30                         ` Emanuel Berg
@ 2018-03-18 15:00                         ` Stefan Monnier
       [not found]                         ` <mailman.10837.1521385252.27995.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 40+ messages in thread
From: Stefan Monnier @ 2018-03-18 15:00 UTC (permalink / raw)
  To: help-gnu-emacs

> (defun syms-status (&rest sym-list)
>   (mapcar (lambda (s) (list s (symbol-value s))) sym-list))
>
> (defmacro vars-status (&rest sym-list)
>   `(apply #'syms-status ',sym-list))

Why not

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

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


-- Stefan




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
       [not found]                         ` <mailman.10837.1521385252.27995.help-gnu-emacs@gnu.org>
@ 2018-03-18 15:09                           ` Emanuel Berg
  0 siblings, 0 replies; 40+ messages in thread
From: Emanuel Berg @ 2018-03-18 15:09 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

> Why not
>
>     (defun syms-status (sym-list)
>       (mapcar (lambda (s) (list s (symbol-value s))) sym-list))
>
>     (defmacro vars-status (&rest sym-list)
>       `(syms-status ',sym-list))

I don't KNOW, but it is shorter and works with
no complains from the byte compiler, so I have
changed it that way:

    http://user.it.uu.se/~embe8573/emacs-init/geh.el

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: ask for the value of several variables at once
  2018-03-18 12:30                         ` Emanuel Berg
@ 2018-03-19 21:14                           ` John Mastro
  0 siblings, 0 replies; 40+ messages in thread
From: John Mastro @ 2018-03-19 21:14 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Emanuel Berg <moasen@zoho.com> wrote:
> Is there any trick of thinking or otherwise
> sparring exercises if you will to get into the
> mind frame of macros? Obviously doing it on
> gnu.emacs.help wasn't the way :)

Mostly I think it's just a matter of practice. The macrostep[1] package
can make it a bit more convenient to inspect how a given macro expands,
which can be a big help when you're working on one. I bind
`macrostep-expand' to `C-c C-e' in emacs-lisp-mode.

        John

[1]: https://github.com/joddie/macrostep



^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2018-03-19 21:14 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-08 15:52 ask for the value of several variables at once Uwe Brauer
2018-03-08 16:08 ` tomas
2018-03-08 17:56   ` Uwe Brauer
2018-03-08 21:55     ` tomas
2018-03-09 18:13       ` Uwe Brauer
2018-03-09 20:07         ` Nick Dokos
     [not found]         ` <mailman.10352.1520626056.27995.help-gnu-emacs@gnu.org>
2018-03-09 20:24           ` Emanuel Berg
2018-03-09 23:44             ` Nick Dokos
     [not found]       ` <mailman.10340.1520619259.27995.help-gnu-emacs@gnu.org>
2018-03-09 19:36         ` Emanuel Berg
2018-03-14  9:26           ` Uwe Brauer
2018-03-14  9:42             ` Yuri Khan
     [not found]             ` <mailman.10592.1521020572.27995.help-gnu-emacs@gnu.org>
2018-03-14 10:31               ` Emanuel Berg
2018-03-14 11:53                 ` Yuri Khan
     [not found]                 ` <mailman.10597.1521028463.27995.help-gnu-emacs@gnu.org>
2018-03-14 12:47                   ` Emanuel Berg
2018-03-17 16:44                   ` Emanuel Berg
2018-03-17 17:25                     ` Emanuel Berg
2018-03-17 20:59                     ` John Mastro
     [not found]                     ` <mailman.10810.1521320411.27995.help-gnu-emacs@gnu.org>
2018-03-18 12:14                       ` Emanuel Berg
2018-03-18 12:30                         ` Emanuel Berg
2018-03-19 21:14                           ` John Mastro
2018-03-18 15:00                         ` Stefan Monnier
     [not found]                         ` <mailman.10837.1521385252.27995.help-gnu-emacs@gnu.org>
2018-03-18 15:09                           ` Emanuel Berg
     [not found]           ` <mailman.10591.1521019620.27995.help-gnu-emacs@gnu.org>
2018-03-14  9:39             ` Emanuel Berg
     [not found]     ` <mailman.10293.1520546129.27995.help-gnu-emacs@gnu.org>
2018-03-09  8:01       ` Emanuel Berg
2018-03-09  8:32         ` Emanuel Berg
2018-03-09  9:18           ` Emanuel Berg
2018-03-09 10:14             ` tomas
     [not found]             ` <mailman.10313.1520590498.27995.help-gnu-emacs@gnu.org>
2018-03-09 10:42               ` Emanuel Berg
2018-03-09 11:49                 ` tomas
     [not found]                 ` <mailman.10316.1520596187.27995.help-gnu-emacs@gnu.org>
2018-03-09 14:23                   ` Emanuel Berg
2018-03-09 18:18                 ` Uwe Brauer
     [not found]                 ` <mailman.10342.1520619737.27995.help-gnu-emacs@gnu.org>
2018-03-09 19:30                   ` Emanuel Berg
2018-03-09  9:19           ` tomas
     [not found]           ` <mailman.10308.1520587214.27995.help-gnu-emacs@gnu.org>
2018-03-09 10:09             ` Emanuel Berg
2018-03-09 10:21               ` tomas
2018-03-09 20:07           ` Robert L.
2018-03-09 20:17             ` Emanuel Berg
2018-03-09 10:03     ` Yuri Khan
2018-03-09 18:15       ` Uwe Brauer
     [not found]     ` <mailman.10310.1520589843.27995.help-gnu-emacs@gnu.org>
2018-03-09 10:05       ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.