谁能帮我连接双引号:
在这个例子中,我正在编写一个在 Windows 操作系统上与 Emacs 一起使用的函数。带空格的文件名需要用双引号括起来。
缓冲区文件名是: c:/Documents and Settings/All Users/Desktop/foo.tex
我正在尝试使用:
(setq pdf-file
(concat "\"" (car (split-string (buffer-file-name) "\\.tex")) ".pdf" "\""))
当我打电话(start-process "display" nil c:/SumatraPDF.exe pdf-file)
时,pdf查看器会尝试打开它:
c:\Documents and Settings\All Users\Desktop"c:\Documents and Settings\All Users\Desktop\foo.pdf"
编辑:这是我试图修改的功能。正如我在下面的回答中所述,该错误是由于我无意中将文件名双引号引起的 - 即,start-process
将变量视为双引号,因此我永远不需要连接另一组双引号。
(defun latexmk ()
".latexmkrc contains the following entries:
$pdflatex = 'pdflatex -file-line-error -synctex=1 %O %S';
$pdf_mode = 1;
$recorder = 0;
$clean_ext = 'synctex.gz synctex.gz(busy) aux fdb_latexmk log';"
(interactive)
(setq tex-file (file-name-nondirectory buffer-file-name))
(setq base-file (car (split-string (file-name-nondirectory buffer-file-name) "\\.tex")))
(setq pdf-file (concat base-file ".pdf"))
(setq line (format "%d" (line-number-at-pos)))
(setq sumatra "C:/SumatraPDF/SumatraPDF.exe")
(setq tex-output (concat "*" (file-name-nondirectory buffer-file-name) "*") )
(setq latexmk "c:/texlive/2013/bin/win32/latexmk.exe")
(setq latexmkrc "c:/Documents and Settings/Administrator/Application Data/.emacs.d/.latexmkrc")
(if (buffer-modified-p)
(save-buffer))
(delete-other-windows)
(set-window-buffer (split-window-horizontally) (get-buffer-create tex-output))
(with-current-buffer tex-output (erase-buffer))
(start-process "tskill" nil "c:/WINDOWS/system32/tskill.exe" "SumatraPDF")
(set-process-sentinel
(start-process "deep-clean" nil latexmk "-C" "-r" latexmkrc tex-file)
(lambda (p e) (when (= 0 (process-exit-status p))
(set-process-sentinel
(start-process "compile" tex-output latexmk "-r" latexmkrc tex-file)
(lambda (p e) (when (= 0 (process-exit-status p))
(set-process-sentinel
(start-process "displayline" nil sumatra "-forward-search" tex-file line pdf-file)
(lambda (p e) (when (= 0 (process-exit-status p))
(start-process "clean" nil latexmk "-c" "-r" latexmkrc tex-file)
(switch-to-buffer (get-file-buffer tex-file))
(if (get-buffer-process (get-buffer tex-output))
(process-kill-without-query (get-buffer-process (get-buffer tex-output))))
(kill-buffer tex-output)
(delete-other-windows)))))))))))