yatex

changeset 303:13a62b7c8354 dev

(yatexpkg)Add default option for package completion.
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 06 May 2013 17:24:56 +0900
parents fa7a4a003f9e
children a57f4c74179a
files yatexpkg.el
diffstat 1 files changed, 21 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/yatexpkg.el	Tue Apr 02 22:40:10 2013 +0900
     1.2 +++ b/yatexpkg.el	Mon May 06 17:24:56 2013 +0900
     1.3 @@ -1,7 +1,7 @@
     1.4  ;;; yatexpkg.el --- YaTeX package manager
     1.5  ;;; 
     1.6  ;;; (c)2003-2013 by HIROSE, Yuuji [yuuji@yatex.org]
     1.7 -;;; Last modified Mon Apr  1 22:44:31 2013 on firestorm
     1.8 +;;; Last modified Mon May  6 17:20:43 2013 on firestorm
     1.9  ;;; $Id$
    1.10  
    1.11  ;;; Code:
    1.12 @@ -38,7 +38,9 @@
    1.13  			 "rotatebox" "scalebox" "resizebox" "reflectbox")
    1.14       		(option . YaTeX-package-graphics-driver-alist))
    1.15      ("color"	(section "textcolor" "colorbox" "pagecolor" "color")
    1.16 -     		(option . YaTeX-package-graphics-driver-alist))
    1.17 +     		(option . YaTeX-package-graphics-driver-alist)
    1.18 +		(default-option . "usenames,dvipsnames"))
    1.19 +    ("xcolor"	(same-as . "color"))
    1.20      ("ulem"	(section "uline" "uuline" "uwave")
    1.21  		(option ("normalem")))
    1.22      ("multicol"	(env "multicols")))
    1.23 @@ -55,7 +57,8 @@
    1.24  An good example is the value of YaTeX-package-alist-default.")
    1.25  
    1.26  (defvar YaTeX-package-graphics-driver-alist
    1.27 -  '(("dvips") ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo")
    1.28 +  '(("dvips") ("dvipsnames") ("usenames")
    1.29 +    ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo")
    1.30      ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin")
    1.31      ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex"))
    1.32    "Drivers alist of graphics/color stylefile's supporting deveces.
    1.33 @@ -91,13 +94,16 @@
    1.34        (setq list (cdr list)))
    1.35      pkglist))
    1.36  
    1.37 -(defun YaTeX-package-option-lookup (pkg)
    1.38 +(defun YaTeX-package-option-lookup (pkg &optional key)
    1.39    "Look up options for specified pkg and returne them in alist form.
    1.40 -Just only accocing against the alist of YaTeX-package-alist-*"
    1.41 -  (let ((l (cdr (assq 'option
    1.42 -		      (assoc pkg (append YaTeX-package-alist-private
    1.43 -					 YaTeX-package-alist-default))))))
    1.44 -    (if (symbolp l) (symbol-value l) l)))
    1.45 +Just only associng against the alist of YaTeX-package-alist-*"
    1.46 +  (let*((list (append YaTeX-package-alist-private YaTeX-package-alist-default))
    1.47 +	(l (cdr (assq (or key 'option) (assoc pkg list))))
    1.48 +	(recur (cdr (assq 'same-as (assoc pkg list)))))
    1.49 +    (cond
    1.50 +     (recur (YaTeX-package-option-lookup recur key))
    1.51 +     ((symbolp l) (symbol-value l))
    1.52 +     (t l))))
    1.53  
    1.54  (defvar YaTeX-package-resolved-list nil
    1.55    "List of macros whose package is confirmed to be loaded.")
    1.56 @@ -170,12 +176,15 @@
    1.57  			(YaTeX-package-option-lookup pkg))
    1.58  		  (if optlist
    1.59  		      (let ((minibuffer-completion-table optlist)
    1.60 -			    (delim ",") (w (car (car optlist))))
    1.61 +			    (delim ",") (w (car (car optlist)))
    1.62 +			    (dflt (YaTeX-package-option-lookup
    1.63 +				   pkg 'default-option)))
    1.64  			(setq option
    1.65  			      (read-from-minibuffer
    1.66  			       (format "Any option for {%s}?: " pkg)
    1.67 -			       (if (= (length optlist) 1)
    1.68 -				   (if YaTeX-emacs-19 (cons w 0) w))
    1.69 +			       (let ((v (or dflt
    1.70 +					    (and (= (length optlist) 1) w))))
    1.71 +				 (and v (if YaTeX-emacs-19 (cons v 0) v)))
    1.72  			       YaTeX-minibuffer-completion-map)
    1.73  			      option (if (string< "" option)
    1.74  					 (concat "[" option "]")