aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2015-10-21 14:17:18 +0200
committerTassilo Horn2015-10-21 14:18:34 +0200
commitd60e5a9da157f452d891d92f7337d254a1775787 (patch)
tree871707d6a2d22cab9e8e4f8bede47e374c7b1c4a
parentf2dbc7f9f6bfeb8652b4dceacfefc4549af9bf39 (diff)
downloademacs-d60e5a9da157f452d891d92f7337d254a1775787.tar.gz
emacs-d60e5a9da157f452d891d92f7337d254a1775787.zip
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.
-rw-r--r--lisp/textmodes/reftex.el26
1 files changed, 22 insertions, 4 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 66415234033..84efa7a5b21 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."
306 (let 306 (let
307 ((master 307 ((master
308 (cond 308 (cond
309 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. 309 ;; Test if we're in a subfile using the subfiles document
310 ;; class, e.g., \documentclass[main.tex]{subfiles}. It's
311 ;; argument is the main file, however it's not really the
312 ;; master file in `TeX-master-file' or `tex-main-file's
313 ;; sense. It should be used for references but not for
314 ;; compilation, thus subfiles use a setting of
315 ;; `TeX-master'/`tex-main-file' being themselves.
316 ((save-excursion
317 (goto-char (point-min))
318 (re-search-forward
319 "^[[:space:]]*\\\\documentclass\\[\\([[:word:].]+\\)\\]{subfiles}"
320 nil t))
321 (match-string-no-properties 1))
322 ;; AUCTeX is loaded. Use its mechanism.
323 ((fboundp 'TeX-master-file)
310 (condition-case nil 324 (condition-case nil
311 (TeX-master-file t) 325 (TeX-master-file t)
312 (error (buffer-file-name)))) 326 (error (buffer-file-name))))
313 ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode 327 ;; Emacs LaTeX mode
314 ((boundp 'TeX-master) ; The variable is defined - let's use it. 328 ((fboundp 'tex-main-file) (tex-main-file))
329 ;; Check the `TeX-master' variable.
330 ((boundp 'TeX-master)
315 (cond 331 (cond
316 ((eq TeX-master t) 332 ((eq TeX-master t)
317 (buffer-file-name)) 333 (buffer-file-name))
@@ -322,6 +338,7 @@ If the symbols for the current master file do not exist, they are created."
322 (t 338 (t
323 (setq TeX-master (read-file-name "Master file: " 339 (setq TeX-master (read-file-name "Master file: "
324 nil nil t nil))))) 340 nil nil t nil)))))
341 ;; Check the `tex-main-file' variable.
325 ((boundp 'tex-main-file) 342 ((boundp 'tex-main-file)
326 ;; This is the variable from the default TeX modes. 343 ;; This is the variable from the default TeX modes.
327 (cond 344 (cond
@@ -331,8 +348,9 @@ If the symbols for the current master file do not exist, they are created."
331 (t 348 (t
332 ;; In this case, the buffer is its own master. 349 ;; In this case, the buffer is its own master.
333 (buffer-file-name)))) 350 (buffer-file-name))))
351 ;; We know nothing about master file. Assume this is a
352 ;; master file.
334 (t 353 (t
335 ;; Know nothing about master file. Assume this is a master file.
336 (buffer-file-name))))) 354 (buffer-file-name)))))
337 (cond 355 (cond
338 ((null master) 356 ((null master)