[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Elegance in XPL sought
- Subject: Re: Elegance in XPL sought
- From: cld@xxxxxxxx
- Date: Thu, 12 Oct 2006 19:20:34 +0000
From: Harry Binswanger
> Often I need to put a at the top of a file, for instance to make sure
> the first line generates a hit in searches that look for an initial .
> And I don't want to double up on if there's one in there already. So I
> check in this pedestrian way--is there a more elegant way?
The following is pithy; it takes advantage of the fact that is the only 2-byte character (Cr+Lf, i.e., Ascii 13+10):
XPLeNCODE v2.0
b-gin [UNTITLED]
[XP_][TF_][CR_]{<}IF{<}CP{>}<>2{>}[TF_][255+048+068]{<}EI{>}{
<}EX{>}[cr|lf][cr|lf]
-nd
XPLeNCODE
Either way, an initial func XP is needed, to toggle eXPanded view, in case there is invisible embedded formatting (e.g., or ) at the top of the file; otherwise, the may be inserted after the embedded statement instead of at the very top. There are other ways around this, but they are not 100% reliable; func XP is.
Your code works, but unnecessarily uses two S/Gs. Simplify:
XPLeNCODE v2.0
b-gin [UNTITLED]
[XP_][TF_][DF_][CR_][DF_]{<}SV01{>}[XD_];*;[cr|lf]{<}IF{<}IS0
1{>}<>"[cr|lf]"{>}[TF_][255+048+068]{<}EI{>};*;[cr|lf]{<}EX{>
}[cr|lf][cr|lf]
-nd
XPLeNCODE
--
Carl Distefano
cld@xxxxxxxx