From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Berndl Newsgroups: gmane.emacs.help Subject: Re: defining many similar functions using macros Date: 03 Oct 2004 07:31:20 +0200 Organization: "sd&m AG, Muenchen, Germany" Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1096782226 20952 80.91.229.6 (3 Oct 2004 05:43:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 3 Oct 2004 05:43:46 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 03 07:43:41 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CDz9o-0004xE-00 for ; Sun, 03 Oct 2004 07:43:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CDzGL-00012W-7S for geh-help-gnu-emacs@m.gmane.org; Sun, 03 Oct 2004 01:50:25 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!bnewsoutpeer01.bru.ops.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!emea.uu.net!news.sdm.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 48 Original-NNTP-Posting-Host: callin54.muc.sdm.de Original-X-Trace: news.sdm.de 1096781479 21932 195.125.139.54 (3 Oct 2004 05:31:19 GMT) Original-X-Complaints-To: usenet@news.sdm.de Original-NNTP-Posting-Date: Sun, 3 Oct 2004 05:31:19 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Original-Xref: shelby.stanford.edu gnu.emacs.help:125660 X-Originally-To: Joe Corneli Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:21019 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:21019 On Sat, 02 Oct 2004, Joe Corneli wrote: [...] > This macro works on single elements: > > (defmacro define-tex-symbol (name) > `(defun ,(intern (concat "tex-" name)) () > (interactive) > (insert "\\" ,name))) > > E.g. (define-tex-symbol "alpha") ;=> tex-alpha > > But > > (dolist (elt '("alpha" > "beta")) > (define-tex-symbol elt)) > > triggers an error: > > Debugger entered--Lisp error: (wrong-type-argument sequencep elt) > concat("tex-" elt) (intern (concat "tex-" name)) (list (quote defun) > (intern (concat "tex-" name)) nil (quote (interactive)) (list (quote > insert) "\\" name)) > ... > > There seem to be some subtleties associated with macro expansion > that I'm missing here. Help would be appreciated. Try: (dolist (elt '("alpha" "beta")) (eval `(define-tex-symbol ,elt))) Do not know if there are other and better solutions but this works! Ciao, Klaus -- Klaus Berndl mailto: klaus.berndl@sdm.de sd&m AG http://www.sdm.de software design & management Carl-Wery-Str. 42, 81739 Muenchen, Germany Tel +49 89 63812-392, Fax -220