When trying to run it I get

M-x buffer-file-name [No match]

But it has a function help entry via C-h f and I can evaluate it with M-: buffer-file-name. So why isn't it accessible via M-x?


1 Answer 1


buffer-file-name is a function, but not an interactive command. M-x calls execute-extended-command, so can't be used on non-command functions.

For more information, see What is the difference between a function and a command?.

  • 3
    However it's worth mentioning you can run M-: (eval-expression) and evaluate "(buffer-file-name)" in the mini-buffer or in ielm.
    – stsquad
    Commented Mar 23, 2015 at 15:37

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