tecosaur / org-latex-preview-todos

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

LaTeX previews created in linked files when exporting #2

Open karthink opened 6 months ago

karthink commented 6 months ago

NOTE: This bug might be gone after recent updates to ox.el, this needs to be verified.

Description:

Call org-export-dispatch in a file that has a link to another Org file. The linked file (journal/2023-01-30.org in the backtrace below) is opened up by org-id-find in the export process.

This file has #+startup: latexpreview, so LaTeX preview generation occurs for that file. Everything in org-mode-hook runs for that file as well! By the time the latex preview generation is done, that file has been closed by the export process

Result: flurry of latex preview errors for overlays that don't exist any more Additional errors caused by functions in org-mode-hook that were expecting the window to be visible

Workaround

Don't open link destination files during the export process in the first place.

Failing that:

Backtrace

  find-file-noselect("~/Documents/roam/journal/2023-01-30.org")    <---- NOT THE FILE I'M EXPORTING
  org-id-find-id-in-file("70f416cd-bbc7-4e7f-84be-fde828fd435c" "~/Documents/roam/journal/2023-01-30.org" nil)
  org-id-find("70f416cd-bbc7-4e7f-84be-fde828fd435c")
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_72>(...)
  #f(compiled-function (--data) #<bytecode -0x1a95339969ab4e20>)(...)
  mapc(#f(compiled-function (--data) #<bytecode -0x1a95339969ab4e20>) (... ... ... ... ... ...))
  #f(compiled-function (--data) #<bytecode -0x1a95339969ab4e20>)((org-data ... ... ... ... ... ... ...))
  org-element-map((org-data ... ... ... ... ... ... ...) link #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_72>)
  org-export--collect-tree-properties((org-data ... ... ... ... ... ... ...) (:export-options nil :back-end ... :translate-alist ... :exported-data #<hash-table eq 0/4001 0x157454308a8d> :input-buffer "graph_oscillat..." :input-file "/home/karthik/..." :latex-class "article" ...))
  org-export--annotate-info(#s(org-export-backend :name latex :parent nil :transcoders (...))
  org-export-as(latex nil nil nil (:output-file "graph_oscillators.tex"))
  org-export-to-file(latex "graph_oscillators.tex" nil nil nil nil nil org-latex-compile)
  org-latex-export-to-pdf(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  command-execute(org-export-dispatch)
tecosaur commented 6 months ago

Could https://github.com/tecosaur/org-latex-preview-todos/issues/13#issuecomment-1879722554 fix this too?

karthink commented 6 months ago

It should, but we'd need to test it.