Overview ========
Abbreviations are possible only when `abbrev' mode is enabled. It can be toggled on and off on a buffer by buffer basis using the `abbrev_mode' command. If it is on, the word `abbrev' will appear on the status line.
Each buffer can have its own abbreviation table or use the ``Global'' abbreviation table. If a table has not been defined for a given buffer, the ``Global'' table will be used. Typically, abbreviation tables are mode dependent and are usually assigned to the buffer when a mode is selected.
An abbreviation table consists of abbreviations as well as a definition of characters that are allowed to appear in an abbreviation. By default, the characters that comprise a word are used. However, this is not always what is desired. For example, one might like to use abbreviations like `' for `
'inTeXmode.Forthistohappen, the`´charactershouldbeincludedinthedefinitionofaword.Theexamplesbelowshouldshedmorelightonthisconcept. UsingAbbreviations = = = = = = = = = = = = = = = = = = = Onceabbreviationshavebeenloadedintotheeditor(themechanismisexplainedbelow), theycanbeusedonlyifabbrevmodeisturnedon.Thismodecanbeturnedonoroffbypressing`ESCX'andentering`abbrevmode'attheprompt.Itcanalsobeturnedoninamodehook. Afterenteringanabbreviationintothebuffer, theabbreviationwillbeexpandedifthenextcharacterinsertedintothebufferimmediatelyafterthepositionoftheabbreviationisNOTamemberofthesetofcharactersthatisallowedinanabbreviation.ThentheeditorscansbackwardacrossthetextuntilitfindsacharacterthatisNOTpartofthesetofspecialcharacters.Finallyitattemptstoexpandtheresultingabbreviation. Forexample, consideranabbreviationforTeXmodeandassumethat, whentheabbreviationtablewascreated, thecharacters`,́`a - z',`A - Z', and`0 - 9'werespecifiedasthespecialsetofcharactersthatmaybeusedinanabbreviation.Thismeansthat`isavalidabbreviationbut`@be'isnotsince`@'isnotpartoftheaboveset.Supposethat`istheabbreviationfor`
Thisisanequation. Atthispointnothinghappens.However, ifaSPACEisinserted, theeditorwillrealizethatthespaceisnotpartofthespecialabbreviationcharactersetandscanbackuntilanothercharacterNOTinthesetisfound.Inthiscase, itwillfinda`.'.Fromthisinformation, itlooksup`inthetable, finds`
Thisisanequation.
However, ifthelinehadlookedlike : Thisisanequation theexpansionwouldhavefailedbecausetheeditorwouldhavescannedbacktothespacecharacterbetween`an'and`equation'andtriedtoexpand`equation. Althoughthissoundscomplex, itistrivialinpractice. TheAbbreviationFile = = = = = = = = = = = = = = = = = = = = = = AnabbreviationfileissimplyafilethatcontainstheapproriteS - Langfunctioncallstocreateabbreviationtablesandassignabbreviationstothetables.ItisloadedlikeanyotherS - Langfile, via`evalfile'.Simplyturningabbreviationsonvia`abbrevmode'issufficienttocauseJEDtoloadthefile. Thevariable`AbbrevFile'maybeusedtospecifythenameoftheabbreviationfile.Ifthisvariableisundefined, thefilenamedefaultsto`abbrevs.sl'onnon - Unixsystemsand`.abbrevs.sl'onUnix.ItisassumedtoresideintheHOMEdirectory.Tospecifyadifferentname, e.g.,`/usr/lib/jed /abbrev.sl', put variableAbbrevFile = "/usr/lib/jed /abbrev.sl"; intheJEDstartupfile. HereisasimplefilethatissufficienttocreateaglobalabbreviationtableandalocaltableforTeXmode : createabbrevtable("Global","");defineabbrev("Global","adn","and");defineabbrev("Global","amy","amy.tch.harvard.edu"); createabbrevtable("TeX","
Notethat`createabbrevtable'takes2parameters.Thefirstparameterissimplythenameofthetabletobecreatedandthesecondparameterrepresentsthelistofcharactersthatareallowedtobeinanabbreviation.Ifthesecondparameteristheemptystring, JED'sworddefinitionwillbeused.AlsonotethatthebackslashcharactermustbetypedtwiceforS - Langtointerpretitproperlyasabackslashcharacter. The`defineabbrev'functiontakes3parameters : thenameofthetable, theabbreviation, andtheexpansionfortheabbreviation. Thereisreallynothingspecialaboutanabbreviationfile.ThecodethatappearsinitcanalsoappearintheJEDstartupfile. Usuallytheabbreviationmodeisenabledinahook.Forexample, toenableabbreviationsforTeXmode, useamodehookoftheform : definetexmodehook()setabbrevmode(1); Thisway, whenTeXmodeisenabled, theabbreviationfilewillbeautomaticallyloadedifnotalreadyloadedandabbrevmodewillbeturnedon. CreatingAbbreviations = = = = = = = = = = = = = = = = = = = = = = Therearetwowaystocreateabbreviations : 1.Simplycreateanabbreviationfilebyhand.2.Usethe`defineabbreviation'functioncall. Herethelattermethodisexplained. The`defineabbreviation'functionusestheabbreviationtableassociatedwiththecurrentbuffer.Ifthereisnoneexplicitlyassociatedwiththebuffer, theGlobaltablewillbeused.Ifthetabledoesnotexist, itwillbecreated.Thisfunctionwillpromptforanabbreviation.Itmayormaynotpromptforanexpansion.Ifaregionisdefinedwhen`defineabbreviation'iscalled, theregionwillbetakenastheexpansion.Thisisusefuliftheexpansionconsistsofofmorethanoneword.Ifaregionisnotdefined, theexpansionwillconsistofthepreviouswordasdefinedbythetable.Onlyifthatfailswilltheuserbepromptedforanexpansion, e.g., thiscouldhappenifthePointisatthebeginningofaline. Notethatsimplyusing`defineabbreviation'byitselfdoesnotsavetheabbreviationforfutureuse.Tosavetheabbreviationstotheabbreviationfile, usethefunction`saveabbrevs'.Thatis, press`ESCX'andenter`saveabbrevs'attheprompt.Theeditorwillthenpromptforafilename.SimplyhittingRETURNatthepromptmeansthatthe`AbbrevFile'definitionwillbeused.Enteradifferentfilenametosavethemelsewhere.Notethatenteringanewfilenamewillnotchangethevalueof`AbbrevFile'.Also, thisfunctionsavesALLcurrentlydefinedabbreviationtables.
|
(1) |