[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get value of parameter in macro
From: |
Cecil Westerhof |
Subject: |
Re: How to get value of parameter in macro |
Date: |
Wed, 06 Jan 2010 17:49:30 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) |
Ted Zlatanov <tzz@lifelogs.com> writes:
> CW> I am trying my first stab at macro's. I want to define key bindings to a
> CW> jump to a group. I tried something like:
> CW> (defmacro gnus-group-jump-bind (key-binding group-to-jump-to)
> CW> (define-key gnus-group-mode-map key-binding
> CW> (lambda ()
> CW> (interactive)
> CW> (gnus-group-jump-to-group group-to-jump-to))))
>
> CW> (gnus-group-jump-bind "vjd" "nndraft:drafts")
>
> CW> The key binding is okay, but the lambda function not. This becomes:
> CW> (lambda nil (interactive) (gnus-group-jump-to-group group-to-jump-to))
>
> CW> instead of:
> CW> (lambda nil (interactive) (gnus-group-jump-to-group "nndraft:drafts"))
>
> CW> What do I need to do to get the value of group-to-jump-to instead of the
> CW> string?
>
> Read the manual section on macros again, and again, and again. It
> really takes a while. You are trying to find the , interpolation
> marker, e.g. ",group-to-jump-to" will become "nndraft:drafts" but again
> you should read the manual very thoroughly.
Found it:
(defmacro gnus-group-jump-bind (key-binding group-to-jump-to)
`(define-key gnus-group-mode-map ,key-binding
(lambda ()
(interactive)
(gnus-group-jump-to-group ,group-to-jump-to))))
When you know it, it is not difficult.
But I am still not out of the woods.
Instead of using:
(gnus-group-jump-bind "vjd" "nndraft:drafts")
I want to do something like:
(gnus-group-jump-bind this-key this-group)
But that does not work because the macro then does not receive a string,
but a symbol. I tried to work with symbol-value, but that did not work.
If you -or someone else- has another pointer ...
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof