Given a string, built by various concatenation, "my-func-name", I would like to call the associated function.
As funcall
expects a function object as parameter, I would like to know if there is a way to retrieve the function reference by its name, so I can execute it.
Hint: I am currently using the Emacs Lisp dialect.
Thank you very much
Bonus: Sample dummy code
(defun my-func-name ()
"My function."
(message "Hello"))
(setq mfname "my-func-name")
;; Not working, obviously
;; (funcall mfname)
Get the symbol of that name with intern
, and then funcall
it:
(funcall (intern "my-func-name"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With