auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] reftex: feature proposal/feature, subfiles


From: Tassilo Horn
Subject: Re: [AUCTeX-devel] reftex: feature proposal/feature, subfiles
Date: Wed, 21 Oct 2015 10:53:19 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Uwe Brauer <address@hidden> writes:

> So the proposal is:
>
> Could the line
> \documentclass[main.tex]{subfiles}
>
> Be used in that context instead of
> %%% TeX-master: "main"
>
> Or would that have the same effect?

Well, if we'd set the master from that \documentclass it would have the
same effect.  As far as I understand, what you want to have is a no
master file for the subfiles wrt. compilation but main.tex as master
wrt. references.  Is that correct?

If so, could you test this version of `reftex-TeX-master-file' where the
optional argument of the \documenclass is used as master for RefTeX
only, i.e., you stick to TeX-master being t in the subfiles.

--8<---------------cut here---------------start------------->8---
(defun reftex-TeX-master-file ()
  ;; Return the name of the master file associated with the current buffer.
  ;; When AUCTeX is loaded, we will use it's more sophisticated method.
  ;; We also support the default TeX and LaTeX modes by checking for a
  ;; variable tex-main-file.
  (let
      ((master
        (cond
         ;; We're in a subfile using the subfiles document class.  It's
         ;; argument is the master file, however it's not really the master
         ;; file in `TeX-master-file's sense.  It should be used for references
         ;; but not for compilation.
         ((and (boundp 'LaTeX-provided-class-options)
               (string= (caar LaTeX-provided-class-options) "subfiles")
               (cl-cadar LaTeX-provided-class-options)))
         ((fboundp 'TeX-master-file) ; AUCTeX is loaded.  Use its mechanism.
          (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.
          (cond
           ((eq TeX-master t)
            (buffer-file-name))
           ((eq TeX-master 'shared)
            (setq TeX-master (read-file-name "Master file: "
                                             nil nil t nil)))
           (TeX-master)
           (t
            (setq TeX-master (read-file-name "Master file: "
                                             nil nil t nil)))))
         ((boundp 'tex-main-file)
          ;; This is the variable from the default TeX modes.
          (cond
           ((stringp tex-main-file)
            ;; ok, this must be it
            tex-main-file)
           (t
            ;; In this case, the buffer is its own master.
            (buffer-file-name))))
         (t
          ;; Know nothing about master file.  Assume this is a master file.
          (buffer-file-name)))))
    (cond
     ((null master)
      (error "Need a filename for this buffer,  please save it first"))
     ((or (file-exists-p (concat master ".tex"))
          (reftex-get-buffer-visiting (concat master ".tex")))
      ;; Ahh, an extra .tex was missing...
      (setq master (concat master ".tex")))
     ((or (file-exists-p master)
          (reftex-get-buffer-visiting master))
      ;; We either see the file, or have a buffer on it.  OK.
      )
     (t
      ;; Use buffer file name.
      (setq master (buffer-file-name))))
    (expand-file-name master)))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]