NEDIT_require_macro_file("RSextensions.nm") NEDIT_require_macro_file("RScolor.nm") define ColMoveBackByWord { opos = $1 npos = $cursor R = $2 comment = $3 RangeSet_add(R, $1, $cursor) if (R == "w") col = "orange" else if (R == "s") col = "white" else if (R == "y") col = "cyan" else if (R == "n") col = "gray" else col = "lightgreen" RangeSet_set_color(R, col) dialog(col ": " comment) } define MoveBackByWordStep { opos = $cursor class = $1 rs = $2 comment = $3 ch = get_character($cursor - 1) pos = search(class, $cursor - 1, "regex", "backward") comment = "search(\""class"\", $cursor - 1, \"regex\", \"backward\")\n" \ "first = '"ch"'\n" \ "opos = " opos " pos = " pos "\n" comment if (pos == -1) { # at start of buffer? set_cursor_pos(0) ColMoveBackByWord(opos, rs, comment "\n'" get_range(opos, $cursor) "'") } else if (pos == opos -1) { # no movement? backward_character() ColMoveBackByWord(opos, rs, comment " - no movement\n'" get_range(opos, $cursor) "'") MoveBackByWord() } else { set_cursor_pos(pos + 1) ColMoveBackByWord(opos, rs, comment "\n'" get_range(opos, $cursor) "'") } } define MoveBackByWord { opos = $cursor if ($selection_start == -1) { if ($cursor > 0) { a = get_character($cursor) if (search_string(a, "\\w", 0, "regex") >= 0) { # word chars MoveBackByWordStep("\\W", "w", "word chars") } else if (search_string(a, "\n", 0) >= 0) { # newline (end-of-line) backward_character() ColMoveBackByWord(opos, "n", "newline\n'" get_range(opos, $cursor) "'") MoveBackByWord() } else if (search_string(a, "\\s", 0, "regex") >= 0) { # other space chars MoveBackByWordStep("\\S", "s", "space") } # else if (search_string(a, "\\y", 0, "regex") >= 0) { # delimiter chars # MoveBackByWordStep("\\Y", "y", "delimiter") # } else { # anything else MoveBackByWordStep("[\\w\\s\n]", "o", "other") } } } else beginning_of_selection() npos = $cursor deselect_all() }