Save the cursor location inside every function