emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 4816092 36/48: Fix possible endless loop


From: Tassilo Horn
Subject: [elpa] externals/auctex 4816092 36/48: Fix possible endless loop
Date: Sun, 16 Sep 2018 01:47:26 -0400 (EDT)

branch: externals/auctex
commit 48160922debb8958a51b47fd30aef6afcf55d709
Author: Ikumi Keita <address@hidden>
Commit: Ikumi Keita <address@hidden>

    Fix possible endless loop
    
    * tex.el (TeX-expand-list-builtin): Use symbol `file' for the entry
    "%T" so that special treatment for `file' about advancing matching
    position in `TeX-command-expand' takes effect.
    * tests/tex/command-expansion.el (TeX-command-expand-skip-file-name):
    New test.
---
 tests/tex/command-expansion.el | 29 +++++++++++++++++++++++++++++
 tex.el                         |  5 ++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index 9215a32..14e425d 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -97,4 +97,33 @@
             (TeX-command-expand "%`%(extraopts)%' %T" #'TeX-master-file))
           " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ abc.tex\\ \\}")))
 
+(ert-deftest TeX-command-expand-skip-file-name ()
+  "Check whether file name is not subject to further expansion.
+File names obtained as expansion of \"%t\", \"%s\" and so on should be
+skipped for the following expansion to avoid possible endless loop.
+See <https://lists.gnu.org/r/bug-auctex/2014-08/msg00012.html>."
+  (let ((TeX-master "abc-def")
+       (TeX-expand-list '(("-" (lambda () ":")))))
+    (should (string=
+            (TeX-command-expand "%s" #'TeX-master-file)
+            TeX-master))
+    (should (string=
+            (TeX-command-expand "%t" #'TeX-master-file)
+            (TeX-master-file "tex" t)))
+    (should (string=
+            (TeX-command-expand "%T" #'TeX-master-file)
+            (TeX-master-file "tex" t)))
+    (should (string=
+            (TeX-command-expand "%d" #'TeX-master-file)
+            (TeX-master-file "dvi" t)))
+    (should (string=
+            (TeX-command-expand "%f" #'TeX-master-file)
+            (TeX-master-file "ps" t)))
+    ;; The expander of "%o" does not yet cater for this possible endless
+    ;; loop.
+    ;; (should (string=
+    ;;              (TeX-command-expand "%o" #'TeX-master-file)
+    ;;              (TeX-master-file "pdf" t)))
+    ))
+
 ;;; command-expansion.el ends here
diff --git a/tex.el b/tex.el
index 63ae293..68a7942 100644
--- a/tex.el
+++ b/tex.el
@@ -540,7 +540,10 @@ string."
                  (setq pos (+ pos (length TeX-command-text) 9))
                  (concat TeX-command-text " \"\\input\""))
              "")))
-    ("%T" TeX--master-or-region-file-with-extra-quotes t t nil t)
+    ;; The fourth argument of t is actually for wrapper function
+    ;; `TeX--master-or-region-file-with-extra-quotes', temporally set
+    ;; as value of `file' in `TeX-command-expand'.
+    ("%T" file t t nil t)
     ("%n" TeX-current-line)
     ("%d" file "dvi" t)
     ("%f" file "ps" t)



reply via email to

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