I want to make it so that I have interactive functions that can only be called from buffers in a certain directory, like variables in `.dir-locals.el`. Is there a way to do this?

For example, say I'm writing a program that has configuration files. I'd like to be able to invoke `M-x new-conf`, which will make a new conf file in the same directory as the buffer I invoke it in. However, I only want to be able to call it from buffers in a certain directory.