Gnus development mailing list
 help / color / mirror / Atom feed
From: Steinar Bang <sb@dod.no>
To: ding@gnus.org
Subject: Backquotes and commas and ",@" (Was: gnus-sync-save fails with "wrong-type-argument number-or-marker-p")
Date: Sat, 10 Dec 2011 09:10:55 +0100	[thread overview]
Message-ID: <87sjkskfsg.fsf_-_@dod.no> (raw)
In-Reply-To: <87wra4khpe.fsf@dod.no>

>>>>> Steinar Bang <sb@dod.no>:

> (...and the reason it is hard to do anything about it myself, is that
> backquotes, "," and ",@", are the bits of emacs lisp I've never been
> able to wrap my head around.  I mean:
>    You can also "splice" an evaluated value into the resulting list,
>    using the special marker `,@'.
> Like... huh...?  Anyway, I guess I must try harder...)

Trying harder:

Backquotes means quoting a list (quoting a list I, sort of, knows what
means), in a way where you can evaluate parts of the list, by putting a
"," in front of them.

Ok, I understood that bit.  I also understood the example in the elisp
manual (comparing a regular quoted list, to a backqouted list with one
element comma'd and evaluated).

So, what's still unclear, is:
 1. Why backquote (or for that matter: "why quote?") the body of a
    defun?  What does that mean?
    #+begin_src emacs-lisp
      (defun gnus-sync-lesync-pre-save-group-entry (url nentry &rest passed-props)
        (let* ((loc "gnus-sync-lesync-save-group-entry")
               (k (car nentry))
               (revision (gnus-sync-lesync-get-prop 'rev k))
               (sname gnus-sync-lesync-name)
               (topic (gnus-group-topic k))
               (topic-offset (gnus-sync-topic-group-position k topic))
               (sources (gnus-sync-lesync-get-prop 'source k)))
          ;; set the revision so we don't have a conflict
          `(,@(when revision
          ...
    #+end_src
 2. What does ",@" mean?  "Splice the result of the evaluation into
    the list"...?  Ah... I think I actually understand now.  Looking
    at the elisp manual examples for ",@", I see that it means that if
    the result of the comma-evaluation is a list, the elements are
    added as element of the list, not as a single element that is a
    list.

And the backqoute is just a convenient way of constructing a list.

This means that the gnus-sync-lesync-pre-save-group-entry function
returns a list.  And that list, is:
 - If there is a revision, start the list with the symbol '_rev
   followed by the revision
 - Then the list will have an element that is a two element list,
   consisting of the symbol '_id and the first element of the nentry
   argument to the function (I don't understand why you have to have
   the "." there, though...?)
 - Then passed props are spliced in (what happens if there is no
   passed-props argument sent to the function?  It's optional...?)
 - Then an element that is a list starting with "source" (whatever
   that is), followed by the result of evaluating the "if"
 - Then an element that is a two element list starting with 'level and
   with a number(?) as the second element
 - Then splice in the elements resulting from evaluating two "if"s
   relating to topics
 - Then an element that is a list containing the read marks
 - Then an element that is a list containing other marks, and this is
   the one that broke down for me, because it got a conflict marker
   instead of the other marks

And I'm guessing this list is a translation of JSON into lisp lists...




  reply	other threads:[~2011-12-10  8:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23 19:55 gnus-sync-save fails with "wrong-type-argument number-or-marker-p" Steinar Bang
2011-11-23 20:27 ` Steinar Bang
2011-12-06 21:17   ` Steinar Bang
2011-12-08 14:50     ` Ted Zlatanov
2011-12-08 19:07       ` Steinar Bang
2011-12-10  7:11         ` Steinar Bang
2011-12-10  7:29           ` Steinar Bang
2011-12-10  8:10             ` Steinar Bang [this message]
2011-12-10  9:04               ` Backquotes and commas and ",@" Andreas Schwab
2011-12-10  9:52                 ` Steinar Bang
2011-12-10 10:39               ` Ted Zlatanov
2011-12-10 11:07         ` gnus-sync-save fails with "wrong-type-argument number-or-marker-p" Ted Zlatanov
2011-12-10 14:19           ` Steinar Bang
2011-12-10 14:45             ` Steinar Bang
2011-12-10 14:49               ` Steinar Bang

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sjkskfsg.fsf_-_@dod.no \
    --to=sb@dod.no \
    --cc=ding@gnus.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 NNTP newsgroup(s).