Gnus development mailing list
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: ding@gnus.org
Subject: Re: deffoo?
Date: Mon, 18 May 2015 03:36:56 +0200	[thread overview]
Message-ID: <87bnhi4qfb.fsf@debian.uxu> (raw)
In-Reply-To: <87lhgmzo4a.fsf@vostro.rath.org>

Nikolaus Rath <Nikolaus@rath.org> writes:

> One thing I stumbled upon is the use of "deffoo" and
> "defvoo". The help did not help me at all ("The same
> as `defun', only register FUNC").
>
> Can someone explain what this macros do / how they
> differ from defun / defvar?

Use the source, Luke!

    (defmacro deffoo (func args &rest forms)
      "The same as `defun', only register FUNC."
      `(prog1
           (defun ,func ,args ,@forms)
         (nnoo-register-function ',func)))

So the difference is nothing more than

    (nnoo-register-function ',func)

 - you could equally well do

    (defun make-soap () ...)
    (nnoo-register-function 'make-soap)

`nnoo-register-function' isn't documented, but it
is defined like this:

    (defun nnoo-register-function (func)
      (let ((funcs (nthcdr 3 (assoc (nnoo-backend func)
                nnoo-definition-alist))))
        (unless funcs
          (error "%s belongs to a backend that hasn't been declared" func))
        (setcar funcs (cons func (car funcs)))))

You can grep the Emacs and/or Gnus source to find out
when those vars are used (or search the Gnus manual) -
however, often this would be a backward way to
do things.

Rather, you will find `nnoo-register-function' when
you need it, and then you will understand exactly what
it does, is the way it works most of the time.

Good luck!

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




  reply	other threads:[~2015-05-18  1:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  1:11 deffoo? Nikolaus Rath
2015-05-18  1:36 ` Emanuel Berg [this message]
2015-05-18  2:16 ` deffoo? Nikolaus Rath
2015-05-18  2:28   ` deffoo? Emanuel Berg
2015-05-18 16:02     ` deffoo? Nikolaus Rath
2015-05-18 11:46 ` deffoo? Eric Abrahamsen
2015-11-05 20:30   ` deffoo? Ted Zlatanov
2015-11-06  9:12     ` deffoo? Eric Abrahamsen

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=87bnhi4qfb.fsf@debian.uxu \
    --to=embe8573@student.uu.se \
    --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).