texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] Environment at a tree


From: Henri Lesourd
Subject: Re: [Texmacs-dev] Environment at a tree
Date: Mon, 20 Nov 2006 20:55:21 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

Lionel Elie Mamane wrote:
Hi,

Given t a value of type tree in TeXmacs's scheme environment, is there
an easy way to find the value what a certain TeXmacs variable has at
that point in the document? Roughly, what the tree (value "foo") would
be if placed at the place of t. I mean, suppose that the tree-type
value points at the tree (here) in the following document:

 (with "foo" "bar"
   (document
     "blah"
     (with "foo" "baz"
        (session
          (document
            (input "$" "Go! Go!")
            (input (concat "$" (here) "%") "Back! Back!")
            (output "No luck here."))))))

I would get "baz". An "easy" way means short of doing tree-up until
one encounters a (with "foo" . .) or (with . . "foo" . .) or
 (with . . . . "foo" . .)
where "." stands for any tree. An easy way includes a library routine
that would do just that.

The function :
<<
(get-upwards-property path var)


in graphics-utils.scm does exactly what you want. This
function is not currently a 1st class function of the
TeXmacs libraries, thus I would suggest that you extract
it with all its dependencies (i.e., (find-prop), (tm-find-prop),
and especially (tm-upwards-path), which is the one that
performs going up in the tree), and that you put that
in a library of your own. At some point, this code will
probably become deprecated (although perhaps not the API),
but at least, this way you enjoy a simple implementation
of this traversal routine that only relies on the basic
tree primitives [i.e., (tree-label), (tree-ref) and (tree->path)].

There are also some interesting (but a little bit unpolished)
traversal primitives [i.e. (For) and (for@)] that I use
all the time in my code : adieu les fonctions recursives
a la mords-moi-le-noeud qu'on est oblige de tout le temps
se taper juste parce qu'il manque une boucle for pour
parcourir les arbres et les listes !


Best, Henri






reply via email to

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