[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Elegance in XPL sought
- Subject: Re: Elegance in XPL sought
- From: "Robert Holmgren" holmgren@xxxxxxxx
- Date: Sat, 14 Oct 2006 09:19:34 -0400
** Reply to message from Harry Binswanger on Thu, 12 Oct 2006
23:43:43 -0400
>> Explication:
>> BX jmp 2 Q2 Assume leading , so JuMP to position right after it
>> <1> This _should_ be row 1 -- IF not, you're still on row 0
>> > Get current CursorPosition
> Don't we know that is 2? That's where we JMPed to. Are there
> conditions in which we can Jmp to 2 and, due to multi-byte characters, not
> actually be at 2?
What do people usually place on the first line of documents? Format commands!
So answer your own question: put some formats on the first line, toggle into
any view other than eXPanded, command "JMP 2", type something (a carriage
return, for example), and see whether it is inserted at column (cursor
position) 2 or not. Report back!
Yes, when you JMP 2, is theoretically 2. But as soon as you try to put
text, or you toggle the view in any way e.g. to eXPanded, starting is no
longer 2 -- the cursor will be positioned after all formats.
>> CL CursorLeft once for each (move to beginning of row 0)
> Why not just TF? or CL CL?
Put some formats on line 0, throw your document into NoMarkers view (func NM),
command func TF, and type something! Where is what you typed actually located?
(Find out in eXPanded view.)
To my knowledge, only two functions work: CL CursorLeft and PC
PreviousCharacter. LB LineBegin, LL LinearLeft (surprisingly), TF TopForm do
NOT work. So yes, the following would work (smallest possible code for this
operation):
XPLeNCODE v2.0
b-gin [UNTITLED]
[BX_]jmp 2[Q2_]{<}IF{<}VA$CY{>}<1{>}[CL_][CL_][cr|lf]{<}EI{>}
{<}EX{>}
-nd
XPLeNCODE
> But maybe you have in mind a generalization of the program, so it can test
> for a CR-LF at any point in a file.
No. I'm showing you how to position your cursor, FROM *any* position on line
zero among a bunch of hidden formats, TO column zero (i.e. to *true*
Top_of_File). After you get there, you may put ONE character or carriage
return (not more!) without repositioning again:
...>CL ...
> E.g. say I want to know if there's one
> after "Binswanger"--I could do:
> BX se /Binswanger/Q2
> >
> +2>>
> BX jmp Q2
> >> etc.--i.e., if evaluates as true, then there was a CR-LF.
Why evaluate rows? (And if the goal is pithy/elegant, then use a space
separator in your SEarch command -- save one byte.) Like this:
BX se BinswangerQ2
CR func CR CursorRight
{less than}1>... IF *column* position less than 1, you have
However, that test -- and your test too -- has one fatal flaw: the string
"Binswanger" might appear at the end of a wrapped line *within* a paragraph --
in other words, the test evaluates true but no is actually present.
The simplest valid test would be to CR once, and evaluate whether you moved two
bytes:
BX se BinswangerQ2
+2>
CR
{equals}>... IF evaluates true, you have
-----------------------------
Robert Holmgren
holmgren@xxxxxxxx
-----------------------------