Hi,
Continuing the thread on the automatic insertion of Pop-11, I can
report that I have a library of Ved functions that I wrote many
years back (at least 10, I think) and continue to use on a daily
basis.
>Chris Glur (eas-lab@absamail.co.za) wrote
>
>> Date: 22 Aug 2003 18:48:20 GMT
>> Aaron Sloman wrote:
>> > There are already various autolaodable ved extensions defining
>> > commands like
>> > ENTER define
>> > .....
>> >
>> > As far as I know, after we provided these things to help
>> > students, over 20 years ago nobody really found them
>> > useful.
>>
> > Remarkable ! Do the designers use it ?
Personally I thought that version was designed as a mnemonic
reminder and NOT as a genuinely production tool. Here's what
you get with "ENTER define RETURN"
define NAME (PARAMETERS) -> OUTPUT;
vars VARIABLES;
enddefine;
Clearly this is not properly formatted, includes deprecated
syntax, and employs the less frequently used form of definition
header with an explicit output. On the other hand it is
organized to maximize legibility and to remind the novice
programmer of the tasks that could be done. So this is a
memory aid, not a keyboard shortcut. The code inserted by
ENTER if RETURN is even more extreme.
>I doubt that any experienced programmer would: there is so much
>variability in what follows 'define', 'for', etc. that people who are
>familiar with the syntax just type, or sometimes copy and edit.
Well, I designed my keyboard shortcuts without any confidence I
would ever use them. However, I made an effort to reflect on
what worked and what didn't and after a couple of weeks experimentation
I came up with a number of useful points.
Firstly, it was important that the keyboard shortcuts were
easy to remember. I typically bind them to a prefix sequence (e.g. ^X)
followed by a single keystroke whose mnemonic is the initial
letter of the syntax word. For example:
^Xd define
^Xi if
^Xf for
Secondly, I realized that these functions had to work no matter what
the current indentation level was - otherwise I couldn't define
nested functions with them. (The teaching version gets this
wrong for ENTER define.)
Thirdly, the final position of the cursor had to be right. Exactly
where that should be took me a day or so to get right - although
I can't see for the life of me what the difficulty was. The
teaching version does not attempt to do this.
Lastly, I discovered that it was important for the stuff inserted
by this command to be minimal. For whatever reason, having to
delete stuff wasn't acceptable to me.
I packaged this up using a support function "do_ved_add" that has
a little command language. Here's the shortcut for define:
define ved_add_define();
[ 'define ' + '();' nl 'enddefine;' - ].do_ved_add
enddefine;
It takes a list as a parameter. Strings get inserted as literals
but words are commands. Note that all whitespace must be
explicitly inserted (a defect but tricky to fix)
+ save cursor position (vedpositionpush)
- restore cursor position (vedpositionpop)
nl newline, back to original indentation level
tab indent (this is misconceived)
And here's the code I wrote so many years ago.
define do_ved_add( L );
lvars col = vedcolumn;
lvars it;
for it in L do
if it == "+" then
vedpositionpush()
elseif it == "-" then
vedpositionpop()
elseif it == "nl" then
vedlinebelow();
repeat col - 1 times vedcharinsert( `\s` ) endrepeat
elseif it == "out" then
vedlinebelow();
repeat col - 1 - vedindentstep times vedcharinsert( `\s` ) endrepeat
elseif it == "tab" then
vedcharinsert( `\t` )
elseif it.isstring then
vedinsertstring( it )
else
mishap( 'Do not understand this item', [ ^it ] )
endif
endfor
enddefine;
The shortcuts I use most heavily - and feel lost without - are the
shortcut for define and procedure. They save a lot of typing and work
well. However, I would have liked a way to restrict the stuff
inserted by procedure to be on a single line.
Oddly enough, the shortcut for the for-loop has never proved successful
for me. The cursor positioning is wrong.
define ved_add_for();
[ 'lvars ' + ';' nl 'for in do' nl 'endfor;' - ] .do_ved_add
enddefine;
It inserts
lvars ;
for in do
endfor;
with the cursor positioned in front of the ";". I don't find this saves
me enough typing - and I hate having to type the loop variable twice.
I think I would like to experiment with the idea of using the shortcut
immediately _after_ I have typed the name of the loop variable so that
the shortcut could pick up the name, generate
lvars <name>;
for <name> in do
endfor;
with the cursor positioned between the two spaces separating the in and do.
That might be more useful.
If anyone is interested in the full set I have been using, I'll post them
to popforum.
--
Steve
|