yatex
changeset 356:af0bd0f86b27 dev
Now YaTeX-package-auto-usepackage can insert aline full-automaticaly
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Mon, 22 Dec 2014 11:14:47 +0900 |
parents | 6c67a826f266 |
children | 4ea63809a0ca |
files | yatexpkg.el |
diffstat | 1 files changed, 27 insertions(+), 18 deletions(-) [+] |
line diff
1.1 --- a/yatexpkg.el Mon Dec 22 10:02:49 2014 +0900 1.2 +++ b/yatexpkg.el Mon Dec 22 11:14:47 2014 +0900 1.3 @@ -1,7 +1,7 @@ 1.4 ;;; yatexpkg.el --- YaTeX package manager 1.5 ;;; 1.6 ;;; (c)2003-2014 by HIROSE, Yuuji [yuuji@yatex.org] 1.7 -;;; Last modified Sun Dec 21 14:16:14 2014 on firestorm 1.8 +;;; Last modified Mon Dec 22 11:12:19 2014 on firestorm 1.9 ;;; $Id$ 1.10 1.11 ;;; Code: 1.12 @@ -118,9 +118,12 @@ 1.13 (defvar YaTeX-package-resolved-list nil 1.14 "List of macros whose package is confirmed to be loaded.") 1.15 1.16 -(defun YaTeX-package-auto-usepackage (macro type) 1.17 +(defun YaTeX-package-auto-usepackage (macro type &optional autopkg autoopt) 1.18 "(Semi)Automatically add the \\usepackage line to main-file. 1.19 -Search the usepackage for MACRO of the TYPE." 1.20 +Search the usepackage for MACRO of the TYPE. 1.21 +Optional second and third argument AUTOPKG, AUTOOPT are selected 1.22 +without query. Thus those two argument (Full)automatically add 1.23 +a \\usepackage line." 1.24 (let ((cb (current-buffer)) 1.25 (wc (current-window-configuration)) 1.26 (usepackage (concat YaTeX-ec "usepackage")) 1.27 @@ -171,18 +174,22 @@ 1.28 ;;corresponding \usepackage found 1.29 (funcall register) 1.30 ;; not found, insert it. 1.31 - (if (y-or-n-p 1.32 - (format "`%s' requires package. Put \\usepackage now?" macro)) 1.33 + (if (or 1.34 + autopkg 1.35 + (y-or-n-p 1.36 + (format "`%s' requires package. Put \\usepackage now?" 1.37 + macro))) 1.38 (progn 1.39 (require 'yatexadd) 1.40 (setq pkg 1.41 - (completing-read 1.42 - "Load which package?(TAB for list): " 1.43 - pkglist nil nil 1.44 - ;;initial input 1.45 - (if (= (length pkglist) 1) 1.46 - (let ((w (car (car pkglist)))) 1.47 - (if YaTeX-emacs-19 (cons w 0) w)))) 1.48 + (or autopkg 1.49 + (completing-read 1.50 + "Load which package?(TAB for list): " 1.51 + pkglist nil nil 1.52 + ;;initial input 1.53 + (if (= (length pkglist) 1) 1.54 + (let ((w (car (car pkglist)))) 1.55 + (if YaTeX-emacs-19 (cons w 0) w))))) 1.56 optlist 1.57 (YaTeX-package-option-lookup pkg)) 1.58 (if optlist 1.59 @@ -191,12 +198,14 @@ 1.60 (dflt (YaTeX-package-option-lookup 1.61 pkg 'default-option))) 1.62 (setq option 1.63 - (read-from-minibuffer 1.64 - (format "Any option for {%s}?: " pkg) 1.65 - (let ((v (or dflt 1.66 - (and (= (length optlist) 1) w)))) 1.67 - (and v (if YaTeX-emacs-19 (cons v 0) v))) 1.68 - YaTeX-minibuffer-completion-map) 1.69 + (or 1.70 + autoopt 1.71 + (read-from-minibuffer 1.72 + (format "Any option for {%s}?: " pkg) 1.73 + (let ((v (or dflt 1.74 + (and (= (length optlist) 1) w)))) 1.75 + (and v (if YaTeX-emacs-19 (cons v 0) v))) 1.76 + YaTeX-minibuffer-completion-map)) 1.77 option (if (string< "" option) 1.78 (concat "[" option "]") 1.79 ""))))