I've been struggling with Reftex in org-mode. Initially things are fine,
then after exporting the document to LaTeX and continuing to work with
org-mode, using most of the reftex features (e.g. reftex-toc or trying to
insert a reference) produces a "Wrong type argument: stringp, nil" error
message.
The code in my init file to set up reftex:
;; Reftex
(require 'reftex)
(defun org-mode-reftex-setup ()
(load-library "reftex")
(and (buffer-file-name) (file-exists-p (buffer-file-name))
;enable auto-revert-mode to update reftex when bibtex file changes on disk
(global-auto-revert-mode t)
(reftex-parse-all)
(define-key org-mode-map (kbd "C-c [") 'reftex-citation)
;add a custom reftex cite format to insert links
;; (reftex-set-cite-format "** [[papers:%l][%l]]: %t \n")
)
)
(add-hook 'org-mode-hook 'org-mode-reftex-setup)
At the moment I still enter reftex-mode on demand with "M-x reftex-mode".
Here is the backtrace for the error:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
re-search-forward(nil 10001 t)
tex-main-file()
reftex-TeX-master-file()
reftex-insert-docstruct(#<buffer
paper.org> t "e" nil nil t nil nil ("SEC:lagrange_gibbs_proof" "s" "We define the molar Gibbs free energy in a molecular gas mixture as
\\begin{align} \\h" "/my/path/to/the/
paper.org" nil) "" nil)
byte-code("\306 \307\216\310 \210 \311 \f\203 \312r q\210\313
!)!\210\202&