diff yatexpkg.el @ 80:9b4354af748c

Too many changes from 1.72. See yatex.new. (Japanese)
author yuuji
date Sun, 24 Dec 2006 06:16:52 +0000
parents 0734be649cb8
children 8772bd5d1f02
line wrap: on
line diff
--- a/yatexpkg.el	Thu Dec 25 04:10:32 2003 +0000
+++ b/yatexpkg.el	Sun Dec 24 06:16:52 2006 +0000
@@ -1,10 +1,13 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX package manager
 ;;; yatexpkg.el
-;;; (c)2003 by HIROSE, Yuuji [yuuji@yatex.org]
-;;; Last modified Thu Aug 28 18:24:33 2003 on firestorm
+;;; (c)2003-2006 by HIROSE, Yuuji [yuuji@yatex.org]
+;;; Last modified Sun Dec 24 15:13:29 2006 on firestorm
 ;;; $Id$
 
+(defvar YaTeX-package-ams-envs
+  (mapcar 'car YaTeX-ams-env-table))
+
 (defvar YaTeX-package-alist-default
   '(("version"	(env "comment")		;by tsuchiya@pine.kuee.kyoto-u.ac.jp
      		(section "includeversion" "excludeversion"))
@@ -14,6 +17,7 @@
     ("url"	(section "url"))	;by fujieda@jaist.ac.jp
 
     ("fancybox"	(section "shadowbox" "doublebox" "ovalbox" "Ovalbox"))
+    ("slashbox"	(section "slashbox" "backslashbox"))
     ("pifont"	(section "ding"))
     ("longtable" (env "longtable"))
     ("ascmac"	(env "screen" "boxnote" "shadebox" "itembox")
@@ -21,10 +25,20 @@
      		(section "keytop") ("mask") ("maskbox"))
     ("bm"	(section "bm"))		;by aoyama@le.chiba-u.ac.jp
 
-    ("graphicx"	(section "includegraphics"))
     ("alltt"	(env "alltt"))
     ("misc"	(section "verbfile" "listing"))
-    ("eclbkbox"	(env "breakbox")))
+    ("eclbkbox"	(env "breakbox"))
+    ("supertabular" (env "supertabular"))
+    ("amsmath"	(env . YaTeX-package-ams-envs)
+     		(section "tag" "tag*"))
+    ("graphicx" (section "includegraphics"
+			 "rotatebox" "scalebox" "resizebox" "reflectbox")
+     		(option . YaTeX-package-graphics-driver-alist))
+    ("color"	(section "textcolor" "colorbox" "pagecolor" "color")
+     		(option . YaTeX-package-graphics-driver-alist))
+    ("ulem"	(section "uline" "uuline" "uwave")
+		(option ("normalem")))
+    ("multicol"	(env "multicols")))
   "Default package vs. macro list.
 Alists contains '(PACKAGENAME . MACROLIST)
 PACKAGENAME     Basename of package(String).
@@ -32,8 +46,21 @@
 TYPE	One of 'env, 'section or 'maketitle according to completion-type
 MACROS	List of macros
 
+If TYPE is 'option, its cdr is alist of completion candidates for that
+package.  Its cdr can be a symbol whose value is alist.
+
 An good example is the value of YaTeX-package-alist-default.")
 
