This rev makes minimal changes to the existing (very complex) code.
Please report any problems immediately.
Here are the highlights:
- Match longest prefix first: e;; no longer interferes with date;;
- Predefine 'x' as the empty string before executing abbreviation scripts.
- Split @data abbreviations-subst-env into separate nodes.
- Defined do() and insert() functions in @data abbreviations-subst-env as follows:
def do(commandName):
'''Execute a command by name.'''
c.k.simulateCommand(commandName,event=None)
def insert(s):
'''Insert the string s in the current widget.'''
try:
w = c.abbrevCommands.w
if w:
i = w.getInsertPoint()
w.insert(i,s)
except AttributeError:
pass
Note: Because of a glitch in how abbreviations scripts are created, you can't do::
do(['command1','command2'])
even though c.k.simulateCommand allows list arguments. Instead, do this::
do('command1');do('command2');
The following abbreviations insert matching characters (no need to do x='' in them)::
(={|{insert('()');do('back-char')}|}
[={|{insert('[]');do('back-char')}|}
{={|{insert('{}');do('back-char')}|}
This is an implementation of
auto-close-quotes, done entirely with abbreviations! For example, typing '(' inserts '()' and puts the cursor
between the parens.
I personally dislike these abbreviations. I find it harder to skip past the ')' than to type it later. ymmv.
Your comments please, Amigos.
Edward