1. Adding "Short cuts" to ed.ex - was "hello" (alex..)
- Posted by Ken Rhodes <ken_rhodes30436 at yahoo.com> May 15, 2002
- 388 views
Alex asked: 1) Did anybody already write some kind of preprocessor for eu which supports shortcuts for keywords (like proc->procedure, func->function, endp, endf, endw, endfor, endif, ...)? I have to admit that I have most trouble typing that 'SEQuence' which annoyed me so much that I replaced it with type 'list' = return 1. Or, maybe ED or EE or some other editor supports these features? ED.EX can be very easily "extended" in the manner you suggest. For example the code that follows implements "proc" as a shortcut for "procedure": -- expandable words & corresponding text constant expand_word = {"if", "for", "while", "elsif", "procedure", "proc", "type", "function"}, expand_text = {" then", "= to by do", " do", " then", "()", "()", "()", "()" -- all I have done here is insert "proc" in the -- expand_word sequence and then a matching "()" in -- the expand_text sequence -- and then insert the following 'elsif' clause into the procedure "try_auto_complete (char key) which imediately follows the above: elsif find(word, {"proc"}) then add_queue(repeat(BS,5) & "procedure ") insert_string(begin & '\t' & CR & leading_white & "end " & "procedure") --- BINGO! thats all there is to it --- once you study the routines Rob has built into --- ED.EX, you will find that it is usually very --- easy to add many helpful features hope this helps Ken Rhodes