I'd like to check whether some (say, current) buffer is visiting a file or not. I could say:
(if (buffer-file-name) ...)
but it seems to be not very elegant - what I'm interested in is only the boolean value, not the actual name of the buffer in question. If the buffer-file-name
function were written in Elisp, I could look into its source to find out what it uses - but it is written in C, and while I could install the Emacs sources, I'm afraid that I wouldn't find an elisp name for the function that checks what I'm after there anyway.
What I need it for is I want to create a directory based on the name of the current buffer's file, and currently I'm doing more or less this:
(make-directory (if (buffer-file-name) (file-name-base) "default-dir"))
So, what would be the Elisp-idiomatic way of doing this?