Skip to Content.
Sympa Menu

texmacs-users - Re: [TeXmacs] evaluate a whole session at once 2

Subject: mailing-list for TeXmacs Users

List archive

Re: [TeXmacs] evaluate a whole session at once 2


Chronological Thread 
  • From: Henri Lesourd <address@hidden>
  • To: Bernd Hahnebach <address@hidden>
  • Cc: address@hidden
  • Subject: Re: [TeXmacs] evaluate a whole session at once 2
  • Date: Sat, 08 Apr 2006 19:10:45 +0200

Bernd Hahnebach wrote:

I already sent following e-mail to list 8 days ago, no answer.
I just would like to know if its possible or not?
Bernd



I could not find out how to calculate a whole session at once.

I use texmacs for structural engineering calculations of the following
style:

- some input values.
- some equations.
- output values.

If only one input value changes I have to press more than 10 times
return. This is really annoying. I read documentation --> no success.

I tried Document -> Update -> All --> no success.

Am I missing something or is it just no possible to evaluate a whole
session at once.


thanks
Bernd

What you can do is write a program that moves the cursor
at the first line of the session, and emulates the Carriage-Return
keyboard action repeatedly using (emulate-keyboard). This way,
all the commands are reevaluated one after the other.

You will find the Scheme code to do this, and an example TeXmacs
file as attachments to this e-mail. For turning this piece of
code in something reuseable (i.e., turning it into a small TeXmacs
plugin), you can have a look at my TeXmacs page, in :
<<
http://www.ags.uni-sb.de/~henri/texmacs/aTeXmacsTutorial.pdf
>>

For more details about Scheme programming in TeXmacs, have a look
at :
<<
http://www.texmacs.org/cgi-bin/cvsweb.cgi/doc/devel/scheme/
>>

(These files are temporarily missing from the standard TeXmacs
help package, this is why you have to get them from the CVS).

Best, Henri

P.S. : Thank you for suggesting this idea, it is indeed a
(currently) missing feature in TeXmacs. Now we have a 1st
implementation.
(define-macro (foreach-number i . b)
`(do ((,(car i) ,(cadr i)
(,(if (memq (caddr i) '(> >=)) '- '+) ,(car i) 1))
)
((,(if (eq? (caddr i) '>)
'<=
(if (eq? (caddr i) '<)
'>=
(if (eq? (caddr i) '>=) '< '>)))
,(car i) ,(cadddr i)
)
,(car i)
)
,(cons 'begin b))
)
(define (tm-valid-inner-path? p)
(and (pair? p) (> (length p) 2))
)
(define (tm-inner-atomic-path? p)
(and (tm-valid-inner-path? p)
(not (tm-eol-path? p))
(or (tree-atomic? (path->tree (cDr p)))
(eq? (tree-label (path->tree p)) 'string)))
)
(define (tm-eol-path? p)
(and (tm-valid-inner-path? p)
(<= (tree-arity (path->tree (cDr p))) (cAr p)))
)
(define (tm-upper-path p tags)
(if (or (tm-inner-atomic-path? p)
(tm-eol-path? p)
)
(set! p (cDr p)))
(if (in? (tree-label (path->tree p)) tags)
p
(if (> (length p) 2)
(tm-upper-path (reverse (cdr (reverse p))) tags)
#f))
)
(define (how-many-inputs l)
(define res 0)
(with n (tree-arity l)
(foreach-number (i 0 < n)
(if (eq? (tree-label (path->tree (append (tree->path l) `(,i))))
'input)
(set! res (+ res 1))))
)
res
)
(define (replay-session)
(with p (tm-upper-path (cursor-path) '(session))
(if p
(with n (how-many-inputs (path->tree (append p '(0))))
;(display* "p=" p "\n")
;(display* "n=" n "\n")
(go-to (append p '(0 0 1 0 0)))
(foreach-number (i 0 < n)
(emulate-keyboard "return")
)
(emulate-keyboard "C-backspace")
(emulate-keyboard "backspace")
(emulate-keyboard "backspace"))))
)
(kbd-map ("C-S-return" (replay-session)))
<TeXmacs|1.0.6>

<style|generic>

<\body>
<underline|An example with a simple replay> :

<with|prog-language|scheme|prog-session|default|<\session>
<\input|scheme] >
(display "Hello\\n") ;; This is the position '(0 1 4 0 0 1 0 0)
</input>

<\input|scheme] >
(begin (go-to '(0 1 4 0 0 1 0 0))(emulate-keyboard "return"))
</input>

<\output>
\;
</output>
</session>>

<underline|An example with a multiple replay> :

<with|prog-language|scheme|prog-session|default|<\session>
<\input|scheme] >
(display "1") ;; This is the position '(0 3 4 0 0 1 0 0)
</input>

<\input|scheme] >
(display "2")
</input>

<\input|scheme] >
(display "3")
</input>

<\input|scheme] >
(begin (go-to '(0 3 4 0 0 1 0 0))(emulate-keyboard
"return")(emulate-keyboard "return")(emulate-keyboard "return"))
</input>

<\output>
\;
</output>
</session>>

<hrule>

<underline|Loading the code> :

<with|prog-language|scheme|prog-session|default|<\session>
<\input|scheme] >
(load "replaySession.scm")
</input>

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

<underline|The session to be replayed> (once the
<with|font-family|tt|(load)> above has been performed, use
<with|font-family|tt|Shift-Ctrl-Return>) :

<with|prog-language|scheme|prog-session|default|<\session>
<\input|scheme] >
(display "1")
</input>

<\input|scheme] >
(display "2")
</input>

<\input|scheme] >
(display "3")
</input>

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

\;
</body>

<\initial>
<\collection>
<associate|page-type|letter>
<associate|preamble|false>
</collection>
</initial>


Archive powered by MHonArc 2.6.19.

Top of Page