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

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

Re: Check if a symbol is bound to a macro


From: Nordlöw
Subject: Re: Check if a symbol is bound to a macro
Date: Tue, 8 Dec 2009 14:17:15 -0800 (PST)
User-agent: G2/1.0

On Dec 8, 9:52 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <b240c2eb-6d28-410a-aa2d-4ea285685...@a32g2000yqm.googlegroups.com>,
>
>
>
>
>
>  Nordlöw <per.nord...@gmail.com> wrote:
> > Is there a way to query if a symbol is bound to a macro?
>
> > list-fns.el written by Noah Friedman provides the function
>
> > (defun macrop (x)
> >   "Return `t' if X is a macro, `nil' otherwise.
> > X may be a raw or byte-compiled macro.  No attempt is made to
> > determine if
> > the macro is actually well-formed (i.e. syntactically valid)."
> >   (cond ((not (consp x))
> >          nil)
> >         ((eq (car x) 'macro)
> >          (functionp (cdr x)))))
>
> > but it doesn't work for me.
> >   (macrop 'case)
> > returns nil.
>
> > Thanks,
> > Nordlöw
>
> macrop expects the function, not the function name, as its argument.  So
> you need to do:
>
> (defun named-macrop (symbol)
>   (and (fboundp symbol)
>        (macrop (symbol-function symbol))))
>
> --
> Barry Margolin, bar...@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***

Thanks!
/Per Nordlöw


reply via email to

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