Bruno Arine

Ox-hugo auto-export mode with Doom Emacs

I’ve been trying to enable ox-hugo’s auto-export mode for hours. The official documentation instructs to add the following line on your .dir-locals.el file, if the file is already in the same directory as your Org files:

((org-mode . ((eval . (org-hugo-auto-export-mode)))))

If you already have something in your .dir-locals.el and want to ensure you’re adding this extra line in the right place (and with the right number of parentheses), you can also type M-x add-dir-local-variable, choose eval and type org-hugo-auto-export-mode.

The problem is that it didn’t work for me. All variables are successfully loaded when I opened an Org file in that directory, but org-hugo-auto-export-mode was never enabled.

Turns out the problem is a bug in evil, according to this ticket, the package that lets you navigate Emacs with vi keybindings — and which is signature feature of the Doom Emacs ecosystem. Henrik Lissner suggested, in the same ticket, a workaround. I’ve adapted the suggestion, and here’s how to make auto-export work with Org files:

(setq-default enable-local-variables t)
(defadvice! fix-local-vars (&rest _)
  :before #'turn-on-evil-mode
  (when (eq major-mode 'org-mode)
    (hack-local-variables)))

Add the snippet above in Doom Emacs’s config.el file.