1 ;;; subfiles.el --- AUCTeX style for the subfiles package.
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
5 ;; Author: Uwe Brauer <oub@mat.ucm.es>
6 ;; Created: 07 Nov 2016
9 ;; This file is part of AUCTeX.
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 ;; Mosè Giordano <mose@gnu.org>
28 ;; Arash Esbati <arash@gnu.org>
32 ;; This file adds support for the subfiles package.
36 (defvar LaTeX-subfiles-package-options nil
37 "Package options for the subfiles package.")
39 (defun LaTeX-subfiles-class-options ()
40 "Return name of the main file relative to current subfile."
43 "Main file: " nil nil nil nil
45 (string-match "\\.tex$" texfiles)))
46 (TeX-master-directory)))
52 ;; The following code will run `TeX-run-style-hooks' on the subfile
53 ;; master file. Thanks to Mosè Giordano <mose@gnu.org> for
54 ;; presenting a better solution using `assoc'.
55 (let ((master-file (cadr (assoc "subfiles" LaTeX-provided-class-options))))
56 (when (stringp master-file)
58 (file-name-sans-extension master-file))))
61 '("subfile" TeX-arg-file))
63 ;; Ensure that \subfile stays in one line
64 (LaTeX-paragraph-commands-add-locally "subfile")
66 ;; Tell AUCTeX that \subfile loads a file. regexp is the same as
67 ;; for \input or \include. This will run `TeX-run-style-hooks' on
68 ;; subfile(s) when master file is loaded.
72 "{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}")
75 ;; Tell RefTeX the same thing.
76 (when (and (boundp 'reftex-include-file-commands)
77 (not (member "subfile" reftex-include-file-commands)))
78 (add-to-list 'reftex-include-file-commands "subfile" t)
79 (reftex-compile-variables))
81 ;; The following code will fontify `\subfile{}' like \input.
82 (when (and (featurep 'font-latex)
83 (eq TeX-install-font-lock 'font-latex-setup))
84 (font-latex-add-keywords '(("subfile" "{"))
88 ;;; subfiles.el ends here