On Thu, Oct 26, 2006 at 10:23:17AM +0200, Lionel Elie Mamane wrote:
> On Tue, Oct 24, 2006 at 02:40:35PM +0200, Lionel Elie Mamane wrote:
>>
>> <assign|input|<macro|prompt|body|<coq-orig-input|<with|color|<if|<equal|<value|prog-language>|coq>|<extern|coq-prompt-colour>|<value|color>>|<arg|prompt>>|<arg|body>>>>
>> where coq-prompt-colour is a secure Scheme procedure that will return
>> the colour the thing should be in.
> 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. I thus propose the following:
> add an environmental variable "self" or "self-path" that evaluates
> to the path of the <value> node that asks it value. That is
> <value|self> would evaluate to (a suitable encoding) of the path to
> the value node.
> Would you willing to take a patch for that?
Here's that patch. Documentation: <value|self-path> now evaluates to
an unspecified encoding of the path to the "value" node in the
document tree. The scheme function decode-self-path decodes that
encoding into a path like tree->path gives.
--
Lionel
Index: TeXmacs/progs/kernel/library/tree.scm
===================================================================
RCS file: /texmacs/src/TeXmacs/progs/kernel/library/tree.scm,v
retrieving revision 1.9
diff -u -r1.9 tree.scm
--- TeXmacs/progs/kernel/library/tree.scm 13 Jun 2006 10:59:11 -0000
1.9
+++ TeXmacs/progs/kernel/library/tree.scm 26 Oct 2006 12:12:32 -0000
@@ -38,11 +38,17 @@
(tree->string t)
(cons (tree-label t) (tree-children t))))
+(define (ip->path ip)
+ (and (or (null? ip) (!= (cAr ip) -5))
+ (reverse ip)))
+
+(define-public (decode-self-path t)
+ (let ((ip (map string->number (string-split (tree->string t) #\.))))
+ (ip->path ip)))
+
(define-public (tree-get-path t)
(and (tree? t)
- (let ((ip (tree-ip t)))
- (and (or (null? ip) (!= (cAr ip) -5))
- (reverse ip)))))
+ (ip->path (tree-ip t))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Navigation inside trees
Index: src/Typeset/Concat/concat_macro.cpp
===================================================================
RCS file: /texmacs/src/src/Typeset/Concat/concat_macro.cpp,v
retrieving revision 1.21
diff -u -r1.21 concat_macro.cpp
--- src/Typeset/Concat/concat_macro.cpp 15 Jun 2006 16:18:45 -0000 1.21
+++ src/Typeset/Concat/concat_macro.cpp 26 Oct 2006 12:12:33 -0000
@@ -179,6 +179,7 @@
return;
}
string name= r->label;
+ if (name == "self-path") return typeset_dynamic(tree(as_string(ip)),ip);
if (!env->provides (name)) {
typeset_error (t, ip);
return;
Index: src/Typeset/Env/env_exec.cpp
===================================================================
RCS file: /texmacs/src/src/Typeset/Env/env_exec.cpp,v
retrieving revision 1.92
diff -u -r1.92 env_exec.cpp
--- src/Typeset/Env/env_exec.cpp 31 Aug 2006 22:32:46 -0000 1.92
+++ src/Typeset/Env/env_exec.cpp 26 Oct 2006 12:12:33 -0000
@@ -583,6 +583,7 @@
edit_env_rep::exec_value (tree t) {
tree r= exec (t[0]);
if (is_compound (r)) return tree (ERROR, "bad value");
+ if (r->label == "self-path") return tree(as_string(obtain_ip(t)));
return exec (read (r->label));
}
_______________________________________________
Texmacs-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/texmacs-dev