Function: preview-set-texinputs

preview-set-texinputs is an interactive and byte-compiled function defined in preview.el.

Signature

(preview-set-texinputs &optional REMOVE)

Documentation

Add preview-TeX-style-dir into TEXINPUTS variables.

With prefix argument REMOVE, remove it again.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/preview.el
(defun preview-set-texinputs (&optional remove)
  "Add `preview-TeX-style-dir' into `TEXINPUTS' variables.
With prefix argument REMOVE, remove it again."
  (interactive "P")
  (let ((case-fold-search nil)
        (preview-TeX-style-dir (preview-TeX-style-cooked))
        pattern)
    (if remove
        (progn
          (setq pattern (concat "\\`\\(TEXINPUTS[^=]*\\)=\\(.*\\)"
                                (regexp-quote preview-TeX-style-dir)))
          (dolist (env (copy-sequence process-environment))
            (if (string-match pattern env)
                (setenv (match-string 1 env)
                        (and (or (< (match-beginning 2) (match-end 2))
                                 (< (match-end 0) (length env)))
                             (concat (match-string 2 env)
                                     (substring env (match-end 0))))))))
      (setq pattern (regexp-quote preview-TeX-style-dir))
      (dolist (env (cons "TEXINPUTS=" (copy-sequence process-environment)))
        (if (string-match "\\`\\(TEXINPUTS[^=]*\\)=" env)
            (unless (save-match-data (string-match pattern env))
              (setenv (match-string 1 env)
                      (concat preview-TeX-style-dir
                              (substring env (match-end 0))))))))))