+(defvar YaTeX-package-graphics-driver-alist
+  '(("dvips") ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo")
+    ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin")
+    ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex"))
+  "Drivers alist of graphics/color stylefile's supporting deveces.
+This list is taken from
+%% graphics.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
+%%              Copyright (C) 1995 1996 1997 1998 David Carlisle
+as of 2004/1/19.  Thanks.")
+
 (defvar YaTeX-package-alist-private nil
   "*User defined package vs. macro list. See also YaTeX-package-alist-default")
 
@@ -42,23 +69,33 @@
 Optional second argument TYPE limits the macro type.
 TYPE is a symbol, one of 'env, 'section, 'maketitle."
   (let ((list (append YaTeX-package-alist-private YaTeX-package-alist-default))
-	element x pkg pkglist r)
+	element x val pkg pkglist r)
     (while list
       (setq element (car list)
 	    pkg (car element)
 	    element (cdr element))
       (if (setq r (catch 'found
 		    (while element
-		      (setq x (car element))
-		      (and (YaTeX-member macro (cdr x))
-			   (or (null type)
+		      (setq x (car element)
+			    val (cdr x))
+		      (if (symbolp val) (setq val (symbol-value val)))
+		      (and (or (null type)
 			       (eq type (car x)))
+			   (YaTeX-member macro val)
 			   (throw 'found (car x)))	;car x is type
 		      (setq element (cdr element)))))
 	  (setq pkglist (cons (cons pkg r) pkglist)))
       (setq list (cdr list)))
     pkglist))
 
+(defun YaTeX-package-option-lookup (pkg)
+  "Look up options for specified pkg and returne them in alist form.
+Just only accocing against the alist of YaTeX-package-alist-*"
+  (let ((l (cdr (assq 'option
+		      (assoc pkg (append YaTeX-package-alist-private
+					 YaTeX-package-alist-default))))))
+    (if (symbolp l) (symbol-value l) l)))
+
 (defvar YaTeX-package-resolved-list nil
   "List of macros whose package is confirmed to be loaded.")
 
@@ -68,7 +105,7 @@
   (let ((cb (current-buffer))
 	(wc (current-window-configuration))
 	(usepackage (concat YaTeX-ec "usepackage"))
-	(pkglist (YaTeX-package-lookup macro))
+	(pkglist (YaTeX-package-lookup macro type))
 	(usepkgrx (concat
 		   YaTeX-ec-regexp
 		   "\\(usepackage\\|include\\)\\b"))
@@ -76,7 +113,7 @@
 		     (set (make-local-variable 'YaTeX-package-resolved-list)
 			  (cons macro YaTeX-package-resolved-list))))
 	(begdoc (concat YaTeX-ec "begin{document}"))
-	pb pkg mb0)
+	pb pkg optlist (option "") mb0 uspkgargs)
     (if (or (YaTeX-member macro YaTeX-package-resolved-list)
 	    (null pkglist))
 	nil				;nothing to do
@@ -89,14 +126,25 @@
 		(goto-char (point-min))
 		(YaTeX-search-active-forward	;if search fails, goto eob
 		 begdoc YaTeX-comment-prefix nil 1)
-		(while (YaTeX-re-search-active-backward
-			usepkgrx YaTeX-comment-prefix nil t)
+		(while ;(YaTeX-re-search-active-backward
+			;usepkgrx YaTeX-comment-prefix nil t)
+		    ;;allow commented out \usepackages 2004/3/16
+		    (re-search-backward usepkgrx nil t)
 		  (setq mb0 (match-beginning 0))
 		  (skip-chars-forward "^{")
-		  (forward-char 1)
+		  (setq uspkgargs (YaTeX-buffer-substring
+				   (point)
+				   (progn
+				     ;;(forward-list 1) is more precise,
+				     ;; but higher risk.
+				     (skip-chars-forward "^}\n")(point))))
 		  (let ((pl pkglist))
 		    (while pl		;(car pl)'s car is package, cdr is type
-		      (if (looking-at (regexp-quote (car (car pl))))
+		      (if (string-match
+			   (concat "[{,]\\s *"
+				   (regexp-quote (car (car pl)))
+				   "\\>")
+			   uspkgargs)
 			  (throw 'found t))
 		      (setq pl (cdr pl)))
 		    (goto-char mb0))))
@@ -106,6 +154,7 @@
 	    (if (y-or-n-p
 		 (format "`%s' requires package. Put \\usepackage now?" macro))
 		(progn
+		  (require 'yatexadd)
 		  (setq pkg
 			(completing-read
 			 "Load which package?(TAB for list): "
@@ -113,7 +162,21 @@
 			 ;;initial input
 			 (if (= (length pkglist) 1)
 			     (let ((w (car (car pkglist))))
-			       (if YaTeX-emacs-19 (cons w 0) w)))))
+			       (if YaTeX-emacs-19 (cons w 0) w))))
+			optlist
+			(YaTeX-package-option-lookup pkg))
+		  (if optlist
+		      (let ((minibuffer-completion-table optlist)
+			    (delim ",") (w (car (car optlist))))
+			(setq option
+			      (read-from-minibuffer
+			       (format "Any option for {%s}?: " pkg)
+			       (if (= (length optlist) 1)
+				   (if YaTeX-emacs-19 (cons w 0) w))
+			       YaTeX-minibuffer-completion-map)
+			      option (if (string< "" option)
+					 (concat "[" option "]")
+				       ""))))
 		  (set-buffer pb)
 		  (goto-char (point-min))
 		  (if (YaTeX-re-search-active-forward
@@ -126,8 +189,8 @@
 		      (goto-char (match-beginning 0)))
 		  (insert
 		   usepackage
-		   (format "{%s}\t%% required for `\\%s' (yatex added)\n"
-			   pkg macro))
+		   (format "%s{%s}\t%% required for `\\%s' (yatex added)\n"
+			   option pkg macro))
 		  (funcall register))
 	      (message "Don't forget to put \\usepackage{%s} yourself later"
 		       (car (car pkglist)))) ;doing car car is negligence...

yatex.org