texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] New special env variable: path to self


From: Lionel Elie Mamane
Subject: Re: [Texmacs-dev] New special env variable: path to self
Date: Thu, 23 Nov 2006 12:04:33 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On Thu, Oct 26, 2006 at 05:40:28PM +0200, Henri Lesourd wrote:
> Lionel Elie Mamane wrote:

>> The problem is that as far as I can determine, there is no way for
>> that scheme procedure to know the position in the document of the
>> node being typeset.

> It seems to me that there is a very easy way to determine the path of
> a parameter of a Scheme macro, it is :
> <<
> (tm-define (my-scheme-macro parm)
>  (:type (tree -> tree))
>  (with path (path->tree parm)
>     blah
>     .......
> )
> >>

I did some further testing and it seems that this works in normal
circumstances only if the parameter is a string tree and not a
compound tree (such as a concat). On the other hand, the solution with
my patch seems to work in some cases where (tree->path) does not and
not to work in some cases where (tree->path) does work. And adding an
_empty_ argument just for path-tracking sake seems to do as well as my
patch. I don't completely understand what's going on.

Let me describe exactly what I do:

My style files have:

  <assign|coq-orig-input|<value|input>>
  
<assign|input|<macro|prompt|body|<extern|show-path|<arg|prompt>|<arg|body>|<value|self-path>|>>>

and the scheme function show-path is:

(tm-define (show-path t t0 s p)
  (:secure #t)
  (display "show-path ")(write (tree->path t))(newline)
  (write (tree->path t0))(newline)
  (write (decode-self-path s))(newline)
  (write (tree->path p))
  (list 'coq-orig-input t t0))

I remind you that "decode-self-path" and <value|self-path> are
introduced by my patch.

Then, if my markup looks like:

<\session>
  <input|$PROMPT|$INPUT>
 </session>

If the child 0 of input (the $PROMPT) is a string tree, then when
editing the child 1 of the input node (the $INPUT), I get for every
keystroke (interactive modification to the $INPUT):

show-path (0 0 1 0 4 0 1 0)
#f
(0 0 1 0 4 0 1 -4)
(0 0 1 0 4 0 1 -4)
show-path (0 0 1 0 4 0 1 0)
#f
#f
#f

But if the $PROMPT is a concat (e.g. because it contains both string
elements and <with|mode|math|x> elements), I get:

show-path #f
#f
(0 0 1 0 4 0 1 -4)
(0 0 1 0 4 0 1 -4)
show-path #f
#f
#f
#f

Similarly, if I do programmatically:

 (path-assign (tree->path t) t)

where t is the child 0 of the input node, then I get:

show-path (0 0 1 0 4 0 1 0)
#f
(0 0 1 0 4 0 1 -4)
(0 0 1 0 4 0 1 -4)

and

show-path #f
#f
(0 0 1 0 4 0 1 -4)
(0 0 1 0 4 0 1 -4)


You see?

-- 
Lionel




reply via email to

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