unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lawrence Mitchell <wence@gmx.li>
Subject: Re: Weird &key arglists in ibuf-macs.el
Date: Mon, 10 May 2004 16:11:08 +0100	[thread overview]
Message-ID: <?fnord?871xls71wz.fsf@ID-97657.usr.dfncis.de> (raw)
In-Reply-To: 20040510142830.5C84.JMBARRANQUERO@wke.es

Juanma Barranquero wrote:

> ibuf-macs.el contains a few macros with CL-style arglists of the form

>   (defmacro* macro1 (arg1 arg2 (&key arg3 arg4)...)

> instead of

>   (defmacro* macro1 (arg1 arg2 &key arg3 arg4...)

> I'm not sure that's a legal CL lambda list

It is legal, see section 3.4.4.1 of the hyperspec <URL:
http://www.lispworks.com/reference/HyperSpec/Body/03_dda.htm>.

|  Anywhere in a macro lambda list where a parameter name can
|  appear, and where ordinary lambda list syntax (as described in
|  Section 3.4.1 (Ordinary Lambda Lists)) does not otherwise allow
|  a list, a destructuring lambda list can appear in place of the
|  parameter name. When this is done, then the argument that would
|  match the parameter is treated as a (possibly dotted) list, to
|  be used as an argument list for satisfying the parameters in the
|  embedded lambda list. This is known as destructuring.

It's often used for with-FOO type macros, e.g.

(defmacro* with-foo ((&key x y z &rest stuff) &body more-stuff)
  ...)

allowing

(with-foo (:x x :y y :z z (more-stuff))
  (doing-more-stuff))

> help-make-usage and company don't grok them:

> ELISP> (documentation (defmacro* test1 (arg1 &key arg2) "No doc"))
> "No doc\n\n(fn ARG1 &key ARG2)"
> ELISP> (documentation (defmacro* test1 (arg1 (&key arg2)) "No doc"))
> "No doc\n\n(fn ARG1 (&KEY arg2))"

The thing to do here is to explicitly write the arglist in the
end of the docstring.

(documentation (defmacro* test1 (arg1 (&key arg2))
                  "No doc\n\n(fn ARG1 (&key ARG2))"))
   => No doc\n\n(fn ARG1 (&key ARG2))

-- 
Lawrence Mitchell <wence@gmx.li>

  reply	other threads:[~2004-05-10 15:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-10 12:34 Weird &key arglists in ibuf-macs.el Juanma Barranquero
2004-05-10 15:11 ` Lawrence Mitchell [this message]
2004-05-10 17:11   ` Juanma Barranquero
2004-05-10 17:35     ` Juanma Barranquero

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='?fnord?871xls71wz.fsf@ID-97657.usr.dfncis.de' \
    --to=wence@gmx.li \
    /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.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).