Some background, I have some code that sets a default compile command depending on the mode. However, in some files, I've used the add-file-local-variable-prop-line to create a more specific command, and this overwrites that. I need to check if compile-command has been defined for the file, so I don't assign a default value when the file already has a compile-command.

I've tried using file-local-variables-alist, but it's value is nil, even when there are local variables.


1 Answer 1


Where are you trying to use file-local-variables-alist?

If you're using a mode hook, local variables haven't been processed yet.

Use hack-local-variables-hook.

  • I'm not using a mode hook, so I expect it's something else.
    – user2699
    Oct 20, 2015 at 20:22
  • That doesn't answer my question, though.
    – phils
    Oct 20, 2015 at 23:24
  • Oh, I'm trying to use it a function bound to a keyboard shortcut. It looks like something in my init file was causing some file local variables to not be processed.
    – user2699
    Oct 21, 2015 at 19:38
  • 1
    I guess. Check with C-h v to see whether the variable has a buffer-local value or not. If not, then you could use recursive bisection on your config until you figure out the cause.
    – phils
    Oct 22, 2015 at 0:28

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.