[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
some side comments about absolute line gotos
Date: Wed, 20 Jun 90 10:05:51 MDT
From: email@example.com (David R Strip )
I know that you can do meta-< c-(lineno-1) c-n.
What I want is a function (not a macro even) that really goes to the
absolute line reasonably efficiently.
Everyone seems to have given you ample suggestions about the code to
write, and I have no quarrel with what they've suggested, but no one
seems to have reacted to this statement about efficiency, so I will
offer a few additional comments on that.
You may well prefer to have a command that does the goto for `conceptual
efficiency' but it is doubtful that any of the code anyone has contributed
will be measurably more efficient than m-< c-1n0 c-N since c-N has to do the
same kind of work that this goto function would do.
The reason is that Zwei's lines are arranged as linked strings (with forward
and backward links from line to line) but there is no table somewhere of
line 0 to line N where you can just aref out of the table to get line I.
In order to find line I, you have to increment through the set of lines until
you find the one you want.
Even typing-wise, if you're going to put your new command on a single key,
you're only saving at most 1 keystroke if you implement c-1n0 1bucky0-G rather
than just type m-< c-1n0 c-N.
So it's find to have the command for the sake of conceptual simplicitly.
There are many such commands that offer equivalent functionality but from
different points of view (e.g., consider c-1n0 c-A compared to c-1n0 c-N, which
are functionally redundant but still interesting to have around because they
satisfy different mindsets at the time you want to invoke them). But I just
didn't want you to think superstitiously that there was any massive
inefficiency in doing the obvious incantation with c-N just because you had
the wrong mental model of how things were stored internally.
On the flip side, Zwei's line data structures make things like m-. especially
powerful because you can go to a particular line without knowing its number
1and0 without searching. This same kind of power is also accessible to you
in an interactively programmable way by using the commands
Control-X S (Save Position) and Control-X J (Jump To Saved Position).
If you don't know about them, it's worth checking them out.
They really 1are0 efficient for getting back and forth in large pieces of text.