!- nedit modula-3 mode
!- start nedit with: 'nedit -import m3-nedit-mode' and then save preferences

nedit.highlightPatterns: \
	Modula-3:1:0{\n\
		Pseudo Identifier:"<(Main|RESULT|SELF|T)>":::Storage Type::\n\
		START:"^(UNSAFE |GENERIC )?(INTERFACE|MODULE) \\w+(\\([\\w,]+\\))?( EXPORTS [\\w,]+)?;$":::Keyword::\n\
		END:"^[\\t]*(END;? )+\\w+\\.$":::Keyword::\n\
		Keyword:"<(AND|ANY|ARRAY|AS|BEGIN|BITS|BRANDED|BY|CASE|CONST|DIV|DO|ELSE|ELSIF|END|EPHEMERAL|EVAL|EXCEPT|EXCEPTION|EXIT|EXPORTS|FINALLY|FOR|FROM|FUNCTIONAL|GENERIC|IF|IMPORT|IN|INTERFACE|LOCK|LOOP|METHODS|MOD|MODULE|NOT|OBJECT|OF|OR|OVERRIDES|PROCEDURE|RAISE|RAISES|READONLY|RECORD|REF|REPEAT|RETURN|REVEAL|ROOT|SET|THEN|TO|TRY|TYPE|TYPECASE|UNSAFE|UNTIL|UNTRACED|VALUE|VAR|WHILE|WITH)>":::Keyword::\n\
		Reserved Identifier:"<(ABS|ADDRESS|ADR|ADRSIZE|BITSIZE|BOOLEAN|BYTESIZE|CARDINAL|CEILING|CHAR|DEC|DISPOSE|EXTENDED|FALSE|FIRST|FLOAT|FLOOR|INC|INTEGER|INTERFACE_UNIT|ISTYPE|LAST|LONGREAL|LOOPHOLE|MAX|MIN|MODULE_UNIT|MUTEX|NARROW|NEW|NIL|NULL|NUMBER|ORD|PROCANY|REAL|REFANY|ROUND|SUBARRAY|TEXT|TRUE|TRUNC|TYPECODE|VAL|VIEW)>":::Identifier::\n\
		String:"""":"""":"\\n":String::\n\
		String Escape:"\\\\.":::String1:String:\n\
		Fmt Specifier:"%\\d*s":::String2:String:\n\
		Comment:"\\(\\*":"\\*\\)"::Comment::\n\
		Pragma:"\\<\\*":"\\*\\>"::Preprocessor::\n\
		Character:"'":"'":"[^\\\\][^']":String::\n\
		Number:"<[+-]?((2_[01]+)|(8_[0-7]+)|((\\d+)(\\.[\\dedxEDX]+)?)|(16_[\\da-fA-F]+))>":::Numeric Const::\n\
		Module Or Type:"<[A-Z]\\w*\\.":::Module::\n\
	}\n
nedit.languageModes: \
	Modula-3:.i3 .m3 .ig .mg::Smart::::\n
nedit.styles: \
	Module:#eaa95e:Plain\n
nedit.smartIndentInit: \
	Modula-3:	$m3IndentDist = "default"\n\
	--End-of-Macro--\n\
	# palabros de 2 letras\n\
	palabro = get_range($1-2, $1)\n\
	if (palabro == "DO" || palabro == "OF" || palabro == "=>")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# palabros de 3 letras\n\
	palabro = get_range($1-3, $1)\n\
	if (palabro == "TRY" || palabro == "VAR")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# palabros de 4 letras\n\
	palabro = get_range($1-4, $1)\n\
	if (palabro == "ELSE" || palabro == "LOOP" || palabro == "TYPE" || palabro == "THEN")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# palabros de 5 letras\n\
	palabro = get_range($1-5, $1)\n\
	if (palabro == "BEGIN" || palabro == "CONST")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# palabros de 6 letras\n\
	palabro = get_range($1-6, $1)\n\
	if (palabro == "EXCEPT" || palabro == "FINALLY" || palabro == "OBJECT" || palabro == "RECORD" || palabro == "REPEAT" || palabro == "REVEAL")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# palabros de 9 letras\n\
	palabro = get_range($1-9, $1)\n\
	if (palabro == "EXCEPTION")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# definición de un PROCEDURE -- afinar\n\
	if (get_character($1-1) == "=") # && get_range(0, 8) == "PROCEDURE")\n\
		return measureIndent($1) + defaultIndent($m3IndentDist)\n\
\n\
	# no es ningún palabro, aplicar indentación normal\n\
	return -1\n\
	--End-of-Macro--\n\
	if ($2 == "(")\n\
		replace_range($1, $1, ")")\n\
	else if ($2 == "[")\n\
		replace_range($1, $1, "]")\n\
	else if ($2 == "{")\n\
		replace_range($1, $1, "}")\n\
	else if ($2 == "\\"" && get_character($1-1) != "\\\\")\n\
		replace_range($1, $1, "\\"")\n\
	else if ($2 == "'" && get_character($1-1) != "\\\\")\n\
		replace_range($1, $1, "'")\n\
	else if ($2 == "*") {\n\
		if (get_character($1-1) == "(")\n\
			replace_range($1, $1, "*")\n\
		else if (get_character($1-1) == "<")\n\
			replace_range($1, $1, "*>")\n\
		}\n\
	--End-of-Macro--