suvayu ali <fatkasuvayu+li...@gmail.com> wrote: > Hi Nick, > > On Wed, Mar 7, 2012 at 21:00, Nick Dokos <nicholas.do...@hp.com> wrote: > > As a workaround-and-proof-of-concept, try > > > > (load "tex") > > > > before loading org. Assuming that that works, you will probably want > > to arrange things that this is always done. > > > > This worked as you hypothesised. :) > > > It might also be the case that Carsten's fix needs to be modified to > > check whether TeX-master is bound already - then it can let-bind it > > without problems; but I'm not sure what to do if that's not the case. > > > > The question I have is what exactly causes tex.el to be loaded at that > > point in time. If you can figure that out, then that might lead to a > > more permanent solution. > > I am not sure how I can conclusively confirm that, but I think when I > export to latex, the exported latex buffer loads it. For example, I > don't see this issue when say I go through these steps: > > 1. Open a tex file. > 2. Open and export an org file to latex. > 3. Open a new tex file. > > In this case step (1) must be loading tex.el, circumventing the issue. >
Actually, your backtrace in the original post makes things clearer now. org-export-as-latex calls find-file-noselect on the .tex file, which calls after-find-file which runs the find-file-hook. Somehow the find-file-hook is set up[fn:1] as in VirTeX-common-initialization to call TeX-master-file - although your backtrace shows compiled code, it's pretty clear that that's the setting of the find-file-hook that VirTeX-common-initialization has done. So it looks as if tex.el is partially loaded: the initialization is done, the hook is set up but the defvar has failed, probably because of the let-bind. Nick Footnotes: [fn:1] à la Sidney Harris - cf. http://www.sciencecartoonsplus.com/index.php