all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How does one use a macro in a special form?
@ 2003-06-28 13:23 Alan Mackenzie
  2003-06-28 18:00 ` Daniel Jensen
  2003-06-29 12:39 ` Kai Großjohann
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Mackenzie @ 2003-06-28 13:23 UTC (permalink / raw)


In particular, I want to use a macro acm-indent++ within a let (or let*),
something like this:

(let ((a a-binding)
      (b b-binding)
      ,(acm-indent++))
  FORMS)

and I want it to expand to this:

(let ((a a-binding)
      (b b-binding)
      (indent-spaces (concat indent-spaces "    ")))
  FORMS)

The macro acm-indent++ looks like this:

(defmacro acm-indent++ ()
  "Increase the level of indentation in an acm-printf output by binding indent-spaces.
This form must appear \"comma\"d in a let/let* variable list."
  `(indent-spaces (concat indent-spaces "    ")))

Thus far, I'm having no luck with it, the value of indent-spaces
remaining unchanged within the let form.

Question:  does the "," operator have meaning when not within a backquote
expression?

Is it possible to do what I want to do, and if so, how do I go about it?

Thanks in advance for any help!

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: How does one use a macro in a special form?
  2003-06-28 13:23 How does one use a macro in a special form? Alan Mackenzie
@ 2003-06-28 18:00 ` Daniel Jensen
  2003-06-28 18:17   ` Alan Mackenzie
  2003-06-29 12:39 ` Kai Großjohann
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jensen @ 2003-06-28 18:00 UTC (permalink / raw)


Alan Mackenzie<none@example.invalid> writes:

> In particular, I want to use a macro acm-indent++ within a let (or let*),

You can't. Let is a special form and does not follow conventional
evaluation rules.

> The macro acm-indent++ looks like this:
>
> (defmacro acm-indent++ ()
>   "Increase the level of indentation in an acm-printf output by binding indent-spaces.
> This form must appear \"comma\"d in a let/let* variable list."
>   `(indent-spaces (concat indent-spaces "    ")))

Use something like this instead:

(defmacro with-extra-indent-spaces (&rest body)
  `(let ((indent-spaces (concat indent-spaces "    ")))
    ,@body))

(let (...)
  (with-extra-indent-spaces
    ...))

> Question:  does the "," operator have meaning when not within a backquote
> expression?

No. Then it's just a character. It is only an "operator" inside
backquoted forms.

-- 
Daniel Jensen
Editing is a rewording activity.

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

* Re: How does one use a macro in a special form?
  2003-06-28 18:00 ` Daniel Jensen
@ 2003-06-28 18:17   ` Alan Mackenzie
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Mackenzie @ 2003-06-28 18:17 UTC (permalink / raw)


Daniel Jensen <daniel-news@bigwalter.net> wrote on Sat, 28 Jun 2003
20:00:48 +0200:
> Alan Mackenzie<none@example.invalid> writes:

>> In particular, I want to use a macro acm-indent++ within a let (or let*),

> You can't. Let is a special form and does not follow conventional
> evaluation rules.

>> The macro acm-indent++ looks like this:
>>
>> (defmacro acm-indent++ ()
>>   "Increase the level of indentation in an acm-printf output by binding indent-spaces.
>> This form must appear \"comma\"d in a let/let* variable list."
>>   `(indent-spaces (concat indent-spaces "    ")))

> Use something like this instead:

> (defmacro with-extra-indent-spaces (&rest body)
>   `(let ((indent-spaces (concat indent-spaces "    ")))
>     ,@body))

> (let (...)
>   (with-extra-indent-spaces
>     ...))

>> Question:  does the "," operator have meaning when not within a
>> backquote expression?

> No. Then it's just a character. It is only an "operator" inside
> backquoted forms.

Many thanks for the chrystal clear answers.  I think for this thing, I'll
just write out the indent-spaces thing in longhand each time I need it.

> Daniel Jensen

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

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

* Re: How does one use a macro in a special form?
  2003-06-28 13:23 How does one use a macro in a special form? Alan Mackenzie
  2003-06-28 18:00 ` Daniel Jensen
@ 2003-06-29 12:39 ` Kai Großjohann
  2003-06-29 13:07   ` Daniel Jensen
  1 sibling, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2003-06-29 12:39 UTC (permalink / raw)


Alan Mackenzie<none@example.invalid> writes:

> In particular, I want to use a macro acm-indent++ within a let (or let*),
> something like this:
>
> (let ((a a-binding)
>       (b b-binding)
>       ,(acm-indent++))
>   FORMS)

You could write a macro that allows you to say

    (with-acm-indent++
      (let ((a a-binding)
            (b b-binding))
        FORMS))

Something like this might work:

(defmacro with-acm-indent++ (&rest body)
  `(let ((indent-spaces (concat indent-spaces "    ")))
     ,body))

I haven't tested it, but maybe you get the idea.
-- 
~/.signature

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

* Re: How does one use a macro in a special form?
  2003-06-29 12:39 ` Kai Großjohann
@ 2003-06-29 13:07   ` Daniel Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jensen @ 2003-06-29 13:07 UTC (permalink / raw)


kai.grossjohann@gmx.net (Kai Großjohann) writes:

> Something like this might work:
>
> (defmacro with-acm-indent++ (&rest body)
>   `(let ((indent-spaces (concat indent-spaces "    ")))
>      ,body))
>
> I haven't tested it, but maybe you get the idea.

That's funny, this is almost exactly what I wrote. The exception is
that your version doesn't work because you use ',' instead of ',@'.

-- 
Daniel Jensen
Editing is a rewording activity.

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

end of thread, other threads:[~2003-06-29 13:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-28 13:23 How does one use a macro in a special form? Alan Mackenzie
2003-06-28 18:00 ` Daniel Jensen
2003-06-28 18:17   ` Alan Mackenzie
2003-06-29 12:39 ` Kai Großjohann
2003-06-29 13:07   ` Daniel Jensen

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.