Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: narrow-to-region (was Re: This widget implementation feels a bit clunky)



On Jul 20, 11:19am, Oliver Kiddle wrote:
} Subject: Re: PATCH: narrow-to-region (was Re: This widget implementation f
}
} Bart wrote:
} > } It'd also be good for the function to use the new undo limit features.
} > 
} > I was going to send a follow-up message about undo-ing and whether a call
} > to split-undo is needed before (and/or after) the recursive-edit.
} 
} It is needed immediately after you've setup PREDISPLAY and emptied
} BUFFER.

The sourceforge outage is getting a bit annoying with respect to passing
these patches back and forth.

} > Related, should -S / -R implicitly set undo points?
} 
} I've never used those two options and am not sure I quite understand
} what they're for. At least not without digging in the archives. With the
} patch below, it is fairly obviously broken for them because
} _ntr_changeno is set in a different block from the one which does zle
} undo to revert to it.

The -S and -R options are basically a hack to because there's no good way
to do a callback mechansim.  What you'd like is to replace recursive-edit
with a call back into the invoking scope, but you can't do that without
real closures or at least real namerefs, so "narrow-to-region -S" does
everything up to recursive-edit and then saves state, followed by -R
which restores state and picks up where -S left off.

If you introduce new variables _ntr_savelim and _ntr_changeno those are
going to have to be added to the state save/restore, or else they have
to be localized to the part where recursive-edit is called and NOT the
parts where state is saved/restored.

Also this --

}    PREDISPLAY=$_ntr_predisplay
}    POSTDISPLAY=$_ntr_postdisplay
} -  LBUFFER="$_ntr_lbuffer$BUFFER"
} -  RBUFFER="$_ntr_rbuffer"
} +  LBUFFER="$_ntr_lbuffer$_ntr_newlbuf"
} +  RBUFFER="$_ntr_newrbuf$_ntr_rbuffer"
}    MARK=${#_ntr_lbuffer}

-- breaks MARK and CURSOR again, you need

LBUFFER="$_ntr_lbuffer$_ntr_newlbuf$_ntr_newrbuf"
RBUFFER="$_ntr_rbuffer"

to get CURSOR in the right place.  Which means you may as well not save
the left and right buffers separately to begin with.



Messages sorted by: Reverse Date, Date, Thread, Author