[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] GNU AUCTeX branch, lexical-binding-attempt-1, updated. d9
From: |
Ikumi Keita |
Subject: |
[AUCTeX-diffs] GNU AUCTeX branch, lexical-binding-attempt-1, updated. d91a08d905fa80b5ff04deb77672dc9d38a2fc70 |
Date: |
Sat, 12 Sep 2020 04:00:43 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".
The branch, lexical-binding-attempt-1 has been updated
via d91a08d905fa80b5ff04deb77672dc9d38a2fc70 (commit)
from 3268e848c11d57cca9c6d763573769a816663146 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d91a08d905fa80b5ff04deb77672dc9d38a2fc70
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date: Sat Sep 12 14:52:35 2020 +0900
Make "%o" compatible again with file name with spaces
* tex-buf.el (TeX-active-master-with-quotes): Rename from
`TeX--master-or-region-file-with-extra-quotes' and make public.
Incorporate adjust of `TeX-expand-pos' from `TeX-command-expand'.
(TeX-command-expand): Simplify.
* tex.el (TeX-expand-list-builtin): Use renamed function instead of
`TeX-active-master'.
* tests/tex/command-expansion.el (TeX-command-expand-skip-file-name):
Include "%o" in test.
(TeX-command-expand-file-name-with-spaces): New test.
(TeX-command-detokenize): Add case where `TeX-master' has space.
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index bb5c7d4..3b2779d 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -88,13 +88,20 @@
;; Skip on w32 because the quoting style of `shell-quote-argument'
;; is different.
(skip-unless (not (eq system-type 'windows-nt)))
- (should (string=
- (let ((major-mode 'latex-mode)
- (TeX-engine 'default)
- (TeX-master "/tmp/abc")
- (TeX-command-extra-options " \"\\foo\""))
- (TeX-command-expand "%`%(extraopts)%' %T"))
- " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ abc.tex\\ \\}")))
+ (let ((major-mode 'latex-mode)
+ (TeX-engine 'default)
+ (TeX-command-extra-options " \"\\foo\"")
+ TeX-master)
+
+ (setq TeX-master "/tmp/abc")
+ (should (string=
+ (TeX-command-expand "%`%(extraopts)%' %T")
+ " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ abc.tex\\ \\}"))
+
+ (setq TeX-master "/tmp/abc def")
+ (should (string=
+ (TeX-command-expand "%`%(extraopts)%' %T")
+ " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ \\\"abc\\
def.tex\\\"\\ \\}"))))
(ert-deftest TeX-command-expand-skip-file-name ()
"Check whether file name is not subject to further expansion.
@@ -105,6 +112,7 @@ See
<https://lists.gnu.org/r/bug-auctex/2014-08/msg00012.html>."
;; is different.
(skip-unless (not (eq system-type 'windows-nt)))
(let ((TeX-master "abc-def")
+ (TeX-output-extension "pdf")
(TeX-expand-list '(("-" (lambda () ":")))))
(should (string=
(TeX-command-expand "%s")
@@ -121,12 +129,9 @@ See
<https://lists.gnu.org/r/bug-auctex/2014-08/msg00012.html>."
(should (string=
(TeX-command-expand "%f")
(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 "pdf" t)))
- ))
+ (should (string=
+ (TeX-command-expand "%o")
+ (TeX-master-file "pdf" t)))))
(ert-deftest TeX-command-expand-active-master ()
"Test whether `TeX-active-master' is valid argument for
`TeX-command-expand'."
@@ -144,4 +149,27 @@ See
<https://lists.gnu.org/r/bug-auctex/2014-08/msg00012.html>."
(TeX-command-expand "%s")
TeX-region))))
+(ert-deftest TeX-command-expand-file-name-with-spaces ()
+ "Test whether file name with spaces is quoted correctly."
+ (let ((TeX-master "abc def")
+ (TeX-output-extension "pdf"))
+ (should (string=
+ (TeX-command-expand "%s")
+ (shell-quote-argument TeX-master)))
+ (should (string=
+ (TeX-command-expand "%t")
+ (shell-quote-argument (TeX-master-file "tex" t))))
+ (should (string=
+ (TeX-command-expand "%T")
+ (shell-quote-argument (TeX-master-file "tex" t))))
+ (should (string=
+ (TeX-command-expand "%d")
+ (shell-quote-argument (TeX-master-file "dvi" t))))
+ (should (string=
+ (TeX-command-expand "%f")
+ (shell-quote-argument (TeX-master-file "ps" t))))
+ (should (string=
+ (TeX-command-expand "%o")
+ (shell-quote-argument (TeX-master-file "pdf" t))))))
+
;;; command-expansion.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index 134bf36..9b04a07 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -557,13 +557,6 @@ without further expansion."
arguments (cdr (cdr entry)) ;Remaining elements
string (save-match-data
(cond
- ((eq expansion #'TeX-active-master)
- (let ((res (apply
#'TeX--master-or-region-file-with-extra-quotes arguments)))
- ;; Advance past the file name in order to
- ;; prevent expanding any substring of it.
- (setq TeX-expand-pos
- (+ TeX-expand-pos (length res)))
- res))
((functionp expansion)
(apply expansion arguments))
((boundp expansion)
@@ -575,7 +568,7 @@ without further expansion."
(replace-match string t t TeX-expand-command))))
TeX-expand-command))
-(defun TeX--master-or-region-file-with-extra-quotes
+(defun TeX-active-master-with-quotes
(&optional extension nondirectory ask extra)
"Return the current master or region file name with quote for shell.
Pass arguments EXTENSION NONDIRECTORY ASK to `TeX-active-master'.
@@ -587,31 +580,40 @@ the following three conditions are met:
1. compiling with standard (pdf)LaTeX or upLaTeX
2. \" \\input\" is supplemented
3. EXTRA is non-nil (default when expanding \"%T\")
-
-Helper function of `TeX-command-expand'."
- (shell-quote-argument
- (let* ((raw (TeX-active-master extension nondirectory ask))
- ;; String `TeX-command-text' means that the file name is
- ;; given through \input command.
- (quote-for-space (if (and (stringp TeX-command-text)
- (string-match " " raw))
- "\"" "")))
- (format
- (if (and extra
- (stringp TeX-command-text)
- (memq major-mode '(latex-mode doctex-mode))
- (memq TeX-engine '(default uptex)))
- ;; Since TeXLive 2018, the default encoding for LaTeX
- ;; files has been changed to UTF-8 if used with
- ;; classic TeX or pdfTeX. I.e.,
- ;; \usepackage[utf8]{inputenc} is enabled by default
- ;; in (pdf)latex.
- ;; c.f. LaTeX News issue 28
- ;; Due to this change, \detokenize is required to
- ;; recognize non-ascii characters in the file name
- ;; when \input precedes.
- "\\detokenize{ %s }" "%s")
- (concat quote-for-space raw quote-for-space)))))
+Adjust dynamically bound variable `TeX-expand-pos' to avoid possible
+infinite loop in `TeX-command-expand'.
+
+Helper function of `TeX-command-expand'. Use only within entries in
+`TeX-expand-list-builtin' and `TeX-expand-list'."
+ (let ((res
+ (shell-quote-argument
+ (let* ((raw (TeX-active-master extension nondirectory ask))
+ ;; String `TeX-command-text' means that the file name is
+ ;; given through \input command.
+ (quote-for-space (if (and (stringp TeX-command-text)
+ (string-match " " raw))
+ "\"" "")))
+ (format
+ (if (and extra
+ (stringp TeX-command-text)
+ (memq major-mode '(latex-mode doctex-mode))
+ (memq TeX-engine '(default uptex)))
+ ;; Since TeXLive 2018, the default encoding for LaTeX
+ ;; files has been changed to UTF-8 if used with
+ ;; classic TeX or pdfTeX. I.e.,
+ ;; \usepackage[utf8]{inputenc} is enabled by default
+ ;; in (pdf)latex.
+ ;; c.f. LaTeX News issue 28
+ ;; Due to this change, \detokenize is required to
+ ;; recognize non-ascii characters in the file name
+ ;; when \input precedes.
+ "\\detokenize{ %s }" "%s")
+ (concat quote-for-space raw quote-for-space))))))
+ ;; Advance past the file name in order to
+ ;; prevent expanding any substring of it.
+ (setq TeX-expand-pos
+ (+ TeX-expand-pos (length res)))
+ res))
(defun TeX-check-files (derived originals extensions)
"Check if DERIVED is newer than any of the ORIGINALS.
diff --git a/tex.el b/tex.el
index efcb8e1..dd74f07 100644
--- a/tex.el
+++ b/tex.el
@@ -80,7 +80,6 @@
(defvar TeX-mode-map)
(defvar TeX-mode-p)
(defvar TeX-output-extension)
-(defvar TeX-output-extension)
(defvar TeX-source-correlate-mode)
(defvar TeX-source-specials-places)
(defvar TeX-source-specials-tex-flags)
@@ -590,10 +589,11 @@ string."
(or (if TeX-source-correlate-output-page-function
(funcall TeX-source-correlate-output-page-function))
"1")))
- ;; `TeX-active-master' calls either calls`TeX-master-file' or
- ;; `TeX-region-file' returning the master or region file.
- ("%s" TeX-active-master nil t)
- ("%t" TeX-active-master t t)
+ ;; `TeX-active-master-with-quotes' calls either `TeX-master-file'
+ ;; or `TeX-region-file' returning the master or region file, and
+ ;; adds suitable quotes for use in shell command line.
+ ("%s" TeX-active-master-with-quotes nil t)
+ ("%t" TeX-active-master-with-quotes t t)
;; If any TeX codes appear in the interval between %` and %', move
;; all of them after the interval and supplement " \input". The
;; appearance is marked by leaving the bind to `TeX-command-text'
@@ -636,15 +636,14 @@ string."
(setq TeX-expand-pos (+ TeX-expand-pos (length
TeX-command-text) 9))
(concat TeX-command-text " \"\\input\""))
"")))
- ;; The fourth argument of t is actually for wrapper function
- ;; provided by `TeX--master-or-region-file-with-extra-quotes'.
- ;; See its doc string as well as the comments in
- ;; `TeX-command-expand'.
- ("%T" TeX-active-master t t nil t)
+ ;; The fourth argument of t directs to supply "\detokenize{}" when
+ ;; necessary. See doc string and comment of
+ ;; `TeX-active-master-with-quotes'.
+ ("%T" TeX-active-master-with-quotes t t nil t)
("%n" TeX-current-line)
- ("%d" TeX-active-master "dvi" t)
- ("%f" TeX-active-master "ps" t)
- ("%o" (lambda nil (TeX-active-master (TeX-output-extension) t)))
+ ("%d" TeX-active-master-with-quotes "dvi" t)
+ ("%f" TeX-active-master-with-quotes "ps" t)
+ ("%o" (lambda nil (TeX-active-master-with-quotes (TeX-output-extension)
t)))
;; for source specials the file name generated for the xdvi
;; command needs to be relative to the master file, just in
;; case the file is in a different subdirectory
-----------------------------------------------------------------------
Summary of changes:
tests/tex/command-expansion.el | 54 +++++++++++++++++++++++++--------
tex-buf.el | 68 ++++++++++++++++++++++--------------------
tex.el | 25 ++++++++--------
3 files changed, 88 insertions(+), 59 deletions(-)
hooks/post-receive
--
GNU AUCTeX
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [AUCTeX-diffs] GNU AUCTeX branch, lexical-binding-attempt-1, updated. d91a08d905fa80b5ff04deb77672dc9d38a2fc70,
Ikumi Keita <=