// outline_sort v1.01 peter@TurtleCoveTech.com // // Sorts an outline. // Treats the selection or the buffer as an indented outline and sorts // based on the leftmost indented "parents", carrying the subtrees with their // respective parents. // // Skips lines with jEdit auto-settings :setting=value: at the top or bottom // of the file. // // I keep all of my info in plain text outlines (Org-Mode style) and this allows me to sort my outlines. // Note: I bind this to 'CS+O s' (the two letter code Control-Shift-O s). I plan on writing more Outline macros in the style of Org-Mode and binding them to (refile: CS+O r, sort: CS+O s, capture: CS+O c, SearchToSparseTree: SC+O f, archive: CS+O a, etc) // Handy Tip: hit 'control-e s' to select a tree before sorting to sort just one outline tree instead of the entire buffer. import java.util.TreeMap; JEditBuffer buffer=textArea.getBuffer(); tabwidth=buffer.getTabSize(); DEBUG=false; int get_indent(line) { line_notabs=TextUtilities.tabsToSpaces( line, tabwidth); line_indent=0; while( line_indent outline_sort.bsh Sorts buffer or selection as an outline, preserving subtrees. */