On 2013-02-10 00:20, mike young wrote:
Ahhhhh, TECO, first editor I ever used, some 35 years ago. Far and away
the most powerful, too. A few mistyped characters can wreak such havoc!
Thanks, Johnny, for the memories.
You are welcome. I still find it surprisingly easy and efficient to do some types of
editing in TECO, compared to anything else. I guess the closes for other people nowadays
are sed, awk, perl, and similar tools. But they are all just doing parts of the work, so
you often see people use several of them, and they are so heavyweight compared to TECO.
But yes, you need to keep your letters in order, or things quickly get out of hand. :-)
TECO have been referred to as a write-only language. I can sortof understand that one...
;-)
Writing something like EMACS in TECO, however, is rather trivial.
Johnny
--Mike
On 2/9/2013 11:54 AM, Johnny Billquist wrote:
On 2013-02-09 15:23, G. wrote:
On Sat, 09 Feb 2013 02:21:21 +0100, you wrote:
<fs($(<a
href="hecnetinfo.com?q=$;.UAS)$-CQA,.XAI">$GAI</a>$>EX$$
Clear as a spring rain.
Let me know if you want me to explain it... ;-)
Yes please, do! :)
Like I said, clear as spring rain...
Ok, here we go. Written somewhat more "structured":
Anything between exclamation points are comments in TECO (well,
technically, they are labels, but what is really the difference
between a label and a comment anyway... :-)
< ! Start of
loop !
FS($(<a href="hecnetinfo.com?q=$; ! Search for ( and replace it
with all that other crap. The trailing ; after the second escape means
that if the search and replace fails we'll exit the loop !
.UA ! Save current
position in
Q-register A !
S)$ ! Search for ) !
-C ! Backup one char
!
QA,.XA ! Copy text between
position in
Q-register A and current position into Q-register A !
I">$ ! Insert the
text "> !
GA ! Insert the text
from
Q-register A !
I</a>$ ! Insert
</a> !
! End of loop !
EX$$
! Exit !
Now, the good tricks to know: In TECO you have Q-registers. Think of
them as variables that can store a number and a string (at the same
time). TECO always have a current position in the buffer. That is
denoted by ".". Functions takes arguments.
So, a thing like the search and replace is FSstr1$str2$, which
searches for str1, and if found, replaces it with str2. So the first
like is just searching for the next opening paren, and inserts a lot
of cruft after the paren. Just plain text constant.
At this point, the current position is just before the nodename. So,
we store the position where the nodename starts. (.UA). The command is
actually nUq, where n is any number. We just use "." as the number,
which is the current position. q is what Q-register to store the value
in. So, .UA stores the current position in Q-register A.
S)$ should be very obvious. Just search for the closing paren.
-C should also be pretty obvious. nC moves the position that many
steps. If no argument is given, it defaults to 1. -C is just short for
-1C.
QA,.XA looks much worse than it is. The basic command is actually
m,nXq, which stores the text between m and n in Q-register q. The the
XA part should be obvious. Store the text in Q-register A. The stuff
before the command is QA,. . At this point, you should realize that n
in this case is ".", or the current position. QA is the function to
read out the value from Q-register A (Qq to say the function in a
general way). So we'll copy the text from the start of the nodename
(stored in Q-register A) to the current position, which is right
before the right paren, to Q-register A. That is, Q-register A will
then hold the nodename. Also, at this point, the current point is
after the nodename.
So, we now want to finish the <a href= tag, so we insert a little more
text: I">$, which does just that. Position is still right before the
right paren, but now we have a full <a> tag in the buffer.
GA gets the text from Q-register A, and inserts it into the buffer.
That is the nodename again, now for displaying.
I</a>$ then inserts a little more text, finishing the tagged text.
is the end of the loop.
EX$$ exits.
See. TECO is actually pretty easy. :-)
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic
trip
email: bqt at softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" -
B. Idol