Mercurial > hgrepos > hgweb.cgi > yatex
comparison yatexadd.el @ 208:33c8875f52f9 yatex-1.75
Merged changes to 1.75
author | yuuji@gentei.org |
---|---|
date | Thu, 12 Jan 2012 12:26:35 +0900 |
parents | 6e959a05ae19 |
children | ad4e0a008972 |
comparison
equal
deleted
inserted
replaced
96:127a36f4cd6a | 208:33c8875f52f9 |
---|---|
1 ;;; -*- Emacs-Lisp -*- | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; YaTeX add-in functions. | 2 ;;; YaTeX add-in functions. |
3 ;;; yatexadd.el rev.18 | 3 ;;; yatexadd.el rev.19 |
4 ;;; (c)1991-2006 by HIROSE Yuuji.[yuuji@yatex.org] | 4 ;;; (c)1991-2011 by HIROSE Yuuji.[yuuji@yatex.org] |
5 ;;; Last modified Fri Sep 21 11:44:42 2007 on firestorm | 5 ;;; Last modified Mon Mar 7 12:12:11 2011 on firestorm |
6 ;;; $Id$ | 6 ;;; $Id$ |
7 | 7 |
8 ;;; | 8 ;;; |
9 ;;Sample functions for LaTeX environment. | 9 ;;Sample functions for LaTeX environment. |
10 ;;; | 10 ;;; |
196 ;; (YaTeX:makebox))) | 196 ;; (YaTeX:makebox))) |
197 (fset 'YaTeX:framebox 'YaTeX:makebox) | 197 (fset 'YaTeX:framebox 'YaTeX:makebox) |
198 | 198 |
199 (defun YaTeX:parbox () | 199 (defun YaTeX:parbox () |
200 (YaTeX:read-position "tbc")) | 200 (YaTeX:read-position "tbc")) |
201 | 201 (defun YaTeX::parbox (argp) |
202 (defun YaTeX:dashbox () | 202 (cond |
203 ((= argp 1) (read-string "Width: ")) | |
204 ((= argp 2) (read-string "Text: ")))) | |
205 | |
206 (defun YaTeX::dashbox () | |
203 (concat "{" (read-string "Dash dimension: ") "}" | 207 (concat "{" (read-string "Dash dimension: ") "}" |
204 (YaTeX:read-coordinates "Dimension"))) | 208 (YaTeX:read-coordinates "Dimension"))) |
205 | 209 |
206 (defun YaTeX:savebox (argp) | 210 (defun YaTeX::savebox (argp) |
207 (cond | 211 (cond |
208 ((= argp 1) (read-string "Saved into name: " "\\")) | 212 ((= argp 1) (read-string "Saved into name: " "\\")) |
209 ((= argp 2) (read-string "Text: ")))) | 213 ((= argp 2) (read-string "Text: ")))) |
210 | 214 |
211 (defvar YaTeX-minibuffer-quick-map nil) | 215 (defvar YaTeX-minibuffer-quick-map nil) |
736 '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) | 740 '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2) |
737 ("\\\\label{\\([^}]+\\)}" . 1)) | 741 ("\\\\label{\\([^}]+\\)}" . 1)) |
738 "Alist of labeling regexp vs. its group number points to label string. | 742 "Alist of labeling regexp vs. its group number points to label string. |
739 This alist is used in \\ref's argument's completion.") | 743 This alist is used in \\ref's argument's completion.") |
740 (defvar YaTeX::ref-labeling-regexp-alist-private nil | 744 (defvar YaTeX::ref-labeling-regexp-alist-private nil |
741 "*Private extesion to YaTeX::ref-labeling-regexp-alist. | 745 "*Private extension to YaTeX::ref-labeling-regexp-alist. |
742 See the documetation of YaTeX::ref-labeling-regexp-alist.") | 746 See the documetation of YaTeX::ref-labeling-regexp-alist.") |
743 (defvar YaTeX::ref-labeling-regexp-alist | 747 (defvar YaTeX::ref-labeling-regexp-alist |
744 (append YaTeX::ref-labeling-regexp-alist-default | 748 (append YaTeX::ref-labeling-regexp-alist-default |
745 YaTeX::ref-labeling-regexp-alist-private)) | 749 YaTeX::ref-labeling-regexp-alist-private)) |
746 (defvar YaTeX::ref-labeling-regexp | 750 (defvar YaTeX::ref-labeling-regexp |
1113 buf (nth (- lnum line 1) point-list)))) | 1117 buf (nth (- lnum line 1) point-list)))) |
1114 ))) | 1118 ))) |
1115 (bury-buffer YaTeX-label-buffer))) | 1119 (bury-buffer YaTeX-label-buffer))) |
1116 label))))) | 1120 label))))) |
1117 | 1121 |
1122 (defun YaTeX::label-rename-refs (old new &optional def ref) | |
1123 "Rename reference tag from OLD to NEW. | |
1124 Optional arguments DEF and REF specify defining command and | |
1125 referring command respectively. | |
1126 --------------------------------------------------------- | |
1127 CONTROL KEYS - キーの説明 | |
1128 y Replace 置換する | |
1129 n Do not replace 置換しない | |
1130 ! Replace All w/o query 残る全部を確認なしで置換 | |
1131 r Enter Recursive-edit 再帰編集モードへ | |
1132 q Quit from replacing ここまでで置換をやめる | |
1133 | |
1134 Don't forget to exit from recursive edit by typing \\[exit-recursive-edit] | |
1135 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。" | |
1136 (save-window-excursion | |
1137 (catch 'exit | |
1138 (let*((bufs (YaTeX-yatex-buffer-list)) buf b e | |
1139 (oldptn (regexp-quote old)) | |
1140 (sw (selected-window)) | |
1141 (ptn (concat | |
1142 "\\(" YaTeX-refcommand-ref-regexp "\\)" | |
1143 "\\s *{" oldptn "}")) | |
1144 (repface (and (fboundp 'make-overlay) | |
1145 (fboundp 'internal-find-face) | |
1146 (if (internal-find-face 'isearch) 'isearch 'region))) | |
1147 ov | |
1148 (qmsg "Replace to `%s'? [yn!rq?]") | |
1149 continue ch) | |
1150 (while bufs | |
1151 (set-buffer (setq buf (car bufs))) | |
1152 (save-excursion | |
1153 (goto-char (point-min)) | |
1154 (while (re-search-forward ptn nil t) | |
1155 (goto-char (match-end 1)) | |
1156 (skip-chars-forward " \t\n{") | |
1157 (unwind-protect | |
1158 (if (and | |
1159 (looking-at oldptn) | |
1160 (setq b (match-beginning 0) | |
1161 e (match-end 0)) | |
1162 (or continue | |
1163 (catch 'query | |
1164 (if repface | |
1165 (if ov (move-overlay ov b e) | |
1166 (overlay-put | |
1167 (setq ov (make-overlay b e)) | |
1168 'face repface))) | |
1169 (switch-to-buffer buf) | |
1170 (while t | |
1171 (message qmsg new) | |
1172 (setq ch (read-char)) | |
1173 (cond | |
1174 ((= ch ?q) (throw 'exit t)) | |
1175 ((= ch ?r) | |
1176 (message | |
1177 "Don't forget to exit recursive-edit by `%s'" | |
1178 (key-description | |
1179 (where-is-internal | |
1180 'exit-recursive-edit '(keymap) t))) | |
1181 (sleep-for 2) | |
1182 (recursive-edit)) | |
1183 ((= ch ?y) (throw 'query t)) | |
1184 ((= ch ?!) (throw 'query (setq continue t))) | |
1185 ((= ch ??) | |
1186 (describe-function | |
1187 'YaTeX::label-rename-refs) | |
1188 (select-window (get-buffer-window "*Help*")) | |
1189 (search-forward "----") | |
1190 (forward-line 1) | |
1191 (set-window-start (selected-window) (point)) | |
1192 (sit-for 0) | |
1193 (select-window sw)) | |
1194 ((= ch ?n) (throw 'query nil))))))) | |
1195 (replace-match new)) | |
1196 (and ov (delete-overlay ov))))) | |
1197 (setq bufs (cdr bufs))))))) | |
1198 | |
1199 (defun YaTeX::label (argp &optional labname refname) | |
1200 "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring." | |
1201 (cond | |
1202 ((= argp 1) | |
1203 (let*((chmode (boundp (intern-soft "old"))) | |
1204 (dlab (if chmode old ;if called via YaTeX-change-section (tricky...) | |
1205 (YaTeX::ref-default-label))) | |
1206 (label (read-string | |
1207 (format "New %s name: " (or labname "label")) | |
1208 (cons dlab 1)))) | |
1209 (if (string< "" label) | |
1210 (let ((refstr (format "\\%s{%s}" (or refname "ref") label)) | |
1211 (key (key-description (where-is-internal 'yank nil t))) | |
1212 (msg | |
1213 (if YaTeX-japan | |
1214 "をkill-ringに入れました。yank(%s)で取り出せます。" | |
1215 " is stored into kill-ring. Paste it by yank(%s)."))) | |
1216 (kill-new refstr) | |
1217 (and chmode | |
1218 (not (equal old label)) | |
1219 (YaTeX::label-rename-refs old label)) | |
1220 (message (concat "`%s'" msg) refstr key))) | |
1221 label)))) | |
1222 | |
1223 | |
1118 (fset 'YaTeX::pageref 'YaTeX::ref) | 1224 (fset 'YaTeX::pageref 'YaTeX::ref) |
1119 (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal | 1225 (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal |
1120 (YaTeX::ref | 1226 (YaTeX::ref |
1121 argp nil nil | 1227 argp nil nil |
1122 (function | 1228 (function |
1280 "\\)\\(\\[.*\\]\\)?") | 1386 "\\)\\(\\[.*\\]\\)?") |
1281 "cite")))) | 1387 "cite")))) |
1282 | 1388 |
1283 (t nil))) | 1389 (t nil))) |
1284 | 1390 |
1391 (defun YaTeX::bibitem (argp) | |
1392 "Add-in function to insert argument of \\bibitem." | |
1393 (YaTeX::label argp "label" "cite")) | |
1394 | |
1285 ;;; for AMS-LaTeX | 1395 ;;; for AMS-LaTeX |
1286 (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref)) | 1396 (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref)) |
1287 ;;; for Harvard citation style | 1397 ;;; for Harvard citation style |
1288 (fset 'YaTeX::citeasnoun 'YaTeX::cite) | 1398 (fset 'YaTeX::citeasnoun 'YaTeX::cite) |
1289 (fset 'YaTeX::possessivecite 'YaTeX::cite) | 1399 (fset 'YaTeX::possessivecite 'YaTeX::cite) |
1290 (fset 'YaTeX::citeyear 'YaTeX::cite) | 1400 (fset 'YaTeX::citeyear 'YaTeX::cite) |
1291 (fset 'YaTeX::citename 'YaTeX::cite) | 1401 (fset 'YaTeX::citename 'YaTeX::cite) |
1292 (fset 'YaTeX::citep 'YaTeX::cite) | 1402 (fset 'YaTeX::citep 'YaTeX::cite) |
1293 (fset 'YaTeX::citet 'YaTeX::cite) | 1403 (fset 'YaTeX::citet 'YaTeX::cite) |
1294 | |
1295 (defun YaTeX-yatex-buffer-list () | |
1296 (save-excursion | |
1297 (delq nil (mapcar (function (lambda (buf) | |
1298 (set-buffer buf) | |
1299 (if (eq major-mode 'yatex-mode) buf))) | |
1300 (buffer-list))))) | |
1301 | 1404 |
1302 (defun YaTeX-select-other-yatex-buffer () | 1405 (defun YaTeX-select-other-yatex-buffer () |
1303 "Select buffer from all yatex-mode's buffers interactivelly." | 1406 "Select buffer from all yatex-mode's buffers interactivelly." |
1304 (interactive) | 1407 (interactive) |
1305 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) | 1408 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list)) |
1585 (defvar YaTeX:documentclass-options-default | 1688 (defvar YaTeX:documentclass-options-default |
1586 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") | 1689 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt") |
1587 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") | 1690 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape") |
1588 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") | 1691 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib") |
1589 ("tombow") ("titlepage") ("notitlepage") ("dvips") | 1692 ("tombow") ("titlepage") ("notitlepage") ("dvips") |
1693 ("mingoth") ;for jsarticle | |
1590 ("clock") ;for slides class only | 1694 ("clock") ;for slides class only |
1591 ) | 1695 ) |
1592 "Default options list for documentclass") | 1696 "Default options list for documentclass") |
1593 (defvar YaTeX:documentclass-options-private nil | 1697 (defvar YaTeX:documentclass-options-private nil |
1594 "*User defined options list for documentclass") | 1698 "*User defined options list for documentclass") |
1622 (concat "[" opt "]")) | 1726 (concat "[" opt "]")) |
1623 ""))) | 1727 ""))) |
1624 | 1728 |
1625 (defvar YaTeX:documentclasses-default | 1729 (defvar YaTeX:documentclasses-default |
1626 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") | 1730 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook") |
1731 ("jsarticle") ("jsbook") | |
1627 ("j-article") ("j-report") ("j-book") | 1732 ("j-article") ("j-report") ("j-book") |
1628 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) | 1733 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc")) |
1629 "Default documentclass alist") | 1734 "Default documentclass alist") |
1630 (defvar YaTeX:documentclasses-private nil | 1735 (defvar YaTeX:documentclasses-private nil |
1631 "*User defined documentclass alist") | 1736 "*User defined documentclass alist") |
1659 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") | 1764 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue") |
1660 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") | 1765 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen") |
1661 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") | 1766 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen") |
1662 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") | 1767 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen") |
1663 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) | 1768 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White")) |
1664 "Colors defined in $TEXMF/tex/plain/colordvi.tex") | 1769 "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex") |
1665 | 1770 |
1666 (defvar YaTeX:latex2e-basic-color-alist | 1771 (defvar YaTeX:latex2e-basic-color-alist |
1667 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") | 1772 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan") |
1668 ("magenta")) | 1773 ("magenta")) |
1669 "Basic colors") | 1774 "Basic colors") |