mailing-list for TeXmacs Users

Text archives Help


Re: Hacking TeXmacs styles


Chronological Thread 
  • From: Nicolas Girard <address@hidden>
  • To: address@hidden
  • Subject: Re: Hacking TeXmacs styles
  • Date: Tue, 10 Dec 2002 15:54:43 +0100

Thank you for these informations, but i'm afraid i don't understand your
reaction. Could you please tell me where the troll is ?

You raised an interesting point for which i created a new thread:
"how to hack TeXmacs styles ?" ; at least it appears very important
to me. After reading your advice i had the feeling that your
way of hacking styles was very different than mine and i would
be glad to use the Right Way ; however:
-1- the use of default format has always been the most natural to me
-2- the use of scheme code isn't obvious to me

I certainly badly and quickly exposed these two points, but how could
you imagine i was trolling, while i was just trying to find a way
to make my styles work ???

So let me go into details:

-1- Maybe i should explain you how i've been hacking styles up to now,
and maybe i should stick to the problem from which this discussion
arised.

In fact the need to modify headers comes from one of my colleagues ;
i convinced our administrator to install a copy of TeXmacs for
everybody and succeeded in having several people discovering
TeXmacs ; but you'll understand that i can't go and tell our
admin once a week "come on ! time to upgrade TeXmacs to the
brand new version !" ; so as a first parenthesis i'd like
to say that it is natural for users to come to you with outdated
code, because sometimes they just have to deal with an
outdated-but-working installation.

Okay, so once i understood the guy's need, i browsed all *.ts
files and looked for everything that looked like "header". It
quickly appeared that the code responsible for article headers
was in the file 'packages/header/header-article.ts'

The next step was to create a file named 'my-article.ts', similar
to the file named 'article.ts', in which i put all relevant
code i could find in the file 'header-article.ts'. my-article
then looked something like:

<TeXmacs|1.0.0.17>

<style|<tuple|common-base|header-article|env-us|number-article|section-articl\
e>>

<\body>
<assign|my-article-style|1.0>

<assign|odd-page-text|<func|s|<assign|odd page header|<with|font
size|0.84|<format|no first indentation><with|font
shape|small-caps|<apply|s>><htab|5mm><quote|<apply|page number>>>>>>

<assign|even-page-text|<func|s|<assign|even page header|<with|font
size|0.84|<format|no first indentation><quote|<apply|page
number>><htab|5mm><with|font shape|small-caps|<apply|s>>>>>>

[.......]

Of course, code formatted like this is unreadable, so i re-arrange it before
any modifications, like the following chunk:

<assign|odd-page-text|<func|s|\
<assign|odd page header|<with|font size|0.84|\
<format|no first indentation>
<with|font shape|small-caps|<apply|s>>
<htab|5mm>
<quote|<apply|page number>>\
>>\
>>

Then i hack it until it works... most of time i'm successful,
and sometimes not ; in the late case i ask the mailing-list.
That's it.

I hope you'll agree that i could not invent the above macros, i had
to copy existing code to see how things worked, and it happened to come
to me as *default format* and not as scheme code. Hardly all my knowledge
of TeXmacs guts come from existing .tm and .ts files i hacked and played with,
and this is why i told you that in my situation this code is de facto the most
natural to me since it is the one i explored.

So please tell me what you think about my way of hacking styles,
which i thought to be straightforward. How do you personnally
hack styles ?

-2- As i had very few experience with scheme code, it has always seemed
obscure to me. And the more so as from previous conversations in the
mailing lists i got the (perhaps wrong) feeling that the conversion
between default format to scheme code was far from straightforward.
The reply i cited from you was an example of such conversation
wich i maybe misunderstood but gave me the feeling that 'all this
scheme stuff' was more complicated that the default code i used
to hack and that it would not be easy to translate.

What i'd like you to understand is that my knowledge of TeXmacs
is mostly empiric because up to now i just didn't find enough
time to try to understand TeXmacs' guts

So probably it would be very helpful if you could 'demistify' TeXmacs
scheme code, and especially tell me about the following points
i find particularly obscure:
- is there a simple reciepe to do the translation between the two formats?
Given a chunk of default code, how to translate it to scheme code, and
vice-versa ?
- is it possible to mix default format and scheme code in .ts files ?
- is it possible to use only scheme code in .ts files ?
- if the use of scheme code for styles is the Right Way, then why
do .ts files contain no scheme code ?
- how precisely do concats work ? i'm sorry but even after your last
explanation i still understand nothing to this ; i also read
this paragraph about concats in the documentation which just added to my
confusion:
" (concat t1 ... tn): Horizontal concatenation of the trees t1, ..., tn.
Often, but not always, the main edit tree are concatenations. "
~~~~~~~~~~~~~~~~~~~~~

