[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master d60e5a9: Make RefTeX work with LaTeX subfiles packa
From: |
Tassilo Horn |
Subject: |
[Emacs-diffs] master d60e5a9: Make RefTeX work with LaTeX subfiles package |
Date: |
Wed, 21 Oct 2015 12:18:41 +0000 |
branch: master
commit d60e5a9da157f452d891d92f7337d254a1775787
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
Make RefTeX work with LaTeX subfiles package
* lisp/textmodes/reftex.el (reftex-TeX-master-file): Recognize subfiles
document class argument as master file for referencing purposes.
---
lisp/textmodes/reftex.el | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 6641523..84efa7a 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -306,12 +306,28 @@ If the symbols for the current master file do not exist,
they are created."
(let
((master
(cond
- ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
+ ;; Test if we're in a subfile using the subfiles document
+ ;; class, e.g., \documentclass[main.tex]{subfiles}. It's
+ ;; argument is the main file, however it's not really the
+ ;; master file in `TeX-master-file' or `tex-main-file's
+ ;; sense. It should be used for references but not for
+ ;; compilation, thus subfiles use a setting of
+ ;; `TeX-master'/`tex-main-file' being themselves.
+ ((save-excursion
+ (goto-char (point-min))
+ (re-search-forward
+ "^[[:space:]]*\\\\documentclass\\[\\([[:word:].]+\\)\\]{subfiles}"
+ nil t))
+ (match-string-no-properties 1))
+ ;; AUCTeX is loaded. Use its mechanism.
+ ((fboundp 'TeX-master-file)
(condition-case nil
(TeX-master-file t)
(error (buffer-file-name))))
- ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode
- ((boundp 'TeX-master) ; The variable is defined - let's use it.
+ ;; Emacs LaTeX mode
+ ((fboundp 'tex-main-file) (tex-main-file))
+ ;; Check the `TeX-master' variable.
+ ((boundp 'TeX-master)
(cond
((eq TeX-master t)
(buffer-file-name))
@@ -322,6 +338,7 @@ If the symbols for the current master file do not exist,
they are created."
(t
(setq TeX-master (read-file-name "Master file: "
nil nil t nil)))))
+ ;; Check the `tex-main-file' variable.
((boundp 'tex-main-file)
;; This is the variable from the default TeX modes.
(cond
@@ -331,8 +348,9 @@ If the symbols for the current master file do not exist,
they are created."
(t
;; In this case, the buffer is its own master.
(buffer-file-name))))
+ ;; We know nothing about master file. Assume this is a
+ ;; master file.
(t
- ;; Know nothing about master file. Assume this is a master file.
(buffer-file-name)))))
(cond
((null master)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master d60e5a9: Make RefTeX work with LaTeX subfiles package,
Tassilo Horn <=