I suppose I should change the subject back to the original!
Chris Dollin <kers@hpl.hp.com> writes:
> Date: Fri, 22 Aug 2003 09:34:14 +0100
> Organization: HPLB
>
[AS]
> > Finding all the words in the current dictionary that start with a given
> > string is dead easy, using appdic or mapdic. E.g.
>
> [deletions]
[CD]
> That wasn't what I meant by "completion"; the name was not as well-chosen
> as I'd prefer. I had in mind more
>
> if ESC-Y
>
> completing to
>
> if <cursor ends up here> then else endif
>
> Ditto "until ESC-Y" completing to
>
> until <cursor ends up here> do enduntil
>
> where ESC-Y consults a ESC-Y-specific table of completions.
Apologies: that's MUCH easier to do than vedwordcomplete (which by
the way had some left-over comments from vedfilecomplete, which I've
now removed).
There are already various autolaodable ved extensions defining
commands like
ENTER define
ENTER if
ENTER unless
ENTER until
E.g. ENTER define, inserts
define NAME (PARAMETERS) -> OUTPUT;
vars VARIABLES;
enddefine;
and leaves the cursor just before 'define'.
(Hmmm 'vars' should be changed to 'lvars' now!)
As far as I know, after we provided these things to help
students, over 20 years ago nobody really found them
useful.
But it would be trivial to produce a user-extendable list
of the form
vars syntax_completions =
[ 'if' 'then else endif;'
'while' 'do enddo;'
....
];
and then associate an escape sequence with a procedure to look at
the preceding (complete) word and then insert the corresponding
string from the list, leaving the Ved cursor location unchanged.
A variant could allow different completions, e.g. those
for raw pop11, some for objectclass, some for poprulebase, etc.
'define' ' NAME( , ) -> ( , );\n\tlvars ;\n\nenddefine'
'define' ' :method NAME(X:TYPE , Y:TYPE);\n\nenddefine'
'define' ' :class NAME( , ) -> ( , ) ;\n\nenddefine'
'define' ' :ruleset NAME;\n\tRULE NAME\n\t==>\n\nenddefine; '
(likewise the many formats for 'for' listed in HELP FOR)
These could use the same 'menu' mechanism as vedfilecomplete and
the new vedwordcomplete to let the user select. A user or a
teacher could easily extend the list syntax_completions.
In fact altering vedwordcomplete to do this would be very easy.
It would involve altering lastwordpart() to go back over space,
altering the syswordcomplete procedure to use the list
syntax_completions, getting rid of the common_completion
procedure, and using vedpositionpush() and vedpositionpop() to
save and restore the cursor location.
It would take a few minutes to do. Building the list of useful
completions would take a lot longer and would be to some extent a
matter of individual preference. E.g. some people would and some
would not like the capitalised bits in my examples.
[CD]
> To make
> this work properly one also needs at least (using SPOO to mean "some
> ESC-thingy or CTRL-thongy or whatever prefix" and A, B etc to mean
> "some specific extension for SPOO")
>
> SPOO-N next slot in current completable thing
> SPOO-P previous slot in current completable thing
> SPOO-E just after the end of current completable thing
...etc....
>
> But we'd have to try it to see if it would fly in practice.
I have a lot of such utilities for processing email files: delete
current message, mark current message, tidy header for current
message, move to next message, move to previous message, start
reply to current message or Reply (to all), start a reply with
original text indented, send current message etc. etc.
Doing it for program structures would be more difficult as there
are so many of them. In principle one could have a command that
searches backwards for the last syntax key word in a list of
syntax forms and then uses things like vedwordright() and
ved_mm(), ved_mp() etc. But in general for an experienced
programmer, developing lots of nested program structures it would
be very hard to get it right. However special cases could be
handled and these might be especially useful for teaching.
I suspect I would always use the keyboard macro move functions in
preference, e.g. vedwordleft() vedwordright(), vedcharuplots(),
vedcharrightlots(), vedcharuprightlots(), vedchardownrighlots()
etc etc. These can get you close to where you want to be editing,
without requiring all your inervening syntax to be correct
already! (I compose programs as a poet composes poems, moving
back and forth over incomplete structures).
Another thing I use a lot is
ESC ' /
(move to next occurrence of thing to right of cursor)
ESC ' \
(move to last occurrence of thing to right of cursor)
These can both be followed by ESC / and ESC \ to repeatedly move
forward or backward searching for the same thing. This means that
when programming I hardly ever need to type search strings when
navigating a large file.
Likewise F7 followed by ESC F7 deletes and re-inserts the word to
the right of the cursor. I can then repeatedly use ESC F7 to insert
it somewhere else, e.g. in a search string or substitute string
or showlib command, etc.
Because such tricks (a) reduce the time to type things and
(b) eliminate many typing mistakes, they probably *double* my
programming speed (when the programming task is not itself
intrinsically hard).
Cheers.
Aaron
==
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/ (And free book on Philosophy of AI)
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
|