2011-12-01 67 views
0

我使用preview-latex在Emacs窗口中顯示LaTeX結果。我使用預覽點在代碼和輸出之間來回切換。但是,如果我不在Latex代碼中(錯誤地,也許我錯過了我的預期行),那麼預覽嘗試編譯所有內容,調出「其他」窗口並失敗。所有這些過程都會降低速度。Emacs preview-latex

我的問題是如何禁用此編譯(嘗試)?如果不能切換,則預覽不應該執行任何操作。有沒有一個預覽膠乳的設置?或者,也許我可以重寫一個函數?

error in process sentinel: LaTeX found no preview images 

感謝,

回答

1

真正的工作是由preview-region這樣做,我們可以建議,要在某些情況下一個空操作。以下方法並不完美,因爲我認爲沒有辦法事先知道要預覽的內容 - 用戶可以指定要預覽的任何環境或宏。例如,如果您只關心數學預覽,那麼您可以刪除previewable-environments件。

(defvar previewable-environments 
    "List of environments that should be previewed." 
    '("tabular" "tabular*" "tikzpicture" "...")) 

(defadvice preview-region (around preview-at-point-no-long-pauses activate) 
    "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview." 
    (when (or (not (eq this-command 'preview-at-point)) 
      (TeX-active-mark) 
      (texmathp) 
      (member (LaTeX-current-environment) previewable-environments)) 
    ad-do-it)) 
0

上公認的答案的變化:該代碼將引發預覽切換,如果它是如下方程,但我也想整個文件預覽的時候我沒有任何的數學片段。代碼是

(defvar previewable-environments 
    "List of environments that should be previewed." 
    '("tabular" "tabular*" "tikzpicture" "...")) 

(defadvice preview-region (around preview-at-point-no-long-pauses activate) 
    "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview." 
    (message "preview-region") 
    (if (or (not (eq this-command 'preview-at-point)) 
      (TeX-active-mark) 
      (texmathp) 
      (member (LaTeX-current-environment) previewable-environments)) 
    ad-do-it 
    (preview-section) 
    ) 
)