preview-latex在GS9.00下报错

在emacs下其实很久不用preview-latex了,一直觉得没有必要——但是忽然用一下的时候发现不能用还是很郁闷的。基本上报错是这样的:

"GSWIN32C.EXE" "-dOutputFile=(_region_.prv/tmp5723kvc/pr1-1.png)" "-q""-dSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4""-dGraphicsAlphaBits=4" "-sDEVICE=png16m" "-r70.4906x70.6156"
GS>{DELAYSAFER{.setsafe}if}stopped pop/.preview-BPcurrentpagedevice/BeginPage get dup null eq{pop{pop}bind}ifdef<>setpagedevice/preview-do{[count 3 roll save]3 1 roll dup length 0 eq{pop}{setpagedevice}{ifelse .runandhide}stopped{handleerror quit}if aload pop restore}bind def[(_region_.prv/tmp3712kvc/preview.dsc)(r)file]aload exch dup 0 setfileposition 520()/SubFileDecode filter cvx .runandhide aload pop dup dup 623 setfileposition 50()/SubFileDecode filter cvx<<>>preview-do
Error: /invalidfileaccess in --file--

查了一通后来发现有人遇到这个问题之后把GS降级到8.71以下就好了。说明GS在近来做了一些改动。左看右看看到了-dSAFER这个参数——这个参数本意是要加强权限检查防止gs自动打开系统文件权限——但和权限相关的也只有它了。试着在命令行下重新跑着两个命令(用gswin32会容易些,否则后面这个长命令贴都贴不进去),居然跑通了。又大致查了查,貌似可能是一个BUG,不过我升级到了最新的9.02也没有解决这个问题。

既然如此,到site-lisp/auctex/preview.elc(最好还是用.el重新编译一下) 下面找到
(defcustom preview-gs-options '("-q" "-dSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4")
把dSAFER一项干掉就是了。虽然这似乎是一个“漏洞”,不过就自己跑跑preview来看,应该没太大风险。

一个更为稳妥的办法是在.emacs里面加上 ‘(preview-gs-options (quote (“-q” “-dNOPAUSE” “-DNOPLATFONTS” “-dPrinted” “-dTextAlphaBits=4” “-dGraphicsAlphaBits=4”))),就好了

One thought on “preview-latex在GS9.00下报错

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.