yatex
changeset 328:d972598d233b dev
Prefix-arg for YaTeX-preview runs default previewer without inquiry
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 13 Nov 2014 09:00:50 +0900 |
parents | 2bc5b59840d5 |
children | fdbc3b60a09d |
files | yatexprc.el |
diffstat | 1 files changed, 28 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/yatexprc.el Thu Nov 13 08:59:40 2014 +0900 1.2 +++ b/yatexprc.el Thu Nov 13 09:00:50 2014 +0900 1.3 @@ -1,7 +1,7 @@ 1.4 ;;; yatexprc.el --- YaTeX process handler 1.5 ;;; 1.6 ;;; (c)1993-2013 by HIROSE Yuuji.[yuuji@yatex.org] 1.7 -;;; Last modified Wed Nov 5 09:07:25 2014 on firestorm 1.8 +;;; Last modified Thu Nov 13 08:49:02 2014 on firestorm 1.9 ;;; $Id$ 1.10 1.11 ;;; Code: 1.12 @@ -602,12 +602,9 @@ 1.13 (defvar YaTeX-preview-file-history nil 1.14 "Holds minibuffer history of file to preview.") 1.15 (put 'YaTeX-preview-file-history 'no-default t) 1.16 -(defun YaTeX-preview (preview-command preview-file) 1.17 - "Execute xdvi (or other) to tex-preview." 1.18 - (interactive 1.19 - (let* ((command (read-string-with-history 1.20 - "Preview command: " 1.21 - (YaTeX-replace-format 1.22 +(defun YaTeX-preview-default-previewer () 1.23 + "Return default previewer for this document" 1.24 + (YaTeX-replace-format 1.25 (or (YaTeX-get-builtin "PREVIEW") 1.26 (if (eq (get 'dvi2-command 'format) 'pdf) 1.27 tex-pdfview-command 1.28 @@ -615,17 +612,33 @@ 1.29 "p" (format (cond 1.30 (YaTeX-dos "-y:%s") 1.31 (t "-paper %s")) 1.32 - (YaTeX-get-paper-type))) 1.33 - 'YaTeX-preview-command-history)) 1.34 - (file (read-string-with-history 1.35 - "Preview file: " 1.36 - (if (get 'dvi2-command 'region) 1.37 + (YaTeX-get-paper-type)))) 1.38 +(defun YaTeX-preview-default-main (command) 1.39 + "Return default preview target file" 1.40 + (if (get 'dvi2-command 'region) 1.41 (substring YaTeX-texput-file 1.42 0 (rindex YaTeX-texput-file ?.)) 1.43 - (YaTeX-get-preview-file-name command)) 1.44 - 'YaTeX-preview-file-history))) 1.45 + (YaTeX-get-preview-file-name command))) 1.46 +(defun YaTeX-preview (preview-command preview-file &optional as-default) 1.47 + "Execute xdvi (or other) to tex-preview." 1.48 + (interactive 1.49 + (let* ((previewer (YaTeX-preview-default-previewer)) 1.50 + (as-default current-prefix-arg) 1.51 + (command (if as-default 1.52 + previewer 1.53 + (read-string-with-history 1.54 + "Preview command: " 1.55 + previewer 1.56 + 'YaTeX-preview-command-history))) 1.57 + (target (YaTeX-preview-default-main command)) 1.58 + (file (if as-default 1.59 + target 1.60 + (read-string-with-history 1.61 + "Preview file: " 1.62 + target 1.63 + 'YaTeX-preview-file-history)))) 1.64 (list command file))) 1.65 - (setq dvi2-command preview-command) ;`dvi2command' is buffer local 1.66 + (setq dvi2-command preview-command) ;`dvi2-command' is buffer local 1.67 (save-excursion 1.68 (YaTeX-visit-main t) 1.69 (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))