]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix file name quoting problems in tex-mode
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 6 Dec 2020 18:25:43 +0000 (19:25 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 7 Dec 2020 12:37:44 +0000 (13:37 +0100)
* lisp/textmodes/tex-mode.el (tex--quote-spec): New function
(bug#14286).
(tex-format-cmd): Use it.
(tex-compile): Don't quote the file names, because we're using
`file-exists-p' and friends on the results later, and that fails
on systems where everything is quoted, and on file names that need
quoting.

lisp/textmodes/tex-mode.el

index 37ab11ad89f9c8c011be59328ffebc31107524f2..59238452a4d5ec304ffd63c0ec214a27b3ce6751 100644 (file)
@@ -2331,9 +2331,14 @@ FILE is typically the output DVI or PDF file."
   :version "23.1"
   :group 'tex-run)
 
+(defun tex--quote-spec (fspec)
+  (cl-loop for (char . file) in fspec
+           collect (cons char (shell-quote-argument file))))
+
 (defun tex-format-cmd (format fspec)
   "Like `format-spec' but adds user-specified args to the command.
 Only applies the FSPEC to the args part of FORMAT."
+  (setq fspec (tex--quote-spec fspec))
   (if (not (string-match "\\([^ /\\]+\\) " format))
       (format-spec format fspec)
     (let* ((prefix (substring format 0 (match-beginning 0)))
@@ -2430,8 +2435,8 @@ Only applies the FSPEC to the args part of FORMAT."
            (prog1 (file-name-directory (expand-file-name file))
              (setq file (file-name-nondirectory file))))
          (root (file-name-sans-extension file))
-         (fspec (list (cons ?r (shell-quote-argument root))
-                      (cons ?f (shell-quote-argument file))))
+         (fspec (list (cons ?r root)
+                      (cons ?f file)))
          (default (tex-compile-default fspec)))
      (list default-directory
           (completing-read