diff --git a/config.el b/config.el index bfcaaad..64ef601 100644 --- a/config.el +++ b/config.el @@ -389,6 +389,32 @@ Bound to cmd+v in org-mode and markdown-mode." (setq org-latex-pdf-process '("latexmk -f -pdf -%latex -interaction=nonstopmode -output-directory=%o %f"))) +;;; LaTeX aux file cleanup after export +;; org-latex-remove-logfiles t is the default; extend the list to cover all +;; latexmk output files (bbl, fdb_latexmk, fls, synctex.gz, run.xml, etc.) +(with-eval-after-load 'ox-latex + (setq org-latex-remove-logfiles t + org-latex-logfiles-extensions + '("aux" "bbl" "bcf" "blg" "fdb_latexmk" "fls" "idx" "log" + "nav" "out" "ptc" "run.xml" "snm" "synctex.gz" "toc" "vrb" "xdv"))) + +;;; Export directory routing +;; All exports go to ~/exports// (created automatically if absent). +;; .tex is intermediate for PDF export -- both routed to exports/pdf/. +(defun my/org-export-directory (extension) + "Return ~/exports// directory for file EXTENSION, creating it if needed." + (let* ((ext (downcase (string-trim-left extension "\\."))) + (subdir (if (string= ext "tex") "pdf" ext)) + (dir (expand-file-name (concat "exports/" subdir "/") "~"))) + (make-directory dir t) + dir)) + +(defun my/org-export-output-file-name (orig extension &optional subtreep pub-dir) + "Route org exports to ~/exports// unless pub-dir is already set." + (funcall orig extension subtreep (or pub-dir (my/org-export-directory extension)))) + +(advice-add 'org-export-output-file-name :around #'my/org-export-output-file-name) + ;;; ============================================================ ;;; ORG MODE — CUSTOM BEHAVIOR