As a proof of concept, I did added the below function to my .mp.mpsl file. What it does is allows you to define a CURSOR point in your template. For example: %%Tcl If if {CURSOR} { } Then, when you insert this template, the function goes back to the insertion point and searches for CURSOR, if found, it replaces it with nothing and leaves the cursor right there. This is my first function and I'm sure it can be done better (i.e. I search twice, so that templates with no CURSOR do not cause any weird cursor movements). I also think it'd be cool to do something like: %%Tcl If if {$Condition$} { $Body$ } Then, you could define a key to bounce from $.*$ (or something like that) to the next one. Just a thought. Once I learn more about MPSL and how all the MP related functions work, I may give that a try (unless someone gets to it first). Anyway, here is the function I am currently using: mp.actions['insert_template'] = sub(d) { local l, t; local startline = d.txt.y; /* no local templates? do nothing */ if((l = mp.long_op(mp.read_templates_file)) == NULL) return; /* select one */ if((t = mp.form( [ { 'label' => L("Template to insert:"), 'type' => 'list', 'list' => l } ])) == NULL) return; t = t[0]; mp.store_undo(d); /* insert the template content */ mp.insert(d, mp.templates[l[t]]); local endline = d.txt.y; local endcol = d.txt.x; mp.set_x(d, 0); mp.set_y(d, startline); if (mp.search(d, "CURSOR")) { mp.set_x(d, 0); mp.set_y(d, startline); mp.replace_1(d, "CURSOR", ""); } else { mp.set_x(d, endcol); mp.set_y(d, endline); } }; Thanks! Jeremy -- To unsubscribe, send mail to mp-unsubscribe_lists.triptico.com.Received on Thu Sep 06 2007 - 19:46:19 CEST
This archive was generated by hypermail 2.2.0 : Thu Apr 10 2008 - 08:59:26 CEST