Assuming you are using dynamic binding you can search through the obarray for your value:
;;; Assumes dynamic binding. This is a macro because a function would
;;; introduce more bound variables that could hide the thing we're
;;; looking for.
(defmacro find-local-val (val)
(let ((sym-var (make-symbol "sym"))
(val-var (make-symbol "val")))
`(catch 'varname
(let ((,val-var ,val))
(mapatoms (lambda (,sym-var)
(when (and (boundp ,sym-var)
(eq (symbol-value ,sym-var) ,val-var))
(throw 'varname ,sym-var))))
(error "Couldn't find a name for %S" ,val-var)))))
(let* ((my-func
(lambda (arg1 arg2 arg3)
(message "arg1: %s | arg2: %s | arg3: %s" arg1 arg2 arg3)))
(my-list (list my-func '("foo" "bar" "baz"))))
(apply (car my-list) (car (cdr my-list)))
(message "I want my-func to appear as \"my-func\": %s"
(find-local-val (car my-list))))
This won't work if my-func
is a lexical variable. Another possibility which always works is to bind with cl-letf
and call it by symbol instead of value:
(cl-letf (((symbol-function 'my-func)
(lambda (arg1 arg2 arg3)
(message "arg1: %s | arg2: %s | arg3: %s" arg1 arg2 arg3))))
(let ((my-list (list #'my-func '("foo" "bar" "baz"))))
(apply (car my-list) (car (cdr my-list)))
(message "I want my-func to appear as \"my-func\": %s"
(car my-list))))