emacs如何指定tmp file路径

org-mode
latex

#1

背景交代

我在Org-mode下执行公式预览时遇到
c:/Users/ADMINI~1/AppData/Local/Temp/orgtex26eeuz.dvi wasn't produced

同样的配置在mac上没有问题。

后来在shell中执行 latex c:/Users/ADMINI~1/AppData/Local/Temp/orgtex26eeuz.tex Fail

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `c:/Users/ADMINI'.
<to be read again>
                   \protect
<*> c:/Users/ADMINI~
                    1/AppData/Local/Temp/orgtexmAd9Gp.tex
(Press Enter to retry, or Control-Z to exit)

Window Emacs 在预览公式是在路径c:/Users/ADMINI~1/AppData/Local/Temp/下生成临时文件,
而这个临时文件路径中包含"~"符号, 不能被Latex命令正确识别导致错误

请问:

1: 如何设置临时文件的存放路径以便在路径中剔除"~"符号
2: 或者有没有其他方法让latex能够正确执行windows临时路径

谢谢!


#2

搜到方法了,自己回答一下 :neutral_face:
将临时目录设置到e盘的.emacs_temp路径下,最好不要带特殊的字符和中文字符

(if (memq system-type '(windows-nt cygwin))
  (setq temporary-file-directory "e:/.emacs_temp")
)

重启公式预览正常!


#3

windows-system不是这么用的,这只是描述了GUI Emacs的显示后端的变量,并不是描述系统类型的变量,正确的方式是用system-type

system-type的docstring

The value is a symbol indicating the type of operating system you are using.

Special values:
  gnu          compiled for a GNU Hurd system.
  gnu/linux    compiled for a GNU/Linux system.
  gnu/kfreebsd compiled for a GNU system with a FreeBSD kernel.
  darwin       compiled for Darwin (GNU-Darwin, macOS, ...).
  ms-dos       compiled as an MS-DOS application.
  windows-nt   compiled as a native W32 application.
  cygwin       compiled using the Cygwin library.
Anything else (in Emacs 26, the possibilities are: aix, berkeley-unix,
hpux, usg-unix-v) indicates some sort of Unix system.

判断windows

(memq system-type '(windows-nt cygwin ms-dos))


#4

好,谢谢指正