# HG changeset patch # User Uwe Brauer # Date 1480170387 0 # Sat Nov 26 14:26:27 2016 +0000 # Node ID 0994295a9ce6cdb4f74c0bbf992766e71aa0f6d9 # Parent 9b1c89d96d8f5ec02c7b1faf0469687c167375d3 style/subfiles.el: implement reftex-references natively. * style/subfiles.el ("subfiles"): use patch provided by Arash Esbati, which implements reftex-references without modifying `reftex-include-file-commands'. diff --git a/style/subfiles.el b/style/subfiles.el --- a/style/subfiles.el +++ b/style/subfiles.el @@ -41,16 +41,33 @@ (lambda () ;; The following code will fontify `\subfile{}' like include. (when (and (featurep 'font-latex) - (eq TeX-install-font-lock 'font-latex-setup)) + (eq TeX-install-font-lock 'font-latex-setup)) (font-latex-add-keywords '(("subfile" "{")) - 'reference)) + 'reference)) ;; The following code will run `TeX-run-style-hooks' on the subfile master file. ;; Thanks to Mosè Giordano for presenting a better solution using `assoc'. (TeX-run-style-hooks (file-name-base (cadr (assoc "subfiles" LaTeX-provided-class-options)))) (TeX-add-symbols - '("subfile" TeX-arg-file))) + '("subfile" TeX-arg-file)) + + ;; Ensure that \subfile stays in one line + (LaTeX-paragraph-commands-add-locally "subfile") + + ;; Tell AUCTeX that \subfile loads a file. regexp is the same as + ;; for \input or \include. This will run `TeX-run-style-hooks' on + ;; subfile(s) when master file is loaded. + (TeX-auto-add-regexp + `(,(concat + "\\\\subfile" + "{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}") + 1 TeX-auto-file)) + + ;; Tell RefTeX the same thing. + (when (and (boundp 'reftex-include-file-commands) + (not (member "subfile" reftex-include-file-commands))) + (add-to-list 'reftex-include-file-commands "subfile" t) + (reftex-compile-variables))) LaTeX-dialect) - ;;; subfiles.el ends here