Change behavior of Snarf: if executed in window tag, use selection from current window or none at all. Do not use active window selection ever. (Fixes bug reported on 9fans, saner behavior.) Change behavior of Indent: Indent ON and OFF now affect all windows, not just windows yet to be created. Reference: /n/sources/patch/applied/acme-exec Date: Fri Jun 15 06:05:04 CES 2007 Signed-off-by: rsc@swtch.com --- /sys/src/cmd/acme/exec.c Fri Jun 15 06:05:01 2007 +++ /sys/src/cmd/acme/exec.c Fri Jun 15 06:06:22 2007 @@ -13,6 +13,22 @@ Buffer snarfbuf; +/* + * These functions get called as: + * + * fn(et, t, argt, flag1, flag1, flag2, s, n); + * + * Where the arguments are: + * + * et: the Text* in which the executing event (click) occurred + * t: the Text* containing the current selection (Edit, Cut, Snarf, Paste) + * argt: the Text* containing the argument for a 2-1 click. + * e->flag1: from Exectab entry + * e->flag2: from Exectab entry + * s: the command line remainder (e.g., "x" if executing "Dump x") + * n: length of s (s is *not* NUL-terminated) + */ + void del(Text*, Text*, Text*, int, int, Rune*, int); void delcol(Text*, Text*, Text*, int, int, Rune*, int); void dump(Text*, Text*, Text*, int, int, Rune*, int); @@ -660,19 +676,25 @@ uint q0, q1, n, locked, c; Rune *r; - /* use current window if snarfing and its selection is non-null */ - if(et!=nil && dosnarf && et->w!=nil && t==nil){ + /* + * if not executing a mouse chord (et != t) and snarfing (dosnarf) + * and executed Cut or Snarf in window tag (et->w != nil), + * then use the window body selection or the tag selection + * or do nothing at all. + */ + if(et!=t && dosnarf && et->w!=nil){ if(et->w->body.q1>et->w->body.q0){ t = &et->w->body; if(docut) filemark(t->file); /* seq has been incremented by execute */ }else if(et->w->tag.q1>et->w->tag.q0) t = &et->w->tag; + else + t = nil; } - if(t == nil){ - /* can only happen if seltext == nil */ + if(t == nil) /* no selection */ return; - } + locked = FALSE; if(t->w!=nil && et->w!=t->w){ locked = TRUE; @@ -1047,6 +1069,12 @@ return runestrncmp(s, L"on", n) == 0; } +static void +fixindent(Window *w, void*) +{ + w->autoindent = globalautoindent; +} + void indent(Text *et, Text*, Text *argt, int, int, Rune *arg, int narg) { @@ -1066,17 +1094,10 @@ if(a != arg) autoindent = indentval(arg, narg-na); } - if(w != nil){ - switch(autoindent){ - case Ion: - case Ioff: - w->autoindent = autoindent; - break; - case IGlobal: - w->autoindent = globalautoindent; - break; - } - } + if(autoindent == IGlobal) + allwindows(fixindent, nil); + else if(w != nil && autoindent >= 0) + w->autoindent = autoindent; } void --- /sys/man/1/acme Fri Jun 15 06:05:03 2007 +++ /sys/man/1/acme Fri Jun 15 06:05:02 2007 @@ -366,7 +366,7 @@ .B ON and .B OFF -set the mode for the current window and all future windows. +set the mode for all existing and future windows. .TP .B Kill Send a