Configuring the org-download save directory

🔔 NOTE: Since this was written, I’m no longer customizing Org’s attachment or download handling. I tired of changing my mind and breaking links. Everything now goes into ugly, gross UUID folders as is the default.


When I drag and drop an image into Emacs, I want the attached file to end up in ./img/YYYY/. This is how I tried configuring org-download in my setup (I use Doom Emacs):

    (setq org-download-method 'directory
            org-download-image-dir (concat "img/"  (format-time-string "%Y") "/")
            org-download-image-org-width 600
            org-download-heading-lvl 1)

    (setq org-download-method 'directory
            org-download-image-dir (concat "img/"  (format-time-string "%Y") "/")
            org-download-image-org-width 600
            org-download-heading-lvl 1)

For some reason, org-download-method was being reset from 'directory to 'attachafter loading, and this broke things. I thought maybe I needed to set the variables _after_org-download was loaded, so I did this:

    (after! org-download
      (setq org-download-method 'directory
            org-download-image-dir (concat "img/"  (format-time-string "%Y") "/")
            org-download-image-org-width 600
            org-download-heading-lvl 1))

That didn’t work. At startup I was seeing this error:

Error (org-mode-hook): Error running hook “org-fancy-priorities-mode” because: (void-variable org-download-image-dir)

Huh. I guess not everything can be set after org-download, so I tried only setting org-download-method

    (after! org-download
      (setq org-download-method 'directory))

This worked. The other settings are done in the (after! org block.

It feels like I have to fight Doom too often, but the details and refinement of Doom is worth the trouble.