GNU bug report logs - #25674
Support for subfiles in `reftex-TeX-master-file'

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Fri, 10 Feb 2017 08:50:02 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25674 in the body.
You can then email your comments to 25674 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#25674; Package auctex. (Fri, 10 Feb 2017 08:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash Esbati <arash <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Fri, 10 Feb 2017 08:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: auctex-bugs <bug-auctex <at> gnu.org>
Subject: Support for subfiles in `reftex-TeX-master-file'
Date: Fri, 10 Feb 2017 09:48:43 +0100
Hi all,

the function `reftex-TeX-master-file' in `reftex.el' has support for
subfiles package, but I think the regexp there does not match all
cases.  Please consider a main file "subfile-main.tex" and a sub-file
"subfile-sub1.tex" like these:

--8<---------------cut here---------------start------------->8---
\documentclass{article}
\usepackage{subfiles}
\begin{document}

\section{Section 1}
\label{sec:section-1}

\subfile{subfile-sub1.tex}
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
\documentclass[subfile-main.tex]{subfiles}
\begin{document}

\section{Subsection 1}
\label{sec:subsection-1}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

`reftex-TeX-master-file' fails to parse the first line and find out the
main file due to first part of it:

--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
         ;; 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))
--8<---------------cut here---------------end--------------->8---

The regexp looks for [:word:] character class and ignores anything
else.  Using `-', `_' or digits in main file name will not work.  I
think the regexp can be reduced to

--8<---------------cut here---------------start------------->8---
            (re-search-forward
             "^[[:space:]]*\\\\documentclass\\[\\([^]]+\\)\\]{subfiles}"
             nil t))
--8<---------------cut here---------------end--------------->8---

as `reftex-TeX-master-file' checks if .tex extension is given or not.
With this change, one can use `C-c )' over all files in a project and
`C-c C-c' compiles a only subfile when issued in it.

Any comments?  I would prepare a patch after confirmation here.

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#25674; Package auctex. (Sun, 12 Feb 2017 15:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 25674 <at> debbugs.gnu.org (full text, mbox):

From: Mosè Giordano <mose <at> gnu.org>
To: Arash Esbati <arash <at> gnu.org>
Cc: 25674 <at> debbugs.gnu.org
Subject: Re: bug#25674: Support for subfiles in `reftex-TeX-master-file'
Date: Sun, 12 Feb 2017 16:12:33 +0100
Hi Arash,

2017-02-10 9:48 GMT+01:00 Arash Esbati <arash <at> gnu.org>:
> Hi all,
>
> the function `reftex-TeX-master-file' in `reftex.el' has support for
> subfiles package, but I think the regexp there does not match all
> cases.  Please consider a main file "subfile-main.tex" and a sub-file
> "subfile-sub1.tex" like these:
>
> --8<---------------cut here---------------start------------->8---
> \documentclass{article}
> \usepackage{subfiles}
> \begin{document}
>
> \section{Section 1}
> \label{sec:section-1}
>
> \subfile{subfile-sub1.tex}
> \end{document}
>
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> --8<---------------cut here---------------end--------------->8---
>
> --8<---------------cut here---------------start------------->8---
> \documentclass[subfile-main.tex]{subfiles}
> \begin{document}
>
> \section{Subsection 1}
> \label{sec:subsection-1}
>
> \end{document}
>
> %%% Local Variables:
> %%% mode: latex
> %%% TeX-master: t
> %%% End:
> --8<---------------cut here---------------end--------------->8---
>
> `reftex-TeX-master-file' fails to parse the first line and find out the
> main file due to first part of it:
>
> --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
>          ;; 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))
> --8<---------------cut here---------------end--------------->8---
>
> The regexp looks for [:word:] character class and ignores anything
> else.  Using `-', `_' or digits in main file name will not work.

Agreed.

