texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] New algorithm style - need help


From: Sam Liddicott
Subject: Re: [Texmacs-dev] New algorithm style - need help
Date: Sat, 09 Apr 2011 09:46:36 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17pre) Gecko/20110408 Lanikai/3.1.10pre


On 09/04/11 02:32, Jan Lellmann wrote:
Hello,

I'm trying to develop a style file for structured input of algorithms. I got most of it to work, including proper line numbering, indentation, etc.

Constructs that may have several cases, such as "if", "switch" etc. are implemented using <xmacro>, so that the user can add additional cases as required. Everything works, except that the indentation for the <xmacro> constructs is wrong.

I've been trying to get this to work for the last few days, and now I'm out of ideas. So if someone can help, I'd be more than grateful.

I attached the style file and a short example that demonstrates the problem.

Thanks,
Jan

The freakiness happens between the IF macro and the if-extend macro.
If I insert: <algo-item>XXXX
before the map-args call to if-extend then it has the correct indent

If I insert: <algo-item>XXXX
as the first item inside if-extend then it has the wrong indent.

If I replace that map-args with <if-extend|hello|0>
then I don't get the extra indent.

So "map-args" combined with "document" seem to be the culprit and I suspect "document"

I replace with "concat" giving: <combine|<map-args|if-extend|concat|args>|<alg-keyword|end if>>
which has the right indent, but no new-lines.

"concat" is for wrapping content.

"document" is for blocks that cannot wrap.

This is made clearer if you use LONG LINES that would need to wrap.
It's hard to tell which you need until you decide what should happen to long lines.

I just moved my literate programming to wrap lines and avoiding macro-generation of <item> tags and instead require that the item tag exist in the document tree directly.

This requires:
(define-group enumerate-tag algorithmic)
in your case, so that pressing enter in algorithmic in your document tree will insert an <item> tag.
You can <with|item|<macro....  to redefine what item does.

Before that I handled it like you and had similar problems.

The only other idea I have is to track the nesting level and muliply the offset when rendering the line numbers - but it looks like you are doing something like that, but just not for the IF.

However my best suggestion is to explicitly use <item> as I do for literate programming.

And I congratulate you on your good looking style, I think it's great.

Sam




reply via email to

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