all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Doug Lewan <dougl@shubertticketing.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: Meta-code confusion
Date: Fri, 10 Aug 2012 21:38:26 +0000	[thread overview]
Message-ID: <155DEC68569B714B86C2C7075F5EDA98268CCCE3@DAKIYA1.pegasus.local> (raw)
In-Reply-To: <155DEC68569B714B86C2C7075F5EDA98268CCCBB@DAKIYA1.pegasus.local>

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.

,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.
> 




  reply	other threads:[~2012-08-10 21:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 19:12 Meta-code confusion Doug Lewan
2012-08-10 21:38 ` Doug Lewan [this message]
     [not found] ` <mailman.6744.1344634688.855.help-gnu-emacs@gnu.org>
2012-08-10 22:02   ` Barry Margolin
2012-08-13 14:04     ` Doug Lewan
2012-08-13 16:44       ` Aurélien Aptel

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=155DEC68569B714B86C2C7075F5EDA98268CCCE3@DAKIYA1.pegasus.local \
    --to=dougl@shubertticketing.com \
    --cc=help-gnu-emacs@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.