help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Meta-code confusion


From: Doug Lewan
Subject: Meta-code confusion
Date: Fri, 10 Aug 2012 19:12:08 +0000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]