And please, if you still see trolls in the above conversation,
consider having a break ! Remember: watching TV, having a bud...

Nicolas

On Tue, Dec 10, 2002 at 12:33:23PM +0100, address@hidden wrote:
> On Mon, Dec 09, 2002 at 06:25:59PM +0100, Nicolas Girard wrote:
> > On Mon, Dec 09, 2002 at 06:04:01PM +0100, address@hidden wrote:
> > >
> > > I advise you not to use the default format for hacking (and submitting
> > > snippets to the mailing list). It is difficult to read for style
> > > definitions and must be used very carefully to get the desired
> > > meaning.
> > >
> > Well the default format seems the most natural for me as it is the
> > on i can type in TeXmacs style files
>
> There have been some discussion on that point, and everyone (even
> Joris) seems to agree that the tm format is better for *documents*
> (data oriented), but the Scheme format is better for *styles* (program
> oriented).
>
> Well maybe one could add a wish like "save and use style files in
> Scheme format". Do not hesitate, the Bug Tracker is public.
>
>
> > So unless you give me a straightforward way of converting
> > a given scheme expression to a ready-to-cut-and-paste native
> > format, i'm afraid i'll go on using the default format...
>
> If you insist on writing style files by hand using emacs, I cannot
> help. But that is definitely not the Right Way. Scheme expressions
> *are* ready to cut and paste in style files if you edit them using
> TeXmacs.
>
> But if you are really commited to writing style files with an external
> editor, you may also use this:
>
> In ~/.TeXmacs/progs/my-init-texmacs.scm
>
> (define (string-to-object x) (with-input-from-string x read))
>
> In your style file
>
> (assign "scheme-tm" (func "x"
> (hold (extern "string-to-object" (release (value "x"))))))
>
> Then you can use scheme format directly in you style files
>
> (document
> (apply "scheme-tm"
> "(assign \"foo\" (concat (em \"Hello\") \", \" (strong\"world!\")))")
> (value "foo"))
>
>
> > As for exchanging tips and ideas through the mailing-lists,
> > i agree that the scheme format is more readeable but, as you
> > already pointed out in a previous mail:
> >
> > > There are very subtle problems in the typesetter with that kind of
> > > things.
> > >
> > > With "Tools->Selections->Export->Scheme" you will be able to see the
> > > internal structure of any document fragment. Actually, the internal
> > > structure is not Scheme, but that scheme format is the closest you can
> > > easily get.
> > >
> > > <assign|myenv|<macro|x|<argument|x>>>
> > > Gives
> > > (assign "myenv" (macro "x" (argument "x")))
> > > which is all very obvious. But
> > > <assign|myenv|<macro|x|Hello <argument|x>>>
> > > gives
> > > (assign "myenv" (macro "x" (concat "Hello " (argument "x"))))
> > > The extra concat is needed to put several elements (here, the string
> > > "Hello " and the argument) in a single parameter of the macro element.
>
> I do not see the relation.
>
> Those issue exists regardless of the representation you are using.
> Actually, since they are subtle, it is better to use a more explicit
> representation. The fact is one has to be aware of "these subtle
> things" to write correct style files.
>
> The tm file format is fine for documents because it make "document"
> and "concat" less obvious. So the reader can concentrate on the data.
> But it *only* make them less obvious, which is bad when your are
> designing style files where you have to know what you are doing.
> Reading the TM format was not a good way to learn about TeXmacs
> *because* it hides things.
>
> Anyway, to correctly use the tm format for all but trivial documents,
> you *have* to know where are concat and document nodes.
>
> > so one has to be aware of all these 'subtle' thing to be able to read
> > scheme code, which is not the case for common users, who IMHO learn
> > TeXmacs through .tm and .ts documents and not through the source code
>
> Wrong. Where subtle things happen is during typesetting. Whether you
> are using Scheme or TM format you have to know where are concats. You
> mistake with the "\;" was due to your confused understanding of that
> issue.
>
> Anyway you are trolling.
>
> --
> David Allouche | GNU TeXmacs -- Writing is a pleasure
> Free software engineer | http://www.texmacs.org
> http://ddaa.net | http://alqua.com/tmresources
> address@hidden | address@hidden
> TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.



Archive powered by MHonArc 2.6.19.

Top of page