// find a previous line that is less than our indentation
// indent to that level, if there are none, indent to 0
unindent: Ymacs_Interactive("P", function(noEmpty) {
if (!this.deleteTransientRegion()) {
this.cmd("back_to_indentation");
var c = this._rowcol.col, r = this._rowcol.row;
var m = /^\s+/.exec(this.code[r]);
if(!m) return
var curr = m[0].length;
var len = 0;
for (var i = r-1; i > 0; i--) {
m = /^\s+/.exec(this.code[i]);
if(m) {
len = m[0].length;
if( len < curr) {
var n = curr - len;
this.cmd("backward_delete_char",n);
return true;
}
}
}
// no indents above, delete to beginning of line
this.cmd("backward_delete_char",curr);
return true;
}
}),
I put it in ymacs-commands.js.
eventually I'd like to associate it with a particular mode but for now
i just have the keybinding in my keymap file.
I think it would be good if it could work on a region or a line, so it
would unindent the entire region if there is one. have to figure out
how to get the region startrow and endrow...
I'm sure the code could be made better, so if you have an suggestions,
fire away.
thanks,
-joe