@capink: looking through your code where you use the template dialog I note that in one case case you reimplement the part that calls the formatter, and in another case you more-or-less reimplement the dialog.
Case 1 is templates.py/TemplateBox. It seems that you were forced to reimplement textbox_changed so you could call safe_format with your new functions. To avoid that I could add two parameters to init
Code:
all_functions=None, builtin_functions=None
This would do 2 things: eliminate the requirement that you override textbox_changed and make your template functions visible in the template dialog. The difference between the two arguments is how the functions are labeled in the template reference box. I suspect that you would add your functions to both the standard builtins and all_funcs, making your functions appear as builtin.
Case 2 is ConditionsEval, which reimplements the entire dialog. I think you were forced to this for the same reason as case 1, and because you wanted to add the widgets for datatype, comparison, condition value, icon, and tooltip. To get around adding the widgets I could add several empty label/QBoxLayout pairs to the base TemplateDialog that are normally invisible, named user_label_N and user_layout_N where N is 1-6. You would use these to add your own fields to TemplateDialog. This would both get rid of a lot of the semi-duplicated code and add the template reference.
If this interests you then I could give you a copy of the necessary files. If it works out for you then I would submit my changes to Kovid.