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: Henri Lesourd
Subject: Re: [Texmacs-dev] New special env variable: path to self
Date: Thu, 23 Nov 2006 15:10:19 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

Lionel Elie Mamane wrote:

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

No, this is not the real root cause of your problem : the root
cause is that if the trees you get as an input of your macro
are **expanded** trees, by their very nature they **cannot**
be part of the document, and therefore they have no meaningful
path.


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.

Forget it, there are much simpler ways to do it, provided you remember
the difference between expanded and non-expanded markup, and that
only the latter kind can be referred directly from Scheme via a simple
pointer (and therefore, have a real path pointing it from the root of
the buffer tree).


You see?
Have a look at the attached .tm file, and tell me if you can
still trick it the way you did in the examples of your previous
mail (i.e., try to interactively change the parameter of
the two instances of the <self-path*|...> macros in the
document). I guess that as far as the <self-path|...> macro
is concerned, you can't trick it anymore, now ;-).


Best, Henri
<TeXmacs|1.0.6.6>

<style|generic>

<\body>
  1/ Validate the (my-scheme-macro) definition below

  <with|prog-language|scheme|prog-session|default|<\session>
    <\input|scheme] >
      (tm-define (my-scheme-macro parm)

      \ \ \ (:type (tree -\<gtr\> tree))

      \ \ \ (with path (tree-\<gtr\>path parm)

      \ \ \ \ \ \ (display* "\\nparm(" path ")=" parm "\\n"))

      \ \ \ '(arg "x"))
    </input>

    <\output>
      (100 (tree -\<gtr\> tree))
    </output>

    <\input|scheme] >
      \;
    </input>
  </session>>

  . and then, activate the markup by means of
  Document-\<gtr\>View-\<gtr\>Edit source tree.

  <hrule>

  2/ You can have a look at the code of the two macros
  \<less\>self-path-buggy\<gtr\> and \<less\>self-path\<gtr\> below, the
  trick is not to forget using \<less\>quote-arg\<gtr\>, and it seems it
  works with this (to clearly see the difference do a go and comeback to
  Document-\<gtr\>View-\<gtr\>Edit source tree).

  <assign|self-path-buggy|<macro|x|<extern|my-scheme-macro|<arg|x>>>>

  <drd-props|self-path-buggy|arity|1|accessible|all>

  <self-path-buggy|<block|<tformat|<table|<row|<cell|<underline|abcde (the
  buggy one : observe that the markup is expanded)>>>>>>>

  <assign|self-path|<macro|x|<extern|my-scheme-macro|<quote-arg|x>>>>

  <drd-props|self-path|arity|1|accessible|all>

  <self-path|<block|<tformat|<table|<row|<cell|<underline|abcde> (the right
  one : observe that the markup is non-expanded)>>>>>>
</body>

<\initial>
  <\collection>
    <associate|preamble|true>
  </collection>
</initial>

reply via email to

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