[Top][All Lists]

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

[Bug-AUCTeX] 11.87; Little problems with 'file' in TeX-command-expand/Te

From: Florent Rougon
Subject: [Bug-AUCTeX] 11.87; Little problems with 'file' in TeX-command-expand/TeX-expand-list
Date: Sun, 24 Aug 2014 22:58:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Hello again,

There is a little problem with the expansion of 'file' in
TeX-command-expand: it does not advance the index 'pos' by the length of
the expansion. As a result, if the file name contains expandable
substrings according to TeX-expand-list, these will be expanded...

In practice, the consequences are minor because the standard expansions
in AUCTeX all start with a % character, except ", and it seems
difficult to feed \input with anything that contains either a % or a "
(except for enclosing a file name in double quotes, in which case they
are not part of the file name).

However, it is still possible to trigger an endless loop with growing
memory use in AUCTeX by trying to compile a file named %t.tex. After the
first expansion, it becomes %t.tex.tex, then %t.tex.tex.tex, etc. The
first attached patch
(auctex_TeX-command-expand_filename_expansion_bug.patch) fixes this.

I also suggest applying a second patch on top of both
auctex_TeX-expand-list.patch from my previous bug report (dated Sun, 24
Aug 2014 16:01:21 +0200) and
auctex_TeX-command-expand_filename_expansion_bug.patch from this mail.
This second patch
(auctex_TeX-command-expand_readability_improvement.patch) would be
useful IMHO because there are two different bindings for the name 'file'
used in TeX-command-expand, one of which is used when expanding entries
from TeX-expand-list (the bad one in the case of %' IMHO), which is
rather confusing for someone reading the code.

This second patch renames the first binding of 'file' to 'filefunc'
(other possible names would be 'unquoted-file' or 'raw-file') and uses
it in the definition of %' in TeX-expand-list. This is the:

  (string-match " "
                (funcall filefunc t t))

part, which makes sure that TeX will see '\input "<filename>"' instead of
'\input <filename>' if <filename> contains at least a space. Therefore,
it makes sense to perform the test on the raw file name (obtained with
'filefunc' with my patch) instead of on the result of
(shell-quote-argument (apply ',file args)) that will only be seen by the
shell, not TeX.

That being said, since the following assertions should be equivalent,
AFAICT, under a POSIX shell:

  f contains at least a space


  (shell-quote-argument f) contains at least a space

using 'file' or 'filefunc' in the above test for %' should result in the
same behavior, even if the logic is a bit twisted... Does someone know
of an Emacs port where the two assertions are not equivalent? :)


Emacs  : GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-08 on trouble, modified by Debian
Package: 11.87

current state:
 AUCTeX-date "2012-11-30"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("auctex-style" "auctex-auto" "/var/lib/auctex/emacs23/"
 TeX-auto-save t
 TeX-parse-self t
 TeX-master t
 TeX-command-list '(("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t"
                     nil (plain-tex-mode ams-tex-mode texinfo-mode) :help
                     "Run plain TeX")
                    ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil
                     (latex-mode doctex-mode) :help "Run LaTeX")
                    ("Makeinfo" "makeinfo %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with Info output")
                    ("Makeinfo HTML" "makeinfo --html %t" TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with HTML output")
                    ("AmSTeX" "%(PDF)amstex %`%S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
                    ("ConTeXt" "texexec --once --texutil %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
                    ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil
                     (context-mode) :help "Run ConTeXt until completion")
                    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help
                     "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
                    ("View" "%V" TeX-run-discard-or-function t t :help
                     "Run Viewer")
                    ("Print" "%p" TeX-run-command t t :help "Print the file")
                    ("Queue" "%q" TeX-run-background nil t :help
                     "View the printer queue" :visible TeX-queue-command)
                    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t :help
                     "Generate PostScript file")
                    ("Index" "makeindex %s" TeX-run-command nil t :help
                     "Create index file")
                    ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
                     :help "Check LaTeX file for correctness")
                    ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil
                     t :help "Spell-check the document")
                    ("Clean" "TeX-clean" TeX-run-function nil t :help
                     "Delete generated intermediate files")
                    ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
                     "Delete generated intermediate and output files")
                    ("Other" "" TeX-run-command t t :help
                     "Run an arbitrary command")
                    ("Dvips" "dvips %d -o %f" TeX-run-command nil nil)
                    ("View with xdvi" "%v" TeX-run-silent nil nil)
                    ("View with xdvi -paper a4r" "%v -paper a4r"
                     nil nil)
                    ("View with the default PostScript viewer" "see %f"
                     TeX-run-discard nil nil)
                    ("View with gv" "gv %f" TeX-run-discard nil nil)
                    ("View with xpdf" "xpdf %s.pdf" TeX-run-silent nil nil)
                    ("View with okular" "okular %s.pdf" TeX-run-silent nil nil))


Attachment: auctex_TeX-command-expand_filename_expansion_bug.patch
Description: Fix 'file' expansion in TeX-command-expand

Attachment: auctex_TeX-command-expand_readability_improvement.patch
Description: Disambiguate the two bindings of 'file' used in TeX-command-expand

reply via email to

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