From owner-aurora-editor Tue Mar 18 20:09 PST 1997 Return-Path: Message-Id: <3.0.1.16.19970318230701.44df2492@popd.ix.netcom.com> X-Sender: jawilson@popd.ix.netcom.com (Unverified) X-Mailer: Windows Eudora Light Version 3.0.1 (16) Date: Tue, 18 Mar 1997 23:07:01 To: aurora-editor@sfu.ca From: Jim Wilson Subject: autoexpd.aml macro Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Length: 5002 Status: O All; The following macro implements a feature from an editor called CRiSP. CRiSP is available on many platforms and has some nice features, one of them being the ability to automatically expand the word your typing based upon the text that has been written previously in that file. For example; if I wanted to type the word 'CRiSP' again all I would have to do is type any amount of letters that would make the search engine recognize it -- in this case, because it's fairly unique, all I would have to type is 'C' (yes, it *is* a case sensative search). AUTOEXPD will search backwards through your file and find the first word that would match the character(s) you've typed and then automatically expand that into the full word. It's sorta like what the TRAN.AML macro does, but instead of being static and hard coded like TRAN this one works dynamically. In order to make this macro work properly you need to assign AUTOEXPD to a key. In my case, I've used the combo, but you could use anything you'd like. The macro seems to work pretty good, although there is still a quirk or two I need to iron out. If you have any problems running it let me know. Regards, Jim Wilson (jawilson@ix.netcom.com) /* ------------------------------------------------------------------ */ /* Macro: AUTOEXPD.AML */ /* Written by: Jim Wilson */ /* */ /* Description: Macro used to automatically expand a partially */ /* typed word with the closest possible match from */ /* the text above the cursor. */ /* */ /* Usage: Assign it to key in kbd.aml. */ /* */ /* */ /* Version: 1.0 -- 1/97 */ /* ----------- */ /* Initial version. */ /* */ /* ------------------------------------------------------------------ */ include bootpath 'define.aml' if not wintype? "edit" then // bail out if not an edit window msgbox 'Edit windows only' 'Error' 'b' return end usemark "AutoExpand" // use a different mark pushcursor // save orig cursor pos left // move cursor back onto word markword // mark the word if not mark? then // bail out if no word found usemark popcursor say 'No valid word to search for.' 'b' return end extendmark ((getmarkleft) - 1) // now mark the left word delim char pushcursor // save new cursor pos SearchWord = send "getword" _CSet // get the chars that were typed if? (getcol) == 1 (up) (col 1) // adjustment so word doesn't match current chars Found = find SearchWord 'r' // see if word exists if Found > 0 then // if something was found... OrigClipName = _ClipName // save orig clipboard name prf.ClipName = "AutoExpandClip" // change to a different clipboard markword _CSet // mark the found word copy // copy to clipboard destroymark // unmark the word popcursor // go back to orig cursor pos markword // mark partial word typed previously deleteblock2 // delete it paste // replace it with the full word markword // mark the new word gotomark 'br' // goto the end of the word right // move cursor past end of word destroymark // unmark word prf.ClipName = OrigClipName // switch back to orig clipboard else // if nothing was found... destroymark // unmark typed chars popcursor // move cursor back to orig spot right say 'Unable to match "' + SearchWord + '"' 'b' // display message delay 1000 end usemark // reset default mark Regards, Jim Wilson (jawilson@ix.netcom.com)