I wish to
M-x my-func and let my code run. This seems basic but where can I get more documentation about this, if possible inside emacs itself?
You can run the latter, but not the former, by binding commands to
keys or calling them by name via
M-x. See the elisp manual
links above more more details.