## these vars are used on every -return and so they should also not be used
set _crl 0
set _crc 0
##
##
## First simple macros
##
setmacro cr 0 (split down adjustline)
setmacro spdw 0 (split down first)
# setmacro fcr 0 (split down firstnb)
##
##
## Then the better(?) and bigger ones
##
##
## language dependent : fill this variable with the keywords that request an
## indent in the next line; only the first word of a line is checked
## Normal Typing
set blockbeginner ()
set blockender ()
## Modula-2 Style
# set blockbeginner (IF ELSE ELSIF REPEAT LOOP WHILE WITH CASE FOR)
# set blockender (END ELSE ELSIF UNTIL)
## C Sytle
# set blockbeginner (if else while for switch case FOREVER)
# set blockender (else case)
##
## with getcolno/getlineno You need not worry about the recursiondepth and number of escapes before a variable
##
setmacro getcolno 1 (set \$arg1 \$colno)
setmacro getlineno 1 (set \$arg1 \$lineno)
##
## that command will find the last not-empty line
##
setmacro prevline 0 (if !top (up first while right (if top break up)) firstnb)
##
## with check[un]blockers you can check if you are in a indented block
##
setmacro checkblockers 1 (untitle (firstnb if ca (rx ("if find('\$blockbeginner','\$currentword') ~= 0 then 'add \$arg1 \$tabstop'"))))
setmacro checkunblockers 1 (untitle (firstnb if ca (rx ("if find('\$blockender','\$currentword') ~= 0 then 'sub \$arg1 \$tabstop'"))))
##
## for C-language You would need other functions
## /* some c-possibilities are not respected here:
## "if ((...) <cr> (...)) { <cr>" would cause 2 tabs
## " } else <cr> would cause no tab */
## Attention: these macros are NOT up to date
##
# setmacro checkblockers 1 (unfail (last left if !ca (add \$arg1 \$tabstop if c=123 abort if c=58 abort sub \$arg1 \$tabstop) if c=59 abort firstnb if ca (rx ("if find('\$blockbeginner','\$currentword') ~= 0 then 'add \$arg1 \$tabstop'"))))
# setmacro checkunblockers 1 (firstnb ifelse c=125 (sub \$arg1 \$tabstop) (firstnb if ca (rx ("if find('\$blockender','\$currentword') ~= 0 then 'sub \$arg1 \$tabstop'"))))
##
## that's my "prettyprinter"
##
setmacro startlinewith 1 (firstnb while x<\$arg1 space while x>\$arg1 bs)
1 (source ed:xdme.edrc) rem (that command is only known by XDME)
##
# any editor addenda are here in my system
addpath ed:
map (c-`) ((\'))
#map c-tab (set _crl \$lineno if !t (up firstnb while r (up firstnb)) set _crc \$colno goto \$_crl firstnb while x>\$_crc bs while x<\$_crc (( )))
map c-r (escimm (multireplace ))
#map -return (split down set _crl \$lineno quiet (prevline firstnb if ca (rx ("if ~(pos('\\\$currentword','\$blockbeginner')=0) then 'tab'")) goto \$_crl eval (startlinewith \\\\\\\$colno)) right left)
#if $_m2patch (map -return cr)
# control support
map c-\\ (escimm (execute `))
map a-0 ((( );) left left left)
# map s-nk* (((* *)) left left left)
# map c-k (firstnb `(* ' last right `*)')
# map sc-k `first if c=40 `ifelse t `` 'left'`up last'' findstr `(*' next del del del last findstr `*)' prev del del firstnb'