
http://aescripts.com/rd-pre-compose/
This script displays a dialog box for pre-composing one or more layers (like the built-in Pre-compose dialog box), but adds the ability to trim the pre-comp to the selected layer's duration, with optional trim handles.