radian-software / apheleia

🌷 Run code formatter on buffer contents without moving point, using RCS patches and dynamic programming.
MIT License
570 stars 80 forks source link

org-mode file looks for prettier with on-save export-to-html hook #83

Open indigoviolet opened 2 years ago

indigoviolet commented 2 years ago

Perhaps related to #29

If you create an org-mode file with the following content, it will export to html on save; it will also start trying to format the file with prettier with global-apheleia-mode turned on.

# Local variables:
# eval: (add-hook 'after-save-hook 'org-html-export-to-html t t)
# end:
raxod502 commented 2 years ago

Yep, can confirm - it looks like org-export-to-file uses code like this to export the HTML file:

        `(let ((output
            (org-export-as
             ',backend ,subtreep ,visible-only ,body-only
             ',ext-plist)))
           (with-temp-buffer
         (insert output)
         (let ((coding-system-for-write ',encoding))
           (write-file ,file)))
           (or (ignore-errors (funcall ',post-process ,file)) ,file)))

Apheleia will need to be adjusted to somehow realize that this invocation of write-file, which invokes Apheleia automatically via after-save-hook, should be ignored.