I have some code that takes as an argument a function:

(defun message-name (fn)

I would like to be able to, if the function has a name, message it. For example, if called this way:

(message-name #'get-buffer)

I would like this code to message The function's name is get-buffer:

(defun message-name (fn)
  (message "The function's name is %s."
           (????? fn)))

1 Answer 1


If you are passing a symbol (as in your example) then yes, you can get the symbol-name of the argument. e.g.:

(symbol-name fn)

A "function passed as an argument" might also be a function object, though, and you can't pull a symbol name from that. You would have to search for a symbol which had the same value in its function cell.

  • 4
    Small addition: you may want to check if fn is a symbol first with symbolp, as symbol-name will throw an error if fn is not a symbol.
    – JeanPierre
    Aug 11, 2016 at 7:47
  • 2
    To be quite clear, a function argument that is not a symbol (what you call a "function object") may not even have a name. Then searching for the symbol that had the same value in its function cell would be fruitless.
    – user98761
    Aug 29, 2022 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.