1376 |
(throw 'preview-filter-specs nil) |
(throw 'preview-filter-specs nil) |
1377 |
(preview-filter-specs-1 args)))) |
(preview-filter-specs-1 args)))) |
1378 |
|
|
1379 |
(defvar preview-icondir (expand-file-name "images" |
(defvar preview-datadir (file-name-directory load-file-name) |
1380 |
(file-name-directory load-file-name)) |
"The directory relative to which package data may be found. |
1381 |
"The directory relative to which images may be found. |
This should be hardwired into the startup file containing the |
1382 |
This should be hardwired into the startup file |
autoloads for preview-latex.") |
|
containing the autoloads for preview-latex.") |
|
1383 |
|
|
1384 |
(put 'preview-filter-specs :file |
(put 'preview-filter-specs :file |
1385 |
#'(lambda (keyword value &rest args) |
#'(lambda (keyword value &rest args) |
1386 |
`(:file ,(expand-file-name value preview-icondir) |
`(:file ,(expand-file-name value (expand-file-name "images" |
1387 |
|
preview-datadir)) |
1388 |
,@(preview-filter-specs-1 args)))) |
,@(preview-filter-specs-1 args)))) |
1389 |
|
|
1390 |
(defun preview-ascent-from-bb (bb) |
(defun preview-ascent-from-bb (bb) |
1989 |
not use in advice." |
not use in advice." |
1990 |
;; The following two lines are bug workaround for Emacs < 22.1. |
;; The following two lines are bug workaround for Emacs < 22.1. |
1991 |
(if (markerp begin) |
(if (markerp begin) |
1992 |
(setq begin (marker-position (marker)))) |
(setq begin (marker-position begin))) |
1993 |
(or (car (get-char-property begin 'preview-counters)) |
(or (car (get-char-property begin 'preview-counters)) |
1994 |
(cdr (get-char-property (max (point-min) |
(cdr (get-char-property (max (point-min) |
1995 |
(1- begin)) |
(1- begin)) |
2294 |
(preview-active-contents ,ov)]) |
(preview-active-contents ,ov)]) |
2295 |
ev)) |
ev)) |
2296 |
|
|
2297 |
|
(defvar preview-TeX-style-dir) |
2298 |
|
|
2299 |
|
(defun preview-set-texinputs (&optional remove) |
2300 |
|
"Add `preview-TeX-style-dir' into `TEXINPUT' variables. |
2301 |
|
With prefix argument REMOVE, remove it again." |
2302 |
|
(interactive "P") |
2303 |
|
(if remove |
2304 |
|
(let ((case-fold-search nil) |
2305 |
|
(pattern (concat "\\`\\(TEXINPUTS[^=]*\\)=\\(.*\\)" |
2306 |
|
(regexp-quote preview-TeX-style-dir)))) |
2307 |
|
(dolist (env (copy-sequence process-environment)) |
2308 |
|
(if (string-match pattern env) |
2309 |
|
(setenv (match-string 1 env) |
2310 |
|
(and (or (< (match-beginning 2) (match-end 2)) |
2311 |
|
(< (match-end 0) (length env))) |
2312 |
|
(concat (match-string 2 env) |
2313 |
|
(substring env (match-end 0)))))))) |
2314 |
|
(let ((case-fold-search nil) |
2315 |
|
(pattern (regexp-quote preview-TeX-style-dir))) |
2316 |
|
(dolist (env (cons "TEXINPUTS=" (copy-sequence process-environment))) |
2317 |
|
(if (string-match "\\`(TEXINPUTS[^=]*\\)=" env) |
2318 |
|
(unless (string-match pattern env) |
2319 |
|
(setenv (match-string 1 env) |
2320 |
|
(concat preview-TeX-style-dir |
2321 |
|
(substring env (match-end 0)))))))))) |
2322 |
|
|
2323 |
|
(defcustom preview-TeX-style-dir nil |
2324 |
|
"This variable contains the location of uninstalled TeX styles. |
2325 |
|
This has to be followed by the character with which kpathsea |
2326 |
|
separates path components, either `:' on Unix-like systems, |
2327 |
|
or `;' on Windows-like systems. |
2328 |
|
|
2329 |
|
If this is non-nil, the `TEXINPUT' environment type variables will |
2330 |
|
get this prepended at load time calling \\[preview-set-texinputs] |
2331 |
|
to reflect this. You can permanently install the style files |
2332 |
|
using \\[preview-install-styles]. |
2333 |
|
|
2334 |
|
Don't set this variable other than with customize so that its |
2335 |
|
changes get properly reflected in the environment." |
2336 |
|
:group 'preview-latex |
2337 |
|
:set (lambda (var value) |
2338 |
|
(and (boundp var) |
2339 |
|
(symbol-value var) |
2340 |
|
(preview-set-texinputs t)) |
2341 |
|
(set var value) |
2342 |
|
(and (symbol-value var) |
2343 |
|
(preview-set-texinputs))) |
2344 |
|
:type '(choice (const :tag "Installed" nil) |
2345 |
|
(string :tag "Directory followed by kpathsea delimiter"))) |
2346 |
|
|
2347 |
|
(defun preview-install-styles (dir &optional force-overwrite |
2348 |
|
force-save) |
2349 |
|
"Installs the TeX style files into a permanent location. |
2350 |
|
This must be in the TeX search path. If FORCE-OVERWRITE is greater |
2351 |
|
than 1, files will get overwritten without query, if it is less |
2352 |
|
than 1 or nil, the operation will fail. The default of 1 for interactive |
2353 |
|
use will query. |
2354 |
|
|
2355 |
|
Similarly FORCE-SAVE can be used for saving |
2356 |
|
`preview-TeX-style-dir' to record the fact that the uninstalled |
2357 |
|
files are no longer needed in the search path." |
2358 |
|
(interactive "DPermanent location for preview TeX styles |
2359 |
|
pp") |
2360 |
|
(unless preview-TeX-style-dir |
2361 |
|
(error "Styles are already installed")) |
2362 |
|
(dolist (file (directory-files |
2363 |
|
(substring preview-TeX-style-dir 0 -1) |
2364 |
|
t "\\.\\(sty\\|def\\|cfg\\)\\'")) |
2365 |
|
(copy-file file dir (cond ((eq force-overwrite 1) 1) |
2366 |
|
((numberp force-overwrite) |
2367 |
|
(> force-overwrite 1)) |
2368 |
|
(t force-overwrite)))) |
2369 |
|
(if (cond ((eq force-save 1) |
2370 |
|
(y-or-n-p "Stop using non-installed styles permanently ")) |
2371 |
|
((numberp force-save) |
2372 |
|
(> force-save 1)) |
2373 |
|
(t force-save)) |
2374 |
|
(customize-save-variable 'preview-TeX-style-dir nil) |
2375 |
|
(customize-set-variable 'preview-TeX-style-dir nil))) |
2376 |
|
|
2377 |
;;;###autoload |
;;;###autoload |
2378 |
(defun LaTeX-preview-setup () |
(defun LaTeX-preview-setup () |
2379 |
"Hook function for embedding the preview package into AUCTeX. |
"Hook function for embedding the preview package into AUCTeX. |