From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Meta-code confusion Date: Fri, 10 Aug 2012 18:02:59 -0400 Organization: A noiseless patient Spider Message-ID: References: <155DEC68569B714B86C2C7075F5EDA98268CCCBB@DAKIYA1.pegasus.local> NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1344636318 14695 80.91.229.3 (10 Aug 2012 22:05:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Aug 2012 22:05:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 11 00:05:18 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SzxKT-0001IZ-AS for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Aug 2012 00:05:13 +0200 Original-Received: from localhost ([::1]:47839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzxKS-0000U1-Bf for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Aug 2012 18:05:12 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!news2.euro.net!newsfeed.freenet.ag!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 91 Injection-Info: barmar.motzarella.org; posting-host="78fb7125a45724f15e21604c94a7d968"; logging-data="20870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/20qjYNozaL5sjLc3cBgYr" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:eaui4LOcIx0l/qJMltCpSHeBDcA= Original-Xref: usenet.stanford.edu gnu.emacs.help:193939 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:86307 Archived-At: In article , Doug Lewan wrote: > Well, after a few more hours I have a work-around. I think the original > problem was because (defvar) is a special form, but I'm still not sure. > > The current work-around is to build a string that looks right and then (eval > (read THAT-STRING)) and let the results of that be the return value. I can't > see the interesting difference, but it does what I want. That's almost always the wrong thing. Rather than that, you should build a list (probably using backquote to fill in a template) and then (eval THAT-LIST). But more likely, you probably need to define your own macro rather than a function. > > ,Doug > > > -----Original Message----- > > From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org > > [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On > > Behalf Of Doug Lewan > > Sent: Friday, 2012 August 10 15:12 > > To: help-gnu-emacs@gnu.org > > Subject: Meta-code confusion > > > > I have development environment that has a handful of files with > > isomorphic (but not identical) structures. > > I'd like to use the same code to define modes for all of them, but > > clearly there are things I don't understand about writing meta-code in > > emacs lisp. > > > > As a starting point I'm failing with the following: > > > > (defvar *pp-symbol-re* "\\(?:\\s_\\|\\sw\\)") > > (defun ppm-define-vars (name abbreviation) > > "Build a list of vars for the new mode." > > (let* ((start-var-name (format "*pp-%s-start-re*" abbreviation)) > > (start-var (make-symbol start-var-name)) > > (start-re (list 'concat (format "^%s\\s-+" name) '*pp-symbol- > > re*))) > > (list (list 'defvar start-var start-re)))) > > > > I want all such functions to return a list of definitions of the type > > of interest. > > This one happens to return a list of one element, [I would like] a > > variable definition. > > It certainly looks like it's returning the right kind of thing: > > > > (car (ppm-define-vars "douglas" "dug")) > > => (defvar *pp-dug-start-re* (concat "^douglas\\s-+" *pp-symbol-re*)) > > > > And (eval) looks like it does the right thing: > > (eval (car (ppm-define-vars "douglas" "dug"))) > > => *pp-dug-start-re* > > > > (defvar) returns a symbol and (symbolp) confirms that that is a symbol. > > > > However, using *pp-dug-start-re* gets a void-variable error. > > On the other hand > > (boundp (eval (car (ppm-define-vars "douglas" "dug")))) > > => t > > which would seem to be a contradiction. > > > > I'm using > > GNU Emacs 24.1.1 (i686-pc-cygwin, GTK+ Version 2.24.10) of 2012-07-17 > > on fiona and > > GNU Emacs 24.1.1 (powerpc-ibm-aix6.1.0.0, X toolkit, Xaw scroll bars) > > of 2012-07-25 on devlpar1. > > > > I would gladly pay with a beer¹ to understand this better. > > > > ,Douglas > > Douglas Lewan > > Shubert Ticketing > > (201) 489-8600 ext 224 > > > > There is no national science just as there is no national > > multiplication table; what is national is no longer science. - Anton > > Checov > > _____________ > > ¹ "beer" is a variable, replace it with an appropriate value should > > beer be distasteful to you or otherwise inappropriate. > > -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***