Electric Expansions Help
Name:Elec Expansions
Version:9.4
Last update:2019-11-27 14:12:47






This package provides a different kind of word completion than the package Electric Completions. It defines two kinds of completions based on acronyms: expansion of camel-case words and user defined expansions.

Acronym Expansions

When you find yourself typing a lot of variable and function names over and over, and these names are word-combinations where the name is formed by either capitalizing each word or separating them with an underscore, just type the initial letter of each part of the word and invoke an acronym expansion instead by using the expansion key. The Alpha ↣ Global Setup ↣ Keyboard Shortcuts ↣ Special Keys menu item allows you to set/change this key.
For instance, if the current document contains the word globalExpansionDialog, you can just type ged (as an acronym for [g]lobal[E]xpansion[D]ialog) and hit the expansion keyboard shorcut: it will be expanded to globalExpansionDialog. The expansion mechanism would also find the word global_expansion_dialog with the same hint ged.
Setting the Expansion key can be done in the Special-Keys Preferences panel.
The idea of this package is to allow you to type a string consisting of the initial letters of the words that have been joined to make up a variable, function, or procedure name. This is often shorter and more natural than typing a few letters and using electric completions. As I developed this routine, I found that a regexp for more than three letters caused search to choke so only those letters of a hint are significant. A three letter pattern is used for the search.
After a possible hit is located, it is turned into an acronym and checked against the hint. The string you are going to use expansion on can be entered in uppercase, lowercase, or any combination. The words in the target you are trying to hit have to start with a capital (except the first word), or, be separated by an underscore or a colon.
The hint can be embedded between non-alphabetic characters and certain punctuation marks:
[ ( { , ; : ' " " ' ] ) }
The expanded hint remains so embedded, and the cursor appears beyond the trailing punctuation. Any whitespace between the hint and the cursor is also preserved.
For instance, if sin($gl) was expanded (in the file elecExpansions.tcl), we would get sin($__Gcw_len).
Similarly, mouse($gph would expand to mouse($__Gcw_prevHint, done twice, we would get mouse($__Gcw_prevHit,
Take the Text Mode Tutorial for a demonstration. See the Electrics Help page for more information about electrics.

Electric Expansions Menu

This menu is found the Alpha ↣ Preferences submenu. It lets you define your own predefined acronyms. This is very much like the Electric Completions menu, the only difference being that the replacement is triggered by a different key. The idea is that you should rather use completions for abbreviations where you type the first few letters of a word (like for instance sup for supercalifragilisticexpialidocious) and expansions for acronyms (like mp for Mary Poppins) although there is no compelling reason to do so. The menu items are
View Global Expansions
Open a window with all current user expansions. By default, the package supplies one user expansion named date.
Add Global Expansions
Open a dialog to create new user expansions.
Edit Global Expansions
Open a list-pick dialog to edit user expansions.
Remove Global Expansions
Open a list-pick dialog to remove user expansions.

Developers Note

This package also provides support for mode-specific expansion procs. A mode can declare its own expansion proc by setting a new entry in the expanders global array. For instance:
set expanders(mymode) foo::Expansion
The proc [foo::Expansion] takes no argument and should return either '1' to indicate termination, or '0' to say either that they failed or that they succeeded and that further expansion procedures may be applied.

Known problems

Please report any problem or bug you encounter to Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 1996-2019, Tom Fetherston.
All rights reserved.
The elecExpansions package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOM FETHERSTON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.