From: DavidMarcus@MindSpring.com (David Marcus)
S.W. Rienstra wrote on Tue, 12 Aug 1997 11:01:38 +0000:
>Dear Tse-ers,
>
>Is there anyone out there who has ever reshaped the wrappara-macro
>for LaTex documents, in a way like for emacs, such that the \begin{..}
>....\end{..} structures remained intact, c.q. untouched?
Here's a macro that may provide a model for you. It is designed to take a
paragraph with Ventura Publisher codes for forced lines breaks () and =
wrap
it in such a way as to always start a new line after each .
It wraps a bit of the paragraph at a time by chunking it into sections, e=
ach
one ending with , moving each section to a temp buffer, wrapping it, a=
nd
then concatenating the wrapped chunks in another temp buffer.
Sorry about the lack of comments...
proc mwrap4vp()
INTEGER tabs =3D Set(expandtabs,OFF),
id =3D GetBufferID(),
tid2,
tid3 =3D CreateTempBuffer(), // new construct
tid1 =3D CreateTempBuffer() // old para
MoveBlock() // move block to tid1
lReplace(' #' + '', '', 'gxnl')
lReplace(' ', '=B7', 'gn')
UnMarkBlock()
repeat
BegFile()
MarkChar()
if not lFind('', 'x')
EndPara()
MarkLine()
else
Right(3)
MarkChar()
endif
tid2 =3D CreateTempBuffer() // holds one bit of the
// para at a time
MoveBlock()
WrapPara()
GotoBufferID(tid3) // holds the results as the
// paragraph is wrapped bit by bit
EndFile()
AddLine()
MoveBlock()
AbandonFile(tid2)
GotoBufferID(tid1)
until NumLines() =3D=3D 0 or (NumLines() =3D=3D 1 and PosLastNonWhite=
() =3D=3D 0)
GotoBufferID(tid3)
BegFile()
repeat
if CurrChar() =3D=3D 32
DelRightWord()
endif
while PosFirstNonWhite() =3D=3D 0 and
CurrLine() < NumLines()
DelLine()
endwhile
until not Down()
UnMarkBlock()
MarkLine(1, NumLines())
GotoBufferID(id)
BegLine()
MoveBlock()
lReplace('=B7', ' ', 'gn')
BegPara()
EndPara()
Down()
Down()
if PosLastNonWhite() =3D=3D 0
Up()
DelLine()
Down()
endif
BegLine()
AbandonFile(tid1)
set(expandtabs,tabs)
end
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)
|