> I
> think the regexp can be reduced to
>
> --8<---------------cut here---------------start------------->8---
>             (re-search-forward
>              "^[[:space:]]*\\\\documentclass\\[\\([^]]+\\)\\]{subfiles}"
>              nil t))
> --8<---------------cut here---------------end--------------->8---
>
> as `reftex-TeX-master-file' checks if .tex extension is given or not.
> With this change, one can use `C-c )' over all files in a project and
> `C-c C-c' compiles a only subfile when issued in it.
>
> Any comments?  I would prepare a patch after confirmation here.

`thing-at-point-file-name-chars' is a good list of characters
allowable in filenames (maybe it won't work in some corner case but
should do the job in most cases).  However I don't have a preference
between your regexp and `thing-at-point-file-name-chars'.

Bye,
Mosè




Information forwarded to bug-auctex <at> gnu.org:
bug#25674; Package auctex. (Mon, 13 Feb 2017 08:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 25674 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Mosè Giordano <mose <at> gnu.org>
Cc: 25674 <at> debbugs.gnu.org, Tassilo Horn <tsdh <at> gnu.org>
Subject: Re: bug#25674: Support for subfiles in `reftex-TeX-master-file'
Date: Mon, 13 Feb 2017 09:34:12 +0100
[Message part 1 (text/plain, inline)]
Hi Mosè,

Mosè Giordano <mose <at> gnu.org> writes:

> 2017-02-10 9:48 GMT+01:00 Arash Esbati <arash <at> gnu.org>:
>>
>> I think the regexp can be reduced to
>>
>> --8<---------------cut here---------------start------------->8---
>>             (re-search-forward
>>              "^[[:space:]]*\\\\documentclass\\[\\([^]]+\\)\\]{subfiles}"
>>              nil t))
>> --8<---------------cut here---------------end--------------->8---
>>
>> as `reftex-TeX-master-file' checks if .tex extension is given or not.
>> With this change, one can use `C-c )' over all files in a project and
>> `C-c C-c' compiles a only subfile when issued in it.
>>
>> Any comments?  I would prepare a patch after confirmation here.
>
> `thing-at-point-file-name-chars' is a good list of characters
> allowable in filenames (maybe it won't work in some corner case but
> should do the job in most cases).  However I don't have a preference
> between your regexp and `thing-at-point-file-name-chars'.

Thanks for your response and the hint.  I see that @ is missing in
`thing-at-point-file-name-chars', I hope that nobody names a file
"m <at> in.tex" (corner case as you said), but I think we are on the safe
side if we match everything and reduce the support factor in future ;-)

@Tassilo: Can please apply this patch to Emacs master?  TIA.

[0001-Match-all-characters-in-optional-argument-of-documen.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Best, Arash

Information forwarded to bug-auctex <at> gnu.org:
bug#25674; Package auctex. (Mon, 13 Feb 2017 16:08:02 GMT) Full text and rfc822 format available.

Message #14 received at 25674 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Arash Esbati <arash <at> gnu.org>
Cc: Mosè Giordano <mose <at> gnu.org>, 25674 <at> debbugs.gnu.org
Subject: Re: bug#25674: Support for subfiles in `reftex-TeX-master-file'
Date: Mon, 13 Feb 2017 17:07:41 +0100
Arash Esbati <arash <at> gnu.org> writes:

> @Tassilo: Can please apply this patch to Emacs master?  TIA.

Done!

Bye,
Tassilo




Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Mon, 13 Feb 2017 18:28:01 GMT) Full text and rfc822 format available.

Notification sent to Arash Esbati <arash <at> gnu.org>:
bug acknowledged by developer. (Mon, 13 Feb 2017 18:28:01 GMT) Full text and rfc822 format available.

Message #19 received at 25674-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: Mosè Giordano <mose <at> gnu.org>, 25674-done <at> debbugs.gnu.org
Subject: Re: bug#25674: Support for subfiles in `reftex-TeX-master-file'
Date: Mon, 13 Feb 2017 19:27:21 +0100
Tassilo Horn <tsdh <at> gnu.org> writes:

> Arash Esbati <arash <at> gnu.org> writes:
>
>> @Tassilo: Can please apply this patch to Emacs master?  TIA.
>
> Done!

Thanks, I close this one then.

Best, Arash




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 14 Mar 2017 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 102 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.