From c1705603c6b7ce79ce41459a3dd5e58afb976359 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 22 Jan 2013 18:19:06 +0100 Subject: [PATCH] Emacs: TeX support for spaces in file names. --- .emacs.d/modes.el | 11 +++++++---- .emacs.d/snippets/latex-mode/article.yasnippet | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.emacs.d/modes.el b/.emacs.d/modes.el index a4b2b09f..98b129a5 100644 --- a/.emacs.d/modes.el +++ b/.emacs.d/modes.el @@ -227,7 +227,7 @@ WARNING: the -shell-escape option is a potential security issue." (if (equal current-prefix-arg '(4)) (setq tex-my-shell-escape "-shell-escape") (setq tex-my-shell-escape "")) - (setq tex-my-compile-command (concat tex-my-compiler " " tex-my-shell-escape " " tex-my-compiler-options " " tex-my-startcommands " " buffer-file-name)) + (setq tex-my-compile-command (concat tex-my-compiler " " tex-my-shell-escape " " tex-my-compiler-options " " tex-my-startcommands " \"" buffer-file-name "\"")) ;; (message tex-my-compile-command) ;; Debug only. (save-buffer) (setq compilation-scroll-output t) @@ -278,11 +278,14 @@ your document embeds raster graphics." ) (defun tex-pdf-view () - "Call a PDF viewer for current buffer file." + "Call a PDF viewer for current buffer file. File name should be +properly escaped with double-quotes in case it has spaces." (interactive) (shell-command - (concat tex-my-viewer " " - (replace-regexp-in-string "\.tex$" "\.pdf &" (file-name-nondirectory buffer-file-name)) + (concat tex-my-viewer + " \"" + (replace-regexp-in-string "\.tex$" "\.pdf" (file-name-nondirectory buffer-file-name)) + "\" &" ) ) (delete-windows-on "*Async Shell Command*") diff --git a/.emacs.d/snippets/latex-mode/article.yasnippet b/.emacs.d/snippets/latex-mode/article.yasnippet index 9ef9a175..25f199fd 100644 --- a/.emacs.d/snippets/latex-mode/article.yasnippet +++ b/.emacs.d/snippets/latex-mode/article.yasnippet @@ -57,7 +57,7 @@ %% Graphics %% Load TikZ after xcolor. -% \usepackage[svgnames]{xcolor} +\usepackage[svgnames]{xcolor} % \usepackage{graphicx} % \usepackage{tikz}