texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] trees


From: Miguel de Benito Delgado
Subject: Re: [Texmacs-dev] trees
Date: Mon, 1 Oct 2012 20:29:36 +0200

If I follow you correctly, I think you can work the other way around: select the trees that interest you and compare their paths to the current one:

If you have some macro like this one:

<assign|nf-chunk|<macro|name|code|arg|This is chunk: <arg|name>. It has
second argument: <arg|code>>>

Then, with

  (select (buffer-tree) '(:* nf-chunk 0))

you get the list of all names of all occurrences of such macro in your document. Since trees remember their paths, you can now use tree->path on each element of that list and compare with the cursor-path. You may also want to check the macro with-innermost in the documentation which will traverse the tree recursively upwards looking for a given tag.

However, you have the choice of redefining your nf-chunk macro to set an environment variable (say, "current-nf-chunk" to the value you want, then read that variable at any point in your document to decide where you are.

Best,
________________
Miguel de  Benito.


On Mon, Oct 1, 2012 at 4:56 PM, Michael Lachmann <address@hidden> wrote:
Hi!

I'm having problems with trees. Where is the best documentation of how
to handle them?

I'm trying to do the following:

My document uses the fangle package, so it includes in it things like this
<nf-chunk | name_of_chunk1 | code1 |  cpp | >
<nf-chunk | name_of_chunk2 | code2 |  cpp | >

What I am trying to calculate is the name of the chunk I am on, or
that I'm after.

(This means that after or in the 2nd chunk, I want to get
name_of_chunk2, and in the 1st chunk , or between 1 and 2 I want to
get name_of_chunk1)

The easiest way I found to do this is to take (cursor-path), and
first, go over all its possible heads (0...m), and then check if
(object->string  (car (tree->list( path->tree HEAD-OF-CURSOR_PATH) )) )
contains "nf-chunk".
If not, then go up the same heads, and check if (select Tree
'(nf-chunk)) sees something.

This, in the end will be very complicated....

Is there an easier way to do this? I don't think I'm using 'select',
trees, and the cursor correctly...

Thanks!
Michael

--

Michael Lachmann, Max Planck Institute for Evolutionary Anthropology
Deutscher Platz 6, 04107 Leipzig, Germany.

_______________________________________________
Texmacs-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/texmacs-dev


reply via email to

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