tecosaur / org-latex-preview-todos

A tracker for the Org LaTeX Preview effort on https://git.tecosaur.net/tec/org-mode
5 stars 0 forks source link

exporting fails when running emacs in batch mode #46

Open mahmoodsh36 opened 3 weeks ago

mahmoodsh36 commented 3 weeks ago

when operating in batch mode emacs applies some special values to faces that arent handled properly by org-latex-preview and cause it to error out. this is a full stack trace (to avoid confusion: note that some of the stuff at the end are functions that i wrote that invoke the exporter):

Debugger entered--Lisp error: (error "Not enough arguments for format string")
  format("%.3f,%.3f,%.3f")
  org-latex-preview--format-color("unspecified-fg")
  org-latex-preview--tex-styled(dvisvgm "\\begin{tikzpicture}\n  \\begin{axis}[xlabel={$\\Delta x$ (m)}, ylabel={$Mg$ (N)}]\n    \\addplot [color=red, domain=0:0.08, mark=none] {0.0051026+10.372231*\\x};\n\n    \\addplot[scatter, only marks, scatter src=\\thisrow{class},\n    error bars/.cd, y dir=both, x dir=both, y explicit, x explicit, error bar style={color=mapped color}]\n    table[x=x,y=y,x error=xerr,y error=yerr] {\n      x      xerr      y        yerr     class\n      0.0047 0.0007071 0.054039 0.000098 0\n      0.0142 0.0007071 0.152651 0.000098 0\n      0.0237 0.0007071 0.252051 0.000098 0\n      0.0332 0.0007071 0.350466 0.000098 0\n      0.0525 0.0007071 0.548380 0.000098 0\n      0.0622 0.0007071 0.646893 0.000098 0\n      0.0720 0.0007071 0.746195 0.000098 0\n      0.0802 0.0007071 0.844709 0.000098 0\n    };\n  \\end{axis}\n\\end{tikzpicture}\n" (:foreground "unspecified-fg" :background "Transparent" :scale 1.0 :zoom 1.0 :page-width 0.6 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[") :number nil :continue-color nil))
  org-latex-preview-cache-images((org-data ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  (let ((preview-table (org-latex-preview-cache-images (org-element-parse-buffer)))) (cl-some #'(lambda (key) (if (equal position (org-element-begin key)) (progn (car (gethash key preview-table))))) (hash-table-keys preview-table)))
  (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" (org-no-properties (thing-at-point 'line))) (progn (forward-line))) (let ((preview-table (org-latex-preview-cache-images (org-element-parse-buffer)))) (cl-some #'(lambda (key) (if (equal position (org-element-begin key)) (progn (car ...)))) (hash-table-keys preview-table))))
  (setq g28 (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" (org-no-properties (thing-at-point 'line))) (progn (forward-line))) (let ((preview-table (org-latex-preview-cache-images (org-element-parse-buffer)))) (cl-some #'(lambda (key) (if (equal position ...) (progn ...))) (hash-table-keys preview-table)))))
  (save-current-buffer (set-buffer (or (find-buffer-visiting filepath) (find-file-noselect filepath))) (setq g28 (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" (org-no-properties (thing-at-point 'line))) (progn (forward-line))) (let ((preview-table (org-latex-preview-cache-images (org-element-parse-buffer)))) (cl-some #'(lambda (key) (if ... ...)) (hash-table-keys preview-table))))) (if (not g27) (progn (kill-buffer (current-buffer)))) g28)
  (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting filepath) (find-file-noselect filepath))) (setq g28 (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" (org-no-properties (thing-at-point ...))) (progn (forward-line))) (let ((preview-table (org-latex-preview-cache-images ...))) (cl-some #'(lambda ... ...) (hash-table-keys preview-table))))) (if (not g27) (progn (kill-buffer (current-buffer)))) g28))
  (let ((g27 (find-buffer-visiting filepath)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting filepath) (find-file-noselect filepath))) (setq g28 (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" (org-no-properties ...)) (progn (forward-line))) (let ((preview-table ...)) (cl-some #'... (hash-table-keys preview-table))))) (if (not g27) (progn (kill-buffer (current-buffer)))) g28)))
  (let* ((blk-entry (car (blk-find-by-id blk-id))) (filepath (plist-get blk-entry :filepath)) (position (plist-get blk-entry :position))) (let ((g27 (find-buffer-visiting filepath)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting filepath) (find-file-noselect filepath))) (setq g28 (progn (goto-char position) (beginning-of-line) (setq position (line-beginning-position)) (if (s-prefix-p "#+name:" ...) (progn ...)) (let (...) (cl-some ... ...)))) (if (not g27) (progn (kill-buffer (current-buffer)))) g28))))
  get-latex-preview-svg-by-blk-id("fig-graph-1")
  eval((get-latex-preview-svg-by-blk-id "fig-graph-1"))
  (if (string-prefix-p "(" value) (eval (car (read-from-string value))) value)
  (let ((value (car (cdr (car (org-collect-keywords (list kw))))))) (if (string-prefix-p "(" value) (eval (car (read-from-string value))) value))
  org-get-keyword("image")
  (progn (org-get-keyword kw))
  (setq g16 (progn (org-get-keyword kw)))
  (save-current-buffer (set-buffer (or (find-buffer-visiting orgfile) (find-file-noselect orgfile))) (setq g16 (progn (org-get-keyword kw))) (if (not g15) (progn (kill-buffer (current-buffer)))) g16)
...
  (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm)))
  (let ((elm (org-element-at-point))) (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm))))
  (progn (goto-char position) (let ((elm (org-element-at-point))) (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm)))))
  (setq g20 (progn (goto-char position) (let ((elm (org-element-at-point))) (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm))))))
  (save-current-buffer (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))) (setq g20 (progn (goto-char position) (let ((elm (org-element-at-point))) (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm)))))) (if (not g19) (progn (kill-buffer (current-buffer)))) g20)
  (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))) (setq g20 (progn (goto-char position) (let ((elm (org-element-at-point))) (if (eq (org-element-type elm) elm-type) (progn (funcall fn elm)))))) (if (not g19) (progn (kill-buffer (current-buffer)))) g20))
  (let ((g19 (find-buffer-visiting file)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))) (setq g20 (progn (goto-char position) (let ((elm ...)) (if (eq ... elm-type) (progn ...))))) (if (not g19) (progn (kill-buffer (current-buffer)))) g20)))
  (let ((file (plist-get result :filepath)) (position (plist-get result :position))) (let ((g19 (find-buffer-visiting file)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))) (setq g20 (progn (goto-char position) (let (...) (if ... ...)))) (if (not g19) (progn (kill-buffer (current-buffer)))) g20))))
  (let ((result (car tail))) (let ((file (plist-get result :filepath)) (position (plist-get result :position))) (let ((g19 (find-buffer-visiting file)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))) (setq g20 (progn (goto-char position) (let ... ...))) (if (not g19) (progn (kill-buffer ...))) g20)))) (setq tail (cdr tail)))
  (while tail (let ((result (car tail))) (let ((file (plist-get result :filepath)) (position (plist-get result :position))) (let ((g19 (find-buffer-visiting file)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer (or ... ...)) (setq g20 (progn ... ...)) (if (not g19) (progn ...)) g20)))) (setq tail (cdr tail))))
  (let ((tail grep-results)) (while tail (let ((result (car tail))) (let ((file (plist-get result :filepath)) (position (plist-get result :position))) (let ((g19 (find-buffer-visiting file)) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer (set-buffer ...) (setq g20 ...) (if ... ...) g20)))) (setq tail (cdr tail)))))
  (let ((grep-results (grep-org-dir dir regex))) (let ((tail grep-results)) (while tail (let ((result (car tail))) (let ((file (plist-get result :filepath)) (position (plist-get result :position))) (let ((g19 ...) (org-startup-with-latex-preview nil)) (save-excursion (save-current-buffer ... ... ... g20)))) (setq tail (cdr tail))))))
  map-org-dir-elements("/home/mahmooz/brain/notes" ":forexport:" headline #f(lambda (_) :dynbind (org-export-heading-html)))
  (let* ((org-inhibit-startup t) (should-export-org-file-function #'should-export-org-file) (files-to-export (if (boundp 'files-to-export) files-to-export (collect-org-files-to-export)))) (map-org-dir-elements *notes-dir* ":forexport:" 'headline #'(lambda (_) (org-export-heading-html))) (export-all-org-files :html-p t) (generate-and-save-website-search-data) (export-html-as-org-file "search" (org-file-contents (from-template "search.html"))))
  export-all-org-files-to-html()
  (let ((enable-local-variables nil) (warning-minimum-level :emergency)) (toggle-debug-on-error) (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp")) (require 'setup-utils) (require 'setup-constants) (require 'setup-android) (require 'setup-elpaca) (require 'setup-other) (require 'setup-org) (require 'setup-packages) (require 'setup-theme) (require 'setup-blk) (elpaca-wait) (export-all-org-files-to-html))
  eval((let ((enable-local-variables nil) (warning-minimum-level :emergency)) (toggle-debug-on-error) (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp")) (require 'setup-utils) (require 'setup-constants) (require 'setup-android) (require 'setup-elpaca) (require 'setup-other) (require 'setup-org) (require 'setup-packages) (require 'setup-theme) (require 'setup-blk) (elpaca-wait) (export-all-org-files-to-html)) t)
  command-line-1(("--eval" "(let ((enable-local-variables nil) ;; to avoid some errors when those use some stuff not in emacs by default\n      (warning-minimum-level :emergency)) ;; reduce warnings\n\n  (toggle-debug-on-error)\n  (add-to-list 'load-path (expand-file-name \"~/.emacs.d/lisp\"))\n  (require 'setup-utils)\n  (require 'setup-constants)\n  (require 'setup-android)\n  (require 'setup-elpaca)\n  (require 'setup-other)\n  (require 'setup-org)\n  (require 'setup-packages)\n  (require 'setup-theme)\n  (require 'setup-blk)\n  (elpaca-wait)(export-all-org-files-to-html))"))
  command-line()
  normal-top-level()
mahmoodsh36 commented 3 weeks ago

for reference, https://emacs.stackexchange.com/questions/80358/unspecified-fg-bg-in-batch-mode-when-querying-foreground-background-colors