I have just started using Kile, and I would like to set up some custom scripts for various things that may help speed up my writing. One thing I in particular would like to do it make a script that, if executed while the cursor is over the name of a label, gives me a preview of the environment that label sits inside. So for example, if I want to refer to some theorem, and I am not entirely certain I remember which label to refer to, I can type the label and use this script to quickly check in my bottom panel if that is indeed the correct theorem.
Now, I think I can make the script select the desired part of the text, except that I am not sure if I can do a "find" command in the script. But I have not been able to find a way to make the script execute the preview of the selected area. Is this possible?