Search code examples
emacsorg-mode

File-local variables in `org-mode`


I have the following variables set in my org-mode file:

* conf
# local variables:
# org-agenda-start-on-weekday: 1
# org-clock-report-include-clocking-task: t
# org-duration-format: (quote h:mm) #fails
# end:

They all work great, except for org-duration-format. What am I doing wrong?

(I say it doesn't work because I have to run (setq org-duration-format 'h:mm) to get my preferred format.


Solution

  • The file-local-variables section of the emacs manual (C-h i g (emacs) specifying file variables RET) says:

    the variables in a local variables list are used literally, and are not evaluated first.

    So just use h:mm literally:

    ...
    # org-duration-format: h:mm
    ...
    

    You can also do something like this:

    ...
    # eval: (setq-local org-duration-format 'h:mmm)
    ...
    

    but there is really no need to do that.

    This has nothing to do with Org mode BTW. Try

    # Local Variables:
    # bar: 3
    # foo: bar
    # End:
    

    The file-local value of bar is 3; the file local value of foo is bar: bar is NOT evaluated, so foo does NOT end up with the value 3.