all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Subject: Re: elisp macros problem
Date: 24 Jul 2004 21:00:01 +0200	[thread overview]
Message-ID: <x5n01pdydq.fsf@lola.goethe.zz> (raw)
In-Reply-To: cduad9$7tg$1@mughi.cs.ubc.ca

Lowell Kirsh <lkirsh@cs.ubc.ca> writes:

> I am defining an emacs lisp macro to do:
> 
> (my-add-hook 'lisp
>     ...)
> 
> which should give:
> 
> (add-hook 'lisp-mode-hook
>    (lambda () ...))
> 
> I have:
> 
> (defmacro my-add-hook (hook &rest body)
>    (let ((tempvar (make-symbol "cat")))
>      `(flet ((,tempvar (sym str)
>                        (make-symbol (concat (symbol-name sym) str))))
>         (add-hook (cat ,hook "-mode-hook") (lambda () ,@body)))))
> 
> Does anyone know what's wrong with this and why it doesn't work?

I don't know where to start...

First of all, your use of flet is complete nonsense.  You flet an
uninterned symbol with the name "cat" to some function.  However, you
never use that function.  Instead you are trying to call the interned
symbol "cat" (which is probably undefined).  Even if one fixed that,
it is completely unnecessary.  Just do

(defmacro my-add-hook (hook &rest body)
  `(add-hook ',(intern (concat (symbol-name hook) "-mode-hook"))
        (lambda () ,@body)))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  reply	other threads:[~2004-07-24 19:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-24 18:39 elisp macros problem Lowell Kirsh
2004-07-24 19:00 ` David Kastrup [this message]
2004-07-24 22:08   ` Lowell Kirsh
2004-07-24 23:41     ` David Kastrup
2004-07-25  1:58       ` Lowell Kirsh
2004-07-25 10:59         ` Kalle Olavi Niemitalo
2004-07-24 19:15 ` Barry Margolin
2004-07-24 19:59   ` Pascal Bourguignon
2004-07-24 20:50     ` David Kastrup
2004-07-24 21:49       ` Lowell Kirsh
2004-07-26  1:35 ` Lowell Kirsh
2004-07-26  1:55   ` Rahul Jain
2004-07-26  2:53     ` Lowell Kirsh
2004-07-26  4:05       ` Pascal Bourguignon
2004-07-26  4:13         ` Lowell Kirsh
2004-07-26  2:54     ` Lowell Kirsh
2004-07-26 22:16       ` Kalle Olavi Niemitalo
2004-07-26 22:58       ` Kevin Rodgers
2004-07-26  2:03   ` Barry Margolin
2004-07-26  3:06     ` Lowell Kirsh
2004-07-26  4:49       ` Barry Margolin
2004-07-26  5:20         ` Pascal Bourguignon
2004-07-26  6:10       ` Oliver Scholz
2004-07-26  5:55   ` David Kastrup
2004-07-27  6:38     ` Lowell Kirsh
2004-07-27  6:54     ` Lowell Kirsh
2004-07-27  7:14       ` David Kastrup
2004-07-27  8:10         ` Lowell Kirsh
2004-07-27 12:05           ` Pascal Bourguignon
2004-07-28  5:03             ` Rob Warnock
2004-07-31 20:46             ` Lowell Kirsh
2004-08-03 18:44               ` Michael Slass
2004-07-27 23:22         ` Barry Fishman

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=x5n01pdydq.fsf@lola.goethe.zz \
    --to=dak@gnu.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.
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.