yatex

annotate yatexadd.el @ 246:9105918e45a2

Abolish too-much guidance for table/figure.
author yuuji@gentei.org
date Fri, 10 Feb 2012 09:09:08 +0900
parents af1e6c48eac0
children 3e3ccba06ca1
rev   line source
yuuji@6 1 ;;; -*- Emacs-Lisp -*-
yuuji@8 2 ;;; YaTeX add-in functions.
yuuji@222 3 ;;; yatexadd.el rev.20
yuuji@222 4 ;;; (c)1991-2012 by HIROSE Yuuji.[yuuji@yatex.org]
yuuji@246 5 ;;; Last modified Thu Feb 9 09:33:55 2012 on firestorm
yuuji@141 6 ;;; $Id$
yuuji@6 7
yuuji@6 8 ;;;
yuuji@6 9 ;;Sample functions for LaTeX environment.
yuuji@6 10 ;;;
yuuji@6 11 (defvar YaTeX:tabular-default-rule
yuuji@6 12 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}"
yuuji@69 13 "*Your favorite default rule format.")
yuuji@69 14
yuuji@23 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s"
yuuji@69 16 "*Vertical thick line format (without @{}). %s'll be replaced by its width.")
yuuji@69 17
yuuji@23 18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}"
yuuji@69 19 "*Horizontal thick line format. %s will be replaced by its width.")
yuuji@69 20
yuuji@6 21 (defun YaTeX:tabular ()
yuuji@18 22 "YaTeX add-in function for tabular environment.
yuuji@18 23 Notice that this function refers the let-variable `env' in
yuuji@18 24 YaTeX-make-begin-end."
yuuji@23 25 (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline"))
yuuji@72 26 (if (string= YaTeX-env-name "tabular*")
yuuji@18 27 (setq width (concat "{" (read-string "Width: ") "}")))
yuuji@18 28 (setq loc (YaTeX:read-position "tb")
yuuji@23 29 bars (string-to-int
yuuji@23 30 (read-string "Number of columns(0 for default format): " "3")))
yuuji@23 31 (if (<= bars 0)
yuuji@23 32 (setq ;if 0, simple format
yuuji@23 33 rule YaTeX:tabular-default-rule
yuuji@23 34 and "& &")
yuuji@23 35 (while (< j bars) ;repeat bars-1 times
yuuji@23 36 (setq rule (concat rule "c|")
yuuji@23 37 and (concat and "& ")
yuuji@23 38 j (1+ j)))
yuuji@23 39 (setq rule (concat rule "c"))
yuuji@23 40 (message "(N)ormal-frame or (T)hick frame? [nt]")
yuuji@23 41 (setq ans (read-char))
yuuji@23 42 (cond
yuuji@23 43 ((or (equal ans ?t) (equal ans ?T))
yuuji@23 44 (setq ans (read-string "Rule width: " "1pt")
yuuji@23 45 rule (concat
yuuji@23 46 "@{" (format YaTeX:tabular-thick-vrule ans) "}"
yuuji@23 47 rule
yuuji@23 48 "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}")
yuuji@23 49 hline (format YaTeX:tabular-thick-hrule ans)))
yuuji@23 50 (t (setq rule (concat "|" rule "|")
yuuji@23 51 hline "\\hline"))))
yuuji@23 52
yuuji@6 53 (setq rule (read-string "rule format: " rule))
yuuji@72 54 (setq YaTeX-single-command "hline")
yuuji@6 55
yuuji@69 56 (format "%s%s{%s}" width loc rule)))
yuuji@69 57
yuuji@18 58 (fset 'YaTeX:tabular* 'YaTeX:tabular)
yuuji@80 59 (fset 'YaTeX:supertabular 'YaTeX:tabular)
yuuji@80 60 (defun YaTeX:alignat ()
yuuji@80 61 (concat "{" (read-string "Number of columns: ") "}"))
yuuji@18 62 (defun YaTeX:array ()
yuuji@18 63 (concat (YaTeX:read-position "tb")
yuuji@69 64 "{" (read-string "Column format: ") "}"))
yuuji@80 65 (defun YaTeX:subequations ()
yuuji@80 66 (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ"
yuuji@80 67 "Changing comment string reduces effort at `ref' completion"))
yuuji@80 68 (concat " " YaTeX-comment-prefix
yuuji@80 69 (YaTeX::ref-default-label "%H:%M")
yuuji@80 70 (if YaTeX-japan "の式群" "equations")))
yuuji@6 71
yuuji@79 72 (defun YaTeX:read-oneof (oneof &optional quick allow-dup)
yuuji@23 73 (let ((pos "") loc (guide ""))
yuuji@23 74 (and (boundp 'name) name (setq guide (format "%s " name)))
yuuji@79 75 (catch 'quick
yuuji@79 76 (while (not (string-match
yuuji@79 77 (setq loc (read-key-sequence
yuuji@79 78 (format "%s position (`%s') [%s]: "
yuuji@79 79 guide oneof pos));name is in YaTeX-addin
yuuji@79 80 loc (if (fboundp 'events-to-keys)
yuuji@79 81 (events-to-keys loc) loc))
yuuji@79 82 "\r\^g\n"))
yuuji@79 83 (cond
yuuji@79 84 ((string-match loc oneof)
yuuji@79 85 (if (or allow-dup (not (string-match loc pos)))
yuuji@79 86 (setq pos (concat pos loc)))
yuuji@79 87 (if quick (throw 'quick t)))
yuuji@79 88 ((and (string-match loc "\C-h\C-?") (> (length pos) 0))
yuuji@79 89 (setq pos (substring pos 0 (1- (length pos)))))
yuuji@79 90 (t
yuuji@79 91 (ding)
yuuji@79 92 (message "Please input one of `%s'." oneof)
yuuji@79 93 (sit-for 3)))))
yuuji@8 94 (message "")
yuuji@69 95 pos))
yuuji@23 96
yuuji@23 97 (defun YaTeX:read-position (oneof)
yuuji@23 98 "Read a LaTeX (optional) position format such as `[htbp]'."
yuuji@23 99 (let ((pos (YaTeX:read-oneof oneof)))
yuuji@69 100 (if (string= pos "") "" (concat "[" pos "]"))))
yuuji@8 101
yuuji@220 102 ;;;
yuuji@220 103 ;; Functions for figure environemnt
yuuji@220 104 ;;;
yuuji@220 105 (defvar YaTeX:figure-caption-first nil
yuuji@220 106 "Non-nil indicates put caption before figure.")
yuuji@220 107 (defun YaTeX:figure (&optional type firstp)
yuuji@220 108 "YaTeX add-in function for figure(*) environment."
yuuji@246 109 (setq YaTeX-section-name
yuuji@246 110 (if YaTeX:figure-caption-first "caption" "includegraphics")
yuuji@246 111 YaTeX-env-name "center")
yuuji@246 112 (YaTeX:read-position "htbp"))
yuuji@246 113
yuuji@220 114
yuuji@220 115 (fset 'YaTeX:figure* 'YaTeX:figure)
yuuji@220 116
yuuji@220 117 ;;;
yuuji@220 118 ;; Functions for table environemnt
yuuji@220 119 ;;;
yuuji@220 120 (defvar YaTeX:table-caption-first t
yuuji@220 121 "*Non-nil indicates put caption before tabular.")
yuuji@8 122 (defun YaTeX:table ()
yuuji@8 123 "YaTeX add-in function for table environment."
yuuji@73 124 (cond
yuuji@73 125 ((eq major-mode 'yatex-mode)
yuuji@246 126 (setq YaTeX-section-name
yuuji@246 127 (if YaTeX:table-caption-first "caption" "label")
yuuji@246 128 YaTeX-env-name "tabular")
yuuji@246 129 (YaTeX:read-position "htbp"))
yuuji@73 130 ((eq major-mode 'texinfo-mode)
yuuji@73 131 (concat " "
yuuji@73 132 (completing-read
yuuji@73 133 "Highlights with: "
yuuji@73 134 '(("@samp")("@kbd")("@code")("@asis")("@file")("@var"))
yuuji@73 135 nil nil "@")))))
yuuji@219 136 (fset 'YaTeX:table* 'YaTeX:table)
yuuji@6 137
yuuji@6 138 (defun YaTeX:description ()
yuuji@6 139 "Truly poor service:-)"
yuuji@72 140 (setq YaTeX-single-command "item[]")
yuuji@69 141 "")
yuuji@6 142
yuuji@6 143 (defun YaTeX:itemize ()
yuuji@6 144 "It's also poor service."
yuuji@72 145 (setq YaTeX-single-command "item")
yuuji@69 146 "")
yuuji@6 147
yuuji@6 148 (fset 'YaTeX:enumerate 'YaTeX:itemize)
yuuji@8 149
yuuji@11 150 (defun YaTeX:picture ()
yuuji@11 151 "Ask the size of coordinates of picture environment."
yuuji@11 152 (concat (YaTeX:read-coordinates "Picture size")
yuuji@69 153 (YaTeX:read-coordinates "Initial position")))
yuuji@11 154
yuuji@12 155 (defun YaTeX:equation ()
yuuji@59 156 (YaTeX-jmode-off)
yuuji@12 157 (if (fboundp 'YaTeX-toggle-math-mode)
yuuji@69 158 (YaTeX-toggle-math-mode t))) ;force math-mode ON.
yuuji@69 159
yuuji@59 160 (mapcar '(lambda (f) (fset f 'YaTeX:equation))
yuuji@59 161 '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align*
yuuji@59 162 YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather*
yuuji@59 163 YaTeX:aligned* YaTeX:gathered YaTeX:gathered*
yuuji@59 164 YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat*
yuuji@59 165 YaTeX:xxalignat YaTeX:xxalignat*))
yuuji@12 166
yuuji@80 167 (defun YaTeX:alignat ()
yuuji@80 168 (YaTeX:equation)
yuuji@80 169 (concat "{" (read-string "Number of cols: ") "}"))
yuuji@80 170
yuuji@80 171
yuuji@80 172
yuuji@16 173 (defun YaTeX:list ()
yuuji@69 174 "%\n{} %default label\n{} %formatting parameter")
yuuji@16 175
yuuji@18 176 (defun YaTeX:minipage ()
yuuji@18 177 (concat (YaTeX:read-position "cbt")
yuuji@69 178 "{" (read-string "Width: ") "}"))
yuuji@18 179
yuuji@64 180 (defun YaTeX:thebibliography ()
yuuji@72 181 (setq YaTeX-section-name "bibitem")
yuuji@77 182 (concat "{" (read-string "Longest label: ") "}"))
yuuji@64 183
yuuji@80 184 (defun YaTeX:multicols ()
yuuji@80 185 (concat "{" (read-string "Number of columns: ") "}"))
yuuji@80 186
yuuji@8 187 ;;;
yuuji@8 188 ;;Sample functions for section-type command.
yuuji@8 189 ;;;
yuuji@8 190 (defun YaTeX:multiput ()
yuuji@8 191 (concat (YaTeX:read-coordinates "Pos")
yuuji@8 192 (YaTeX:read-coordinates "Step")
yuuji@69 193 "{" (read-string "How many times: ") "}"))
yuuji@8 194
yuuji@8 195 (defun YaTeX:put ()
yuuji@69 196 (YaTeX:read-coordinates "Pos"))
yuuji@8 197
yuuji@8 198 (defun YaTeX:makebox ()
yuuji@23 199 (cond
yuuji@23 200 ((YaTeX-in-environment-p "picture")
yuuji@23 201 (concat (YaTeX:read-coordinates "Dimension")
yuuji@80 202 (YaTeX:read-position "lsrtb")))
yuuji@23 203 (t
yuuji@23 204 (let ((width (read-string "Width: ")))
yuuji@23 205 (if (string< "" width)
yuuji@23 206 (progn
yuuji@23 207 (or (equal (aref width 0) ?\[)
yuuji@23 208 (setq width (concat "[" width "]")))
yuuji@80 209 (concat width (YaTeX:read-position
yuuji@80 210 (if YaTeX-use-LaTeX2e "lrs" "lr")))))))))
yuuji@8 211
yuuji@80 212 ;; (defun YaTeX:framebox ()
yuuji@80 213 ;; (if (YaTeX-quick-in-environment-p "picture")
yuuji@80 214 ;; (YaTeX:makebox)))
yuuji@80 215 (fset 'YaTeX:framebox 'YaTeX:makebox)
yuuji@80 216
yuuji@80 217 (defun YaTeX:parbox ()
yuuji@80 218 (YaTeX:read-position "tbc"))
yuuji@104 219 (defun YaTeX::parbox (argp)
yuuji@104 220 (cond
yuuji@104 221 ((= argp 1) (read-string "Width: "))
yuuji@104 222 ((= argp 2) (read-string "Text: "))))
yuuji@8 223
yuuji@105 224 (defun YaTeX::dashbox ()
yuuji@8 225 (concat "{" (read-string "Dash dimension: ") "}"
yuuji@69 226 (YaTeX:read-coordinates "Dimension")))
yuuji@8 227
yuuji@105 228 (defun YaTeX::savebox (argp)
yuuji@80 229 (cond
yuuji@80 230 ((= argp 1) (read-string "Saved into name: " "\\"))
yuuji@80 231 ((= argp 2) (read-string "Text: "))))
yuuji@80 232
yuuji@51 233 (defvar YaTeX-minibuffer-quick-map nil)
yuuji@51 234 (if YaTeX-minibuffer-quick-map nil
yuuji@51 235 (setq YaTeX-minibuffer-quick-map
yuuji@51 236 (copy-keymap minibuffer-local-completion-map))
yuuji@51 237 (let ((ch (1+ ? )))
yuuji@51 238 (while (< ch 127)
yuuji@51 239 (define-key YaTeX-minibuffer-quick-map (char-to-string ch)
yuuji@51 240 'YaTeX-minibuffer-quick-complete)
yuuji@51 241 (setq ch (1+ ch)))))
yuuji@51 242
yuuji@51 243 (defvar YaTeX:left-right-delimiters
yuuji@51 244 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[")
yuuji@51 245 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|")
yuuji@51 246 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil")
yuuji@51 247 ("\\langle" . "\\rangle") ("/") (".")
yuuji@51 248 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil")
yuuji@51 249 ("\\rangle" . "\\langle") ("\\backslash")
yuuji@51 250 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow"))
yuuji@51 251 "TeX math delimiter, which can be completed after \\right or \\left.")
yuuji@51 252
yuuji@51 253 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.")
yuuji@51 254
yuuji@23 255 (defun YaTeX:left ()
yuuji@51 256 (let ((minibuffer-completion-table YaTeX:left-right-delimiters)
yuuji@72 257 delimiter (leftp (string= YaTeX-single-command "left")))
yuuji@51 258 (setq delimiter
yuuji@51 259 (read-from-minibuffer
yuuji@51 260 (format "Delimiter%s: "
yuuji@51 261 (if YaTeX:left-right-default
yuuji@51 262 (format "(default=`%s')" YaTeX:left-right-default)
yuuji@51 263 "(SPC for menu)"))
yuuji@51 264 nil YaTeX-minibuffer-quick-map))
yuuji@51 265 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default))
yuuji@72 266 (setq YaTeX-single-command (if leftp "right" "left")
yuuji@51 267 YaTeX:left-right-default
yuuji@51 268 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter))
yuuji@51 269 delimiter))
yuuji@51 270
yuuji@23 271 (fset 'YaTeX:right 'YaTeX:left)
yuuji@23 272
yuuji@80 273 (defun YaTeX:langle ()
yuuji@80 274 (setq YaTeX-single-command "rangle")
yuuji@80 275 nil)
yuuji@80 276
yuuji@8 277 (defun YaTeX:read-coordinates (&optional mes varX varY)
yuuji@8 278 (concat
yuuji@8 279 "("
yuuji@8 280 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X")))
yuuji@8 281 ","
yuuji@8 282 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y")))
yuuji@69 283 ")"))
yuuji@8 284
yuuji@79 285 (defun YaTeX:itembox ()
yuuji@79 286 (concat "{" (read-string "Item heading string: ") "}"))
yuuji@79 287
yuuji@8 288 ;;;
yuuji@8 289 ;;Sample functions for maketitle-type command.
yuuji@8 290 ;;;
yuuji@8 291 (defun YaTeX:sum ()
yuuji@8 292 "Read range of summation."
yuuji@8 293 (YaTeX:check-completion-type 'maketitle)
yuuji@69 294 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^")))
yuuji@8 295
yuuji@8 296 (fset 'YaTeX:int 'YaTeX:sum)
yuuji@8 297
yuuji@8 298 (defun YaTeX:lim ()
yuuji@8 299 "Insert limit notation of \\lim."
yuuji@8 300 (YaTeX:check-completion-type 'maketitle)
yuuji@8 301 (let ((var (read-string "Variable: ")) limit)
yuuji@8 302 (if (string= "" var) ""
yuuji@8 303 (setq limit (read-string "Limit ($ means infinity): "))
yuuji@8 304 (if (string= "$" limit) (setq limit "\\infty"))
yuuji@69 305 (concat "_{" var " \\rightarrow " limit "}"))))
yuuji@8 306
yuuji@8 307 (defun YaTeX:gcd ()
yuuji@8 308 "Add-in function for \\gcd(m,n)."
yuuji@8 309 (YaTeX:check-completion-type 'maketitle)
yuuji@69 310 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)"))
yuuji@8 311
yuuji@8 312 (defun YaTeX:read-boundary (ULchar)
yuuji@8 313 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar."
yuuji@11 314 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): "))))
yuuji@8 315 (if (string= bndry "") ""
yuuji@11 316 (if (string= bndry "$") (setq bndry "\\infty"))
yuuji@69 317 (concat ULchar "{" bndry "}"))))
yuuji@8 318
yuuji@14 319 (defun YaTeX:verb ()
yuuji@14 320 "Enclose \\verb's contents with the same characters."
yuuji@14 321 (let ((quote-char (read-string "Quoting char: " "|"))
yuuji@14 322 (contents (read-string "Quoted contents: ")))
yuuji@69 323 (concat quote-char contents quote-char)))
yuuji@69 324
yuuji@23 325 (fset 'YaTeX:verb* 'YaTeX:verb)
yuuji@14 326
yuuji@43 327 (defun YaTeX:footnotemark ()
yuuji@72 328 (setq YaTeX-section-name "footnotetext")
yuuji@69 329 nil)
yuuji@43 330
yuuji@48 331 (defun YaTeX:cite ()
yuuji@48 332 (let ((comment (read-string "Comment for citation: ")))
yuuji@48 333 (if (string= comment "") ""
yuuji@69 334 (concat "[" comment "]"))))
yuuji@48 335
yuuji@48 336 (defun YaTeX:bibitem ()
yuuji@64 337 (let ((label (read-string "Citation label for bibitem: ")))
yuuji@48 338 (if (string= label "") ""
yuuji@69 339 (concat "[" label "]"))))
yuuji@48 340
yuuji@53 341 (defun YaTeX:item ()
yuuji@73 342 (cond
yuuji@73 343 ((eq major-mode 'yatex-mode)
yuuji@73 344 (YaTeX-indent-line)
yuuji@73 345 (setq YaTeX-section-name "label"))
yuuji@73 346 ((eq major-mode 'texinfo-mode)
yuuji@73 347 (setq YaTeX-section-name "dots"))) ;??
yuuji@53 348 " ")
yuuji@52 349 (fset 'YaTeX:item\[\] 'YaTeX:item)
yuuji@52 350 (fset 'YaTeX:subitem 'YaTeX:item)
yuuji@52 351 (fset 'YaTeX:subsubitem 'YaTeX:item)
yuuji@52 352
yuuji@58 353 (defun YaTeX:linebreak ()
yuuji@58 354 (let (obl)
yuuji@58 355 (message "Break strength 0,1,2,3,4 (default: 4): ")
yuuji@58 356 (setq obl (char-to-string (read-char)))
yuuji@58 357 (if (string-match "[0-4]" obl)
yuuji@58 358 (concat "[" obl "]")
yuuji@69 359 "")))
yuuji@58 360 (fset 'YaTeX:pagebreak 'YaTeX:linebreak)
yuuji@58 361
yuuji@14 362 ;;;
yuuji@14 363 ;;Subroutine
yuuji@14 364 ;;;
yuuji@14 365
yuuji@8 366 (defun YaTeX:check-completion-type (type)
yuuji@8 367 "Check valid completion type."
yuuji@8 368 (if (not (eq type YaTeX-current-completion-type))
yuuji@69 369 (error "This should be completed with %s-type completion." type)))
yuuji@11 370
yuuji@11 371
yuuji@11 372 ;;;
yuuji@11 373 ;;; [[Add-in functions for reading section arguments]]
yuuji@11 374 ;;;
yuuji@11 375 ;; All of add-in functions for reading sections arguments should
yuuji@11 376 ;; take an argument ARGP that specify the argument position.
yuuji@11 377 ;; If argument position is out of range, nil should be returned,
yuuji@11 378 ;; else nil should NOT be returned.
yuuji@13 379
yuuji@13 380 ;;
yuuji@13 381 ; Label selection
yuuji@13 382 ;;
yuuji@11 383 (defvar YaTeX-label-menu-other
yuuji@11 384 (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n"))
yuuji@23 385 (defvar YaTeX-label-menu-repeat
yuuji@23 386 (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n"))
yuuji@11 387 (defvar YaTeX-label-menu-any
yuuji@11 388 (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n"))
yuuji@11 389 (defvar YaTeX-label-buffer "*Label completions*")
yuuji@11 390 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
yuuji@11 391 (defvar YaTeX-label-select-map nil
yuuji@11 392 "Key map used in label selection buffer.")
yuuji@11 393 (defun YaTeX::label-setup-key-map ()
yuuji@11 394 (if YaTeX-label-select-map nil
yuuji@11 395 (message "Setting up label selection mode map...")
yuuji@68 396 ;(setq YaTeX-label-select-map (copy-keymap global-map))
yuuji@68 397 (setq YaTeX-label-select-map (make-keymap))
yuuji@11 398 (suppress-keymap YaTeX-label-select-map)
yuuji@11 399 (substitute-all-key-definition
yuuji@11 400 'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
yuuji@11 401 (substitute-all-key-definition
yuuji@11 402 'next-line 'YaTeX::label-next YaTeX-label-select-map)
yuuji@11 403 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next)
yuuji@11 404 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous)
yuuji@11 405 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer)
yuuji@11 406 (define-key YaTeX-label-select-map ">" 'end-of-buffer)
yuuji@11 407 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit)
yuuji@11 408 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit)
yuuji@11 409 (define-key YaTeX-label-select-map " " 'exit-recursive-edit)
yuuji@11 410 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit)
yuuji@11 411 (define-key YaTeX-label-select-map "/" 'isearch-forward)
yuuji@11 412 (define-key YaTeX-label-select-map "?" 'isearch-backward)
yuuji@11 413 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag)
yuuji@23 414 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag)
yuuji@11 415 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag)
yuuji@11 416 (message "Setting up label selection mode map...Done")
yuuji@11 417 (let ((key ?A))
yuuji@11 418 (while (<= key ?Z)
yuuji@11 419 (define-key YaTeX-label-select-map (char-to-string key)
yuuji@11 420 'YaTeX::label-search-tag)
yuuji@11 421 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
yuuji@11 422 'YaTeX::label-search-tag)
yuuji@69 423 (setq key (1+ key))))))
yuuji@69 424
yuuji@11 425 (defun YaTeX::label-next ()
yuuji@11 426 (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
yuuji@11 427 (defun YaTeX::label-previous ()
yuuji@11 428 (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
yuuji@11 429 (defun YaTeX::label-search-tag ()
yuuji@11 430 (interactive)
yuuji@68 431 (let ((case-fold-search t)
yuuji@68 432 (tag (regexp-quote (char-to-string last-command-char))))
yuuji@11 433 (cond
yuuji@11 434 ((save-excursion
yuuji@11 435 (forward-char 1)
yuuji@23 436 (re-search-forward (concat "^" tag) nil t))
yuuji@11 437 (goto-char (match-beginning 0)))
yuuji@11 438 ((save-excursion
yuuji@11 439 (goto-char (point-min))
yuuji@23 440 (re-search-forward (concat "^" tag) nil t))
yuuji@11 441 (goto-char (match-beginning 0))))
yuuji@69 442 (message YaTeX-label-guide-msg)))
yuuji@69 443
yuuji@70 444 ; (defun YaTeX::ref (argp &optional labelcmd refcmd)
yuuji@70 445 ; (cond
yuuji@70 446 ; ((= argp 1)
yuuji@70 447 ; (let ((lnum 0) e0 label label-list (buf (current-buffer))
yuuji@70 448 ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref"))
yuuji@70 449 ; (p (point)) initl line cf)
yuuji@70 450 ; (message "Collecting labels...")
yuuji@70 451 ; (save-window-excursion
yuuji@70 452 ; (YaTeX-showup-buffer
yuuji@70 453 ; YaTeX-label-buffer (function (lambda (x) (window-width x))))
yuuji@70 454 ; (if (fboundp 'select-frame) (setq cf (selected-frame)))
yuuji@70 455 ; (if (eq (window-buffer (minibuffer-window)) buf)
yuuji@70 456 ; (progn
yuuji@70 457 ; (other-window 1)
yuuji@70 458 ; (setq buf (current-buffer))
yuuji@70 459 ; (set-buffer buf)
yuuji@70 460 ; ;(message "cb=%s" buf)(sit-for 3)
yuuji@70 461 ; ))
yuuji@70 462 ; (save-excursion
yuuji@70 463 ; (set-buffer (get-buffer-create YaTeX-label-buffer))
yuuji@70 464 ; (setq buffer-read-only nil)
yuuji@70 465 ; (erase-buffer))
yuuji@70 466 ; (save-excursion
yuuji@70 467 ; (goto-char (point-min))
yuuji@70 468 ; (let ((standard-output (get-buffer YaTeX-label-buffer)))
yuuji@70 469 ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
yuuji@70 470 ; (while (YaTeX-re-search-active-forward
yuuji@70 471 ; (concat "\\\\" labelcmd "\\b")
yuuji@70 472 ; (regexp-quote YaTeX-comment-prefix) nil t)
yuuji@70 473 ; (goto-char (match-beginning 0))
yuuji@70 474 ; (skip-chars-forward "^{")
yuuji@70 475 ; (setq label
yuuji@70 476 ; (buffer-substring
yuuji@70 477 ; (1+ (point))
yuuji@70 478 ; (prog2 (forward-list 1) (setq e0 (1- (point)))))
yuuji@70 479 ; label-list (cons label label-list))
yuuji@70 480 ; (or initl
yuuji@70 481 ; (if (< p (point)) (setq initl lnum)))
yuuji@70 482 ; (beginning-of-line)
yuuji@70 483 ; (skip-chars-forward " \t\n" nil)
yuuji@70 484 ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
yuuji@70 485 ; (buffer-substring (point) (point-end-of-line))))
yuuji@70 486 ; (setq lnum (1+ lnum))
yuuji@70 487 ; (message "Collecting \\%s{}... %d" labelcmd lnum)
yuuji@70 488 ; (goto-char e0))
yuuji@70 489 ; (princ YaTeX-label-menu-other)
yuuji@70 490 ; (princ YaTeX-label-menu-repeat)
yuuji@70 491 ; (princ YaTeX-label-menu-any)
yuuji@70 492 ; );standard-output
yuuji@70 493 ; (goto-char p)
yuuji@70 494 ; (or initl (setq initl lnum))
yuuji@70 495 ; (message "Collecting %s...Done" labelcmd)
yuuji@70 496 ; (if (fboundp 'select-frame) (select-frame cf))
yuuji@70 497 ; (YaTeX-showup-buffer YaTeX-label-buffer nil t)
yuuji@70 498 ; (YaTeX::label-setup-key-map)
yuuji@70 499 ; (setq truncate-lines t)
yuuji@70 500 ; (setq buffer-read-only t)
yuuji@70 501 ; (use-local-map YaTeX-label-select-map)
yuuji@70 502 ; (message YaTeX-label-guide-msg)
yuuji@70 503 ; (goto-line (1+ initl)) ;goto recently defined label line
yuuji@70 504 ; (switch-to-buffer (current-buffer))
yuuji@70 505 ; (unwind-protect
yuuji@70 506 ; (progn
yuuji@70 507 ; (recursive-edit)
yuuji@70 508 ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
yuuji@70 509 ; (beginning-of-line)
yuuji@70 510 ; (setq line (1- (count-lines (point-min)(point))))
yuuji@70 511 ; (cond
yuuji@70 512 ; ((= line -1) (setq label ""))
yuuji@70 513 ; ((= line lnum) (setq label (YaTeX-label-other)))
yuuji@70 514 ; ((= line (1+ lnum))
yuuji@70 515 ; (save-excursion
yuuji@70 516 ; (switch-to-buffer buf)
yuuji@70 517 ; (goto-char p)
yuuji@70 518 ; (if (re-search-backward
yuuji@70 519 ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
yuuji@70 520 ; (setq label (YaTeX-match-string 1))
yuuji@70 521 ; (setq label ""))))
yuuji@70 522 ; ((>= line (+ lnum 2))
yuuji@70 523 ; (setq label (read-string (format "\\%s{???}: " refcmd))))
yuuji@70 524 ; (t (setq label (nth (- lnum line 1) label-list)))))
yuuji@70 525 ; (bury-buffer YaTeX-label-buffer)))
yuuji@70 526 ; label)))))
yuuji@70 527
yuuji@80 528 (defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y"
yuuji@80 529 "*Default \\ref time string format.
yuuji@80 530 This format is like strftime(3) but allowed conversion char are as follows;
yuuji@80 531 %y -> Last 2 digit of year, %b -> Month name, %m -> Monthe number(1-12),
yuuji@80 532 %d -> Day, %H -> Hour, %M -> Minute, %S -> Second,
yuuji@80 533 %qx -> alphabetical-decimal conversion of yymmdd.
yuuji@80 534 %qX -> alphabetical-decimal conversion of HHMMSS.
yuuji@80 535 Beware defualt label-string should be always unique. So this format string
yuuji@80 536 should have both time part (%H+%M+%S or %qX) and date
yuuji@80 537 part (%y+(%b|%m)+%d or %qx).")
yuuji@80 538
yuuji@80 539 (defun YaTeX::ref-alphabex (n)
yuuji@80 540 (let ((alphabex ""))
yuuji@80 541 (while (> n 0)
yuuji@80 542 (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex)
yuuji@80 543 n (/ n 26)))
yuuji@80 544 alphabex))
yuuji@80 545
yuuji@80 546 (defun YaTeX::ref-default-label (&optional format)
yuuji@80 547 "Default auto-genarated label string."
yuuji@80 548 ;; We do not use (format-time-string) for emacs-19
yuuji@80 549 (let*((ts (substring (current-time-string) 4))
yuuji@80 550 (y (substring ts -2))
yuuji@80 551 (b (substring ts 0 3))
yuuji@80 552 (d (format "%d" (string-to-int (substring ts 4 6))))
yuuji@80 553 (H (substring ts 7 9))
yuuji@80 554 (M (substring ts 10 12))
yuuji@80 555 (S (substring ts 13 15))
yuuji@80 556 (HMS (+ (* 10000 (string-to-int H))
yuuji@80 557 (* 100 (string-to-int M))
yuuji@80 558 (string-to-int S)))
yuuji@80 559 (talphabex (YaTeX::ref-alphabex HMS))
yuuji@80 560 (mnames "JanFebMarAprMayJunJulAugSepOctNovDec")
yuuji@80 561 (m (format "%02d" (/ (string-match b mnames) 3)))
yuuji@80 562 (ymd (+ (* 10000 (string-to-int y))
yuuji@80 563 (* 100 (string-to-int m))
yuuji@80 564 (string-to-int d)))
yuuji@80 565 (dalphabex (YaTeX::ref-alphabex ymd)))
yuuji@80 566 (YaTeX-replace-formats
yuuji@80 567 (or format YaTeX-ref-default-label-string)
yuuji@80 568 (list (cons "y" y)
yuuji@80 569 (cons "b" b)
yuuji@80 570 (cons "m" m)
yuuji@80 571 (cons "d" d)
yuuji@80 572 (cons "H" H)
yuuji@80 573 (cons "M" M)
yuuji@80 574 (cons "S" S)
yuuji@80 575 (cons "qX" talphabex)
yuuji@80 576 (cons "qx" dalphabex)))))
yuuji@80 577
yuuji@80 578 (defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label
yuuji@80 579 "*Function to generate default label for unnamed \\label{}s.
yuuji@80 580 The function pointed to this value should take two arguments.
yuuji@80 581 First argument is LaTeX macro's name, second is macro's argument.")
yuuji@80 582
yuuji@80 583 (defun YaTeX::ref-generate-label (command arg)
yuuji@70 584 "Generate a label string which is unique in current buffer."
yuuji@80 585 (let ((default (condition-case nil
yuuji@80 586 (YaTeX::ref-default-label)
yuuji@80 587 (error (substring (current-time-string) 4)))))
yuuji@70 588 (read-string "Give a label for this line: "
yuuji@70 589 (if YaTeX-emacs-19 (cons default 1) default))))
yuuji@70 590
yuuji@80 591 (defun YaTeX::ref-getset-label (buffer point &optional noset)
yuuji@70 592 "Get label string in the BUFFER near the POINT.
yuuji@80 593 Make \\label{xx} if no label.
yuuji@80 594 If optional third argument NOSET is non-nil, do not generate new label."
yuuji@73 595 ;;Here, we rewrite the LaTeX source. Therefore we should be careful
yuuji@73 596 ;;to decide the location suitable for \label. Do straightforward!
yuuji@80 597 (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env
yuuji@80 598 (r-escape (regexp-quote YaTeX-comment-prefix))
yuuji@80 599 command arg alreadysought foundpoint)
yuuji@80 600 (set-buffer buffer)
yuuji@70 601 (save-excursion
yuuji@70 602 (goto-char point)
yuuji@70 603 (setq cc (current-column))
yuuji@70 604 (if (= (char-after (point)) ?\\) (forward-char 1))
yuuji@70 605 (cond
yuuji@70 606 ((looking-at YaTeX-sectioning-regexp)
yuuji@80 607 (setq command (YaTeX-match-string 0))
yuuji@70 608 (skip-chars-forward "^{")
yuuji@80 609 (setq arg (buffer-substring
yuuji@80 610 (1+ (point))
yuuji@80 611 (progn (forward-list 1) (1- (point)))))
yuuji@70 612 (skip-chars-forward " \t\n")
yuuji@73 613 ;(setq boundary "[^\\]")
yuuji@77 614 (setq inspoint (point))
yuuji@73 615 (setq boundary
yuuji@73 616 (save-excursion
yuuji@77 617 (if (YaTeX-re-search-active-forward
yuuji@77 618 (concat YaTeX-ec-regexp
yuuji@77 619 "\\(" YaTeX-sectioning-regexp "\\|"
yuuji@77 620 "begin\\|item\\)")
yuuji@77 621 r-escape nil 1)
yuuji@73 622 (match-beginning 0)
yuuji@73 623 (1- (point))))))
yuuji@70 624 ((looking-at "item\\s ")
yuuji@80 625 (setq command "item"
yuuji@80 626 cc (+ cc 6))
yuuji@73 627 ;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b"))
yuuji@73 628 (setq boundary
yuuji@73 629 (save-excursion
yuuji@73 630 (if (YaTeX-re-search-active-forward
yuuji@73 631 (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")
yuuji@73 632 r-escape nil 1)
yuuji@73 633 (match-beginning 0)
yuuji@77 634 (1- (point))))
yuuji@77 635 inspoint boundary))
yuuji@70 636 ((looking-at "bibitem")
yuuji@80 637 (setq labelholder "bibitem" ; label holder is bibitem itself
yuuji@80 638 command "bibitem")
yuuji@73 639 (setq boundary
yuuji@73 640 (save-excursion
yuuji@73 641 (if (YaTeX-re-search-active-forward
yuuji@73 642 (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b")
yuuji@73 643 r-escape nil 1)
yuuji@73 644 (match-beginning 0)
yuuji@77 645 (1- (point))))
yuuji@77 646 inspoint boundary))
yuuji@80 647 ((string-match YaTeX::ref-nestable-counter-regexp
yuuji@70 648 (setq env (or (YaTeX-inner-environment t) "document")))
yuuji@80 649 (let ((curtop (get 'YaTeX-inner-environment 'point))
yuuji@80 650 (end (point-max)) label)
yuuji@80 651 (skip-chars-forward " \t\n")
yuuji@80 652 (setq inspoint (point) ;initial candidate
yuuji@80 653 cc (current-column)
yuuji@80 654 command env
yuuji@80 655 alreadysought t)
yuuji@80 656 (if (condition-case nil
yuuji@80 657 (progn
yuuji@80 658 (goto-char curtop)
yuuji@80 659 (YaTeX-goto-corresponding-environment))
yuuji@80 660 (error nil))
yuuji@80 661 (setq end (point)))
yuuji@80 662 (goto-char inspoint)
yuuji@80 663 (while (YaTeX-re-search-active-forward
yuuji@80 664 (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" )
yuuji@80 665 r-escape end t)
yuuji@80 666 (setq label (YaTeX-match-string 1))
yuuji@80 667 (if (and (equal env (YaTeX-inner-environment t))
yuuji@80 668 (= curtop (get 'YaTeX-inner-environment 'point)))
yuuji@80 669 ;;I found the label
yuuji@80 670 (setq alreadysought label
yuuji@80 671 foundpoint (match-end 0))))
yuuji@80 672 ))
yuuji@80 673 ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case
yuuji@80 674 (setq command env
yuuji@80 675 mathp t
yuuji@80 676 exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env))
yuuji@73 677 ;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)"))
yuuji@73 678 (setq boundary
yuuji@73 679 (save-excursion
yuuji@73 680 (if (YaTeX-re-search-active-forward
yuuji@80 681 (concat
yuuji@80 682 YaTeX-ec-regexp "\\("
yuuji@80 683 (if exp1 "" "\\\\\\|")
yuuji@80 684 "end{" env "}\\)")
yuuji@73 685 r-escape nil 1)
yuuji@73 686 (match-beginning 0)
yuuji@77 687 (1- (point))))
yuuji@77 688 inspoint boundary))
yuuji@73 689 ((looking-at "footnote\\s *{")
yuuji@80 690 (setq command "footnote")
yuuji@73 691 (skip-chars-forward "^{") ;move onto `{'
yuuji@73 692 (setq boundary
yuuji@73 693 (save-excursion
yuuji@73 694 (condition-case err
yuuji@73 695 (forward-list 1)
yuuji@73 696 (error (error "\\\\footnote at point %s's brace not closed"
yuuji@73 697 (point))))
yuuji@77 698 (1- (point)))
yuuji@77 699 inspoint boundary))
yuuji@70 700 ((looking-at "caption\\|\\(begin\\)")
yuuji@80 701 (setq command (YaTeX-match-string 0))
yuuji@70 702 (skip-chars-forward "^{")
yuuji@77 703 ;;;;;;(if (match-beginning 1) (forward-list 1))
yuuji@77 704 ;; caption can be treated as mathenv, is it right??
yuuji@80 705 (setq arg (buffer-substring
yuuji@80 706 (1+ (point))
yuuji@80 707 (progn (forward-list 1) (1- (point)))))
yuuji@73 708 ;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b"))
yuuji@77 709 (setq inspoint (point))
yuuji@73 710 (setq boundary
yuuji@73 711 (save-excursion
yuuji@73 712 (if (YaTeX-re-search-active-forward
yuuji@73 713 (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")
yuuji@73 714 r-escape nil 1)
yuuji@73 715 (match-beginning 0)
yuuji@73 716 (1- (point))))))
yuuji@70 717 (t ))
yuuji@70 718 (if (save-excursion (skip-chars-forward " \t") (looking-at "%"))
yuuji@70 719 (forward-line 1))
yuuji@80 720 (cond
yuuji@80 721 ((stringp alreadysought)
yuuji@80 722 (put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly...
yuuji@80 723 alreadysought)
yuuji@80 724 ((and (null alreadysought)
yuuji@80 725 (> boundary (point))
yuuji@80 726 (save-excursion
yuuji@80 727 (YaTeX-re-search-active-forward
yuuji@80 728 ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
yuuji@80 729 labelholder
yuuji@80 730 (regexp-quote YaTeX-comment-prefix)
yuuji@80 731 boundary 1))
yuuji@80 732 (match-beginning 0))
yuuji@70 733 ;; if \label{hoge} found, return it
yuuji@80 734 (put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0)))
yuuji@80 735 (buffer-substring
yuuji@80 736 (progn
yuuji@80 737 (goto-char (match-end 0))
yuuji@80 738 (skip-chars-forward "^{") (1+ (point)))
yuuji@80 739 (progn
yuuji@80 740 (forward-sexp 1) (1- (point)))))
yuuji@70 741 ;;else make a label
yuuji@73 742 ;(goto-char (match-beginning 0))
yuuji@80 743 (noset nil) ;do not set label if noset
yuuji@80 744 (t
yuuji@77 745 (goto-char inspoint)
yuuji@70 746 (skip-chars-backward " \t\n")
yuuji@80 747 (save-excursion
yuuji@80 748 (setq newlabel
yuuji@80 749 (funcall YaTeX-ref-generate-label-function command arg)))
yuuji@70 750 (delete-region (point) (progn (skip-chars-backward " \t") (point)))
yuuji@70 751 (if mathp nil
yuuji@70 752 (insert "\n")
yuuji@70 753 (YaTeX-reindent cc))
yuuji@70 754 (insert (format "\\label{%s}" newlabel))
yuuji@80 755 newlabel)))))
yuuji@70 756
yuuji@80 757 (defvar YaTeX::ref-labeling-regexp-alist-default
yuuji@80 758 '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2)
yuuji@80 759 ("\\\\label{\\([^}]+\\)}" . 1))
yuuji@80 760 "Alist of labeling regexp vs. its group number points to label string.
yuuji@80 761 This alist is used in \\ref's argument's completion.")
yuuji@80 762 (defvar YaTeX::ref-labeling-regexp-alist-private nil
yuuji@168 763 "*Private extension to YaTeX::ref-labeling-regexp-alist.
yuuji@80 764 See the documetation of YaTeX::ref-labeling-regexp-alist.")
yuuji@70 765 (defvar YaTeX::ref-labeling-regexp-alist
yuuji@80 766 (append YaTeX::ref-labeling-regexp-alist-default
yuuji@80 767 YaTeX::ref-labeling-regexp-alist-private))
yuuji@70 768 (defvar YaTeX::ref-labeling-regexp
yuuji@70 769 (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
yuuji@70 770 (defvar YaTeX::ref-mathenv-regexp
yuuji@80 771 ;; See also YaTeX-ams-math-begin-alist in yatex.el
yuuji@80 772 ;; Define only envs which has counter.(without *)
yuuji@80 773 "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline")
yuuji@80 774 (defvar YaTeX::ref-mathenv-exp1-regexp
yuuji@80 775 "\\(equation\\|multline\\)\\b"
yuuji@80 776 "*Regexp of math-envname which has only one math-expression.")
yuuji@70 777 (defvar YaTeX::ref-enumerateenv-regexp
yuuji@70 778 "enumerate")
yuuji@80 779 (defvar YaTeX::ref-nestable-counter-regexp
yuuji@80 780 "subequations")
yuuji@70 781
yuuji@70 782 (defvar YaTeX::ref-labeling-section-level 2
yuuji@72 783 "*ref補完で収集するセクショニングコマンドの下限レベル
yuuji@70 784 YaTeX-sectioning-levelの数値で指定.")
yuuji@70 785
yuuji@80 786 (defun YaTeX::ref (argp &optional labelcmd refcmd predf)
yuuji@70 787 (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache
yuuji@70 788 (require 'yatexsec)
yuuji@11 789 (cond
yuuji@11 790 ((= argp 1)
yuuji@80 791 (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary
yuuji@70 792 (buf (current-buffer))
yuuji@70 793 (llv YaTeX::ref-labeling-section-level)
yuuji@80 794 (mathenvs YaTeX::ref-mathenv-regexp) envname endrx
yuuji@70 795 (enums YaTeX::ref-enumerateenv-regexp)
yuuji@70 796 (counter
yuuji@70 797 (or labelcmd
yuuji@70 798 (concat
yuuji@70 799 YaTeX-ec-regexp "\\(\\("
yuuji@70 800 (mapconcat
yuuji@70 801 'concat
yuuji@70 802 (delq nil
yuuji@70 803 (mapcar
yuuji@72 804 (function
yuuji@72 805 (lambda (s)
yuuji@72 806 (if (>= llv (cdr s))
yuuji@72 807 (car s))))
yuuji@70 808 YaTeX-sectioning-level))
yuuji@70 809 "\\|")
yuuji@77 810 "\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){"
yuuji@80 811 "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)}\\)"
yuuji@80 812 (if YaTeX-use-AMS-LaTeX
yuuji@80 813 (concat
yuuji@80 814 "\\|\\(begin{"
yuuji@80 815 YaTeX::ref-nestable-counter-regexp "}\\)"))
yuuji@80 816 "\\)")))
yuuji@70 817 (regexp (concat "\\(" counter
yuuji@70 818 "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
yuuji@70 819 (itemsep (concat YaTeX-ec-regexp
yuuji@70 820 "\\(\\(bib\\)?item\\|begin\\|end\\)"))
yuuji@86 821 (refcmd (or refcmd "\\(page\\)?ref"))
yuuji@70 822 (p (point)) initl line cf
yuuji@70 823 (percent (regexp-quote YaTeX-comment-prefix))
yuuji@70 824 (output
yuuji@70 825 (function
yuuji@70 826 (lambda (label p)
yuuji@80 827 (while (setq x (string-match "[\n\t]" label))
yuuji@70 828 (aset label x ? ))
yuuji@80 829 (while (setq x (string-match " +" label))
yuuji@70 830 (setq label (concat
yuuji@70 831 (substring label 0 (1+ (match-beginning 0)))
yuuji@70 832 (substring label (match-end 0)))))
yuuji@70 833 (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label))
yuuji@70 834 (setq point-list (cons p point-list))
yuuji@70 835 (message "Collecting labels... %d" lnum)
yuuji@70 836 (setq lnum (1+ lnum)))))
yuuji@80 837 (me (if (boundp 'me) me 'YaTeX::ref))
yuuji@70 838 )
yuuji@60 839 (message "Collecting labels...")
yuuji@60 840 (save-window-excursion
yuuji@60 841 (YaTeX-showup-buffer
yuuji@60 842 YaTeX-label-buffer (function (lambda (x) (window-width x))))
yuuji@60 843 (if (fboundp 'select-frame) (setq cf (selected-frame)))
yuuji@60 844 (if (eq (window-buffer (minibuffer-window)) buf)
yuuji@60 845 (progn
yuuji@60 846 (other-window 1)
yuuji@60 847 (setq buf (current-buffer))
yuuji@70 848 (set-buffer buf)))
yuuji@60 849 (save-excursion
yuuji@69 850 (set-buffer (get-buffer-create YaTeX-label-buffer))
yuuji@80 851 (condition-case ()
yuuji@80 852 (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode))
yuuji@80 853 (font-lock-mode 1))
yuuji@80 854 (error nil))
yuuji@69 855 (setq buffer-read-only nil)
yuuji@69 856 (erase-buffer))
yuuji@69 857 (save-excursion
yuuji@70 858 (set-buffer buf)
yuuji@60 859 (goto-char (point-min))
yuuji@80 860 (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel)
yuuji@60 861 (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
yuuji@48 862 (while (YaTeX-re-search-active-forward
yuuji@70 863 regexp ;;counter
yuuji@70 864 percent nil t)
yuuji@70 865 ;(goto-char (match-beginning 0))
yuuji@70 866 (setq e0 (match-end 0))
yuuji@70 867 (cond
yuuji@80 868 ;;
yuuji@80 869 ;;2005/10/21 Skip it if predicate function returns nil
yuuji@80 870 ((and predf
yuuji@80 871 (let ((md (match-data)))
yuuji@80 872 (prog1
yuuji@80 873 (condition-case nil
yuuji@80 874 (not (funcall predf))
yuuji@80 875 (error nil))
yuuji@80 876 (store-match-data md)))))
yuuji@73 877 ((YaTeX-literal-p) nil)
yuuji@72 878 ((YaTeX-match-string 1)
yuuji@70 879 ;;if standard counter commands found
yuuji@80 880 (setq cmd (YaTeX-match-string 2)
yuuji@80 881 m0 (match-beginning 0))
yuuji@70 882 (setq match-point (match-beginning 0))
yuuji@70 883 (or initl
yuuji@70 884 (if (< p (point)) (setq initl lnum)))
yuuji@70 885 (cond
yuuji@80 886 ;; In any case, variables e0 should be set
yuuji@80 887 ((and YaTeX-use-AMS-LaTeX
yuuji@80 888 (string-match YaTeX::ref-nestable-counter-regexp cmd))
yuuji@80 889 (let (label)
yuuji@80 890 (skip-chars-forward "}")
yuuji@80 891 (setq label (buffer-substring
yuuji@80 892 (point) (min (+ 80 (point)) (point-max))))
yuuji@80 893 ;; to skip (maybe)auto-generated comment
yuuji@80 894 (skip-chars-forward " \t")
yuuji@80 895 (if (looking-at YaTeX-comment-prefix)
yuuji@80 896 (forward-line 1))
yuuji@80 897 (setq e0 (point))
yuuji@80 898 (skip-chars-forward " \t\n")
yuuji@80 899 (if (looking-at "\\\\label{\\([^}]+\\)}")
yuuji@80 900 (setq label (format "(labe:%s)" (YaTeX-match-string 1))
yuuji@80 901 e0 (match-end 1)))
yuuji@80 902 (funcall output (format "--subequation--%s" label) e0)))
yuuji@70 903 ((string-match mathenvs cmd) ;;if matches mathematical env
yuuji@70 904 ;(skip-chars-forward "} \t\n")
yuuji@80 905 ;(forward-line 1) ;2004/1/25
yuuji@80 906 (skip-chars-forward "}")
yuuji@80 907 (setq x (point)
yuuji@80 908 envname (substring
yuuji@80 909 cmd (match-beginning 0) (match-end 0)))
yuuji@80 910 (save-restriction
yuuji@80 911 (narrow-to-region
yuuji@80 912 m0
yuuji@80 913 (save-excursion
yuuji@80 914 (YaTeX-re-search-active-forward
yuuji@80 915 (setq endrx (format "%send{%s}" YaTeX-ec-regexp
yuuji@80 916 (regexp-quote envname)))
yuuji@80 917 percent nil t)))
yuuji@80 918 (catch 'scan
yuuji@80 919 (while (YaTeX-re-search-active-forward
yuuji@80 920 (concat
yuuji@80 921 "\\\\end{\\(" (regexp-quote envname) "\\)";;(1)
yuuji@80 922 (if YaTeX-use-AMS-LaTeX
yuuji@80 923 "\\|\\\\\\(notag\\)") ;;2
yuuji@80 924 (if (string-match
yuuji@80 925 YaTeX::ref-mathenv-exp1-regexp cmd)
yuuji@80 926 "" "\\|\\\\\\\\$")
yuuji@80 927 )
yuuji@80 928 percent nil t)
yuuji@80 929 (let*((quit (match-beginning 1))
yuuji@80 930 (notag (match-beginning 2))
yuuji@80 931 (label ".......................") l2
yuuji@80 932 (e (point)) (m0 (match-beginning 0))
yuuji@80 933 (ln (YaTeX-string-width label)))
yuuji@80 934 (cond
yuuji@80 935 (notag
yuuji@80 936 (YaTeX-re-search-active-forward
yuuji@80 937 "\\\\\\\\" percent nil 1)
yuuji@80 938 (setq x (point)))
yuuji@80 939 (t
yuuji@80 940 (if (YaTeX-re-search-active-backward
yuuji@80 941 YaTeX::ref-labeling-regexp
yuuji@80 942 percent x t)
yuuji@80 943 ;; if \label{x} in math-expression, display it
yuuji@80 944 ;; because formula source is hard to recognize
yuuji@80 945 (progn
yuuji@80 946 (goto-char (match-end 0))
yuuji@80 947 (setq l2 (format "\"label:%s\""
yuuji@80 948 (buffer-substring
yuuji@80 949 (1- (point))
yuuji@80 950 (progn (forward-sexp -1)
yuuji@80 951 (1+ (point))))))
yuuji@80 952 (setq label
yuuji@80 953 (if (< (YaTeX-string-width l2) ln)
yuuji@80 954 (concat
yuuji@80 955 l2
yuuji@80 956 (substring
yuuji@80 957 label
yuuji@80 958 0 (- ln (YaTeX-string-width l2))))
yuuji@80 959 l2))
yuuji@80 960 (goto-char e)))
yuuji@80 961 (funcall output
yuuji@80 962 (concat
yuuji@80 963 label " "
yuuji@80 964 (buffer-substring x m0))
yuuji@80 965 x)
yuuji@80 966 (cond
yuuji@80 967 ((YaTeX-quick-in-environment-p
yuuji@80 968 YaTeX-math-gathering-list)
yuuji@80 969 ;; if here is inner split/cases/gathered env.,
yuuji@80 970 ;; counter for here is only one.
yuuji@80 971 ;; Go out this environment and,
yuuji@80 972 (YaTeX-end-of-environment)
yuuji@80 973 ;; search next expression unit boundary.
yuuji@80 974 (YaTeX-re-search-active-forward
yuuji@80 975 (concat endrx "\\|\\\\begin{")
yuuji@80 976 percent nil 1)
yuuji@80 977 (end-of-line)))
yuuji@80 978 (if quit (throw 'scan t)))))
yuuji@80 979 (setq x (point)))))
yuuji@70 980 (setq e0 (point)))
yuuji@70 981 ((string-match enums cmd)
yuuji@70 982 ;(skip-chars-forward "} \t\n")
yuuji@70 983 (save-restriction
yuuji@70 984 (narrow-to-region
yuuji@70 985 (point)
yuuji@70 986 (save-excursion
yuuji@70 987 (YaTeX-goto-corresponding-environment) (point)))
yuuji@70 988 (forward-line 1)
yuuji@70 989 (while (YaTeX-re-search-active-forward
yuuji@70 990 (concat YaTeX-ec-regexp "item\\s ")
yuuji@70 991 percent nil t)
yuuji@70 992 (setq x (match-beginning 0))
yuuji@70 993 (funcall
yuuji@70 994 output
yuuji@80 995 (concat
yuuji@80 996 existlabel
yuuji@80 997 (buffer-substring
yuuji@80 998 (match-beginning 0)
yuuji@80 999 (if (re-search-forward itemsep nil t)
yuuji@80 1000 (progn (goto-char (match-beginning 0))
yuuji@80 1001 (skip-chars-backward " \t")
yuuji@80 1002 (1- (point)))
yuuji@80 1003 (point-end-of-line))))
yuuji@77 1004 x))
yuuji@77 1005 (setq e0 (point-max))))
yuuji@80 1006 ((string-match "bibitem" cmd) ;maybe generated by myself
yuuji@80 1007 (setq label "")
yuuji@80 1008 (skip-chars-forward " \t")
yuuji@80 1009 (if (looking-at "{") ;sure to be true!!
yuuji@80 1010 (forward-list 1))
yuuji@80 1011 (let ((list '(30 10 65))
yuuji@80 1012 (delim ";") q lim len l str)
yuuji@80 1013 (save-excursion
yuuji@80 1014 (setq lim (if (re-search-forward itemsep nil 1)
yuuji@80 1015 (match-beginning 0) (point))))
yuuji@80 1016 (while list
yuuji@80 1017 (skip-chars-forward " \t\n\\")
yuuji@80 1018 (setq q (looking-at "[\"'{]")
yuuji@80 1019 len (car list)
yuuji@80 1020 str
yuuji@80 1021 (buffer-substring
yuuji@80 1022 (point)
yuuji@80 1023 (progn
yuuji@80 1024 (if q (forward-sexp 1)
yuuji@80 1025 (search-forward delim lim 1)
yuuji@80 1026 (forward-char -1))
yuuji@80 1027 (point))))
yuuji@80 1028 (if (> (setq l (YaTeX-string-width str)) len)
yuuji@80 1029 (setq str (concat
yuuji@80 1030 (YaTeX-truncate-string-width
yuuji@80 1031 str (- len (if q 5 4)))
yuuji@80 1032 "... "
yuuji@80 1033 (if q (substring str -1)))))
yuuji@80 1034 (if (< (setq l (YaTeX-string-width str)) len)
yuuji@80 1035 (setq str (concat str (make-string (- len l) ? ))))
yuuji@80 1036 (if (looking-at delim) (goto-char (match-end 0)))
yuuji@80 1037 (setq label (concat label " " str)
yuuji@80 1038 list (cdr list)))
yuuji@80 1039 (funcall output label match-point)))
yuuji@77 1040 ;;else, simple section-type counter
yuuji@70 1041 ((= (char-after (1- (point))) ?{)
yuuji@70 1042 (setq label (buffer-substring
yuuji@70 1043 (match-beginning 0)
yuuji@70 1044 (progn (forward-char -1)
yuuji@70 1045 (forward-list 1)
yuuji@70 1046 (point))))
yuuji@77 1047 (funcall output label match-point)
yuuji@77 1048 ;; Skip preceding label if exists
yuuji@80 1049 (if (YaTeX::ref-getset-label (current-buffer) match-point t)
yuuji@80 1050 (goto-char (get 'YaTeX::ref-getset-label 'foundpoint)))
yuuji@77 1051 (if (save-excursion
yuuji@77 1052 (skip-chars-forward "\t \n")
yuuji@77 1053 (looking-at YaTeX::ref-labeling-regexp))
yuuji@77 1054 (setq e0 (match-end 0))))
yuuji@70 1055 (t
yuuji@70 1056 (skip-chars-forward " \t")
yuuji@70 1057 (setq label (buffer-substring
yuuji@70 1058 (match-beginning 0)
yuuji@70 1059 (if (re-search-forward
yuuji@70 1060 itemsep
yuuji@70 1061 nil t)
yuuji@70 1062 (progn
yuuji@70 1063 (goto-char (match-beginning 0))
yuuji@70 1064 (skip-chars-backward " \t")
yuuji@70 1065 (1- (point)))
yuuji@70 1066 (point-end-of-line))))
yuuji@70 1067 (funcall output label match-point)
yuuji@77 1068 (if (save-excursion
yuuji@77 1069 (skip-chars-forward "\t \n")
yuuji@77 1070 (looking-at YaTeX::ref-labeling-regexp))
yuuji@77 1071 (setq e0 (match-end 0)))))
yuuji@70 1072 ) ;;put label buffer
yuuji@70 1073 ;;
yuuji@70 1074 ;; if user defined label found
yuuji@70 1075 (t
yuuji@70 1076 ;; memorize line number and label into property
yuuji@70 1077 (goto-char (match-beginning 0))
yuuji@70 1078 (let ((list YaTeX::ref-labeling-regexp-alist)
yuuji@70 1079 (cache (symbol-plist 'YaTeX::ref-labeling-regexp)))
yuuji@70 1080 (while list
yuuji@70 1081 (if (looking-at (car (car list)))
yuuji@70 1082 (progn
yuuji@70 1083 (setq label (YaTeX-match-string 0))
yuuji@70 1084 (put 'YaTeX::ref-labeling-regexp lnum
yuuji@70 1085 (YaTeX-match-string (cdr (car list))))
yuuji@70 1086 (funcall output label 0) ;;0 is dummy, never used
yuuji@70 1087 (setq list nil)))
yuuji@70 1088 (setq list (cdr list))))
yuuji@70 1089 ))
yuuji@11 1090 (goto-char e0))
yuuji@11 1091 (princ YaTeX-label-menu-other)
yuuji@23 1092 (princ YaTeX-label-menu-repeat)
yuuji@11 1093 (princ YaTeX-label-menu-any)
yuuji@69 1094 );standard-output
yuuji@11 1095 (goto-char p)
yuuji@60 1096 (or initl (setq initl lnum))
yuuji@70 1097 (message "Collecting labels...Done")
yuuji@60 1098 (if (fboundp 'select-frame) (select-frame cf))
yuuji@59 1099 (YaTeX-showup-buffer YaTeX-label-buffer nil t)
yuuji@11 1100 (YaTeX::label-setup-key-map)
yuuji@11 1101 (setq truncate-lines t)
yuuji@11 1102 (setq buffer-read-only t)
yuuji@11 1103 (use-local-map YaTeX-label-select-map)
yuuji@11 1104 (message YaTeX-label-guide-msg)
yuuji@60 1105 (goto-line (1+ initl)) ;goto recently defined label line
yuuji@68 1106 (switch-to-buffer (current-buffer))
yuuji@11 1107 (unwind-protect
yuuji@11 1108 (progn
yuuji@11 1109 (recursive-edit)
yuuji@70 1110
yuuji@11 1111 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
yuuji@11 1112 (beginning-of-line)
yuuji@60 1113 (setq line (1- (count-lines (point-min)(point))))
yuuji@11 1114 (cond
yuuji@60 1115 ((= line -1) (setq label ""))
yuuji@11 1116 ((= line lnum) (setq label (YaTeX-label-other)))
yuuji@23 1117 ((= line (1+ lnum))
yuuji@23 1118 (save-excursion
yuuji@23 1119 (switch-to-buffer buf)
yuuji@23 1120 (goto-char p)
yuuji@48 1121 (if (re-search-backward
yuuji@86 1122 (concat "\\\\" refcmd "{") nil t)
yuuji@86 1123 (setq label (YaTeX-buffer-substring
yuuji@86 1124 (progn (goto-char (1- (match-end 0)))
yuuji@86 1125 (1+ (point)))
yuuji@86 1126 (progn (forward-list 1)
yuuji@86 1127 (1- (point)))))
yuuji@23 1128 (setq label ""))))
yuuji@23 1129 ((>= line (+ lnum 2))
yuuji@48 1130 (setq label (read-string (format "\\%s{???}: " refcmd))))
yuuji@70 1131 (t ;(setq label (nth (- lnum line 1) label-list))
yuuji@70 1132 (setq label
yuuji@70 1133 (or (get 'YaTeX::ref-labeling-regexp line)
yuuji@70 1134 (YaTeX::ref-getset-label
yuuji@70 1135 buf (nth (- lnum line 1) point-list))))
yuuji@70 1136 )))
yuuji@11 1137 (bury-buffer YaTeX-label-buffer)))
yuuji@69 1138 label)))))
yuuji@69 1139
yuuji@168 1140 (defun YaTeX::label-rename-refs (old new &optional def ref)
yuuji@168 1141 "Rename reference tag from OLD to NEW.
yuuji@168 1142 Optional arguments DEF and REF specify defining command and
yuuji@168 1143 referring command respectively.
yuuji@168 1144 ---------------------------------------------------------
yuuji@168 1145 CONTROL KEYS - キーの説明
yuuji@168 1146 y Replace 置換する
yuuji@168 1147 n Do not replace 置換しない
yuuji@168 1148 ! Replace All w/o query 残る全部を確認なしで置換
yuuji@168 1149 r Enter Recursive-edit 再帰編集モードへ
yuuji@168 1150 q Quit from replacing ここまでで置換をやめる
yuuji@168 1151
yuuji@168 1152 Don't forget to exit from recursive edit by typing \\[exit-recursive-edit]
yuuji@168 1153 再帰編集に入ったら \\[exit-recursive-edit] で抜け忘れなきよう。"
yuuji@168 1154 (save-window-excursion
yuuji@168 1155 (catch 'exit
yuuji@168 1156 (let*((bufs (YaTeX-yatex-buffer-list)) buf b e
yuuji@168 1157 (oldptn (regexp-quote old))
yuuji@168 1158 (sw (selected-window))
yuuji@168 1159 (ptn (concat
yuuji@168 1160 "\\(" YaTeX-refcommand-ref-regexp "\\)"
yuuji@168 1161 "\\s *{" oldptn "}"))
yuuji@170 1162 (repface (and (fboundp 'make-overlay)
yuuji@170 1163 (fboundp 'internal-find-face)
yuuji@170 1164 (if (internal-find-face 'isearch) 'isearch 'region)))
yuuji@170 1165 ov
yuuji@173 1166 (qmsg "Replace to `%s'? [yn!rq?]")
yuuji@168 1167 continue ch)
yuuji@168 1168 (while bufs
yuuji@168 1169 (set-buffer (setq buf (car bufs)))
yuuji@168 1170 (save-excursion
yuuji@168 1171 (goto-char (point-min))
yuuji@168 1172 (while (re-search-forward ptn nil t)
yuuji@168 1173 (goto-char (match-end 1))
yuuji@168 1174 (skip-chars-forward " \t\n{")
yuuji@168 1175 (unwind-protect
yuuji@168 1176 (if (and
yuuji@168 1177 (looking-at oldptn)
yuuji@168 1178 (setq b (match-beginning 0)
yuuji@168 1179 e (match-end 0))
yuuji@168 1180 (or continue
yuuji@168 1181 (catch 'query
yuuji@170 1182 (if repface
yuuji@168 1183 (if ov (move-overlay ov b e)
yuuji@168 1184 (overlay-put
yuuji@168 1185 (setq ov (make-overlay b e))
yuuji@170 1186 'face repface)))
yuuji@168 1187 (switch-to-buffer buf)
yuuji@168 1188 (while t
yuuji@168 1189 (message qmsg new)
yuuji@168 1190 (setq ch (read-char))
yuuji@168 1191 (cond
yuuji@168 1192 ((= ch ?q) (throw 'exit t))
yuuji@168 1193 ((= ch ?r)
yuuji@168 1194 (message
yuuji@173 1195 "Don't forget to exit recursive-edit by `%s'"
yuuji@168 1196 (key-description
yuuji@168 1197 (where-is-internal
yuuji@168 1198 'exit-recursive-edit '(keymap) t)))
yuuji@168 1199 (sleep-for 2)
yuuji@168 1200 (recursive-edit))
yuuji@168 1201 ((= ch ?y) (throw 'query t))
yuuji@168 1202 ((= ch ?!) (throw 'query (setq continue t)))
yuuji@168 1203 ((= ch ??)
yuuji@168 1204 (describe-function
yuuji@168 1205 'YaTeX::label-rename-refs)
yuuji@168 1206 (select-window (get-buffer-window "*Help*"))
yuuji@168 1207 (search-forward "----")
yuuji@168 1208 (forward-line 1)
yuuji@168 1209 (set-window-start (selected-window) (point))
yuuji@168 1210 (sit-for 0)
yuuji@168 1211 (select-window sw))
yuuji@168 1212 ((= ch ?n) (throw 'query nil)))))))
yuuji@168 1213 (replace-match new))
yuuji@168 1214 (and ov (delete-overlay ov)))))
yuuji@168 1215 (setq bufs (cdr bufs)))))))
yuuji@168 1216
yuuji@167 1217 (defun YaTeX::label (argp &optional labname refname)
yuuji@163 1218 "Read label name and return it with copying \\ref{LABEL-NAME} to kill-ring."
yuuji@163 1219 (cond
yuuji@163 1220 ((= argp 1)
yuuji@168 1221 (let*((chmode (boundp (intern-soft "old")))
yuuji@168 1222 (dlab (if chmode old ;if called via YaTeX-change-section (tricky...)
yuuji@163 1223 (YaTeX::ref-default-label)))
yuuji@167 1224 (label (read-string
yuuji@167 1225 (format "New %s name: " (or labname "label"))
yuuji@167 1226 (cons dlab 1))))
yuuji@163 1227 (if (string< "" label)
yuuji@163 1228 (let ((refstr (format "\\%s{%s}" (or refname "ref") label))
yuuji@163 1229 (key (key-description (where-is-internal 'yank nil t)))
yuuji@163 1230 (msg
yuuji@163 1231 (if YaTeX-japan
yuuji@163 1232 "をkill-ringに入れました。yank(%s)で取り出せます。"
yuuji@163 1233 " is stored into kill-ring. Paste it by yank(%s).")))
yuuji@163 1234 (kill-new refstr)
yuuji@170 1235 (and chmode
yuuji@170 1236 (not (equal old label))
yuuji@173 1237 (YaTeX::label-rename-refs old label))
yuuji@173 1238 (message (concat "`%s'" msg) refstr key)))
yuuji@163 1239 label))))
yuuji@163 1240
yuuji@163 1241
yuuji@16 1242 (fset 'YaTeX::pageref 'YaTeX::ref)
yuuji@80 1243 (defun YaTeX::tabref (argp) ; For the style file of IPSJ journal
yuuji@80 1244 (YaTeX::ref
yuuji@80 1245 argp nil nil
yuuji@80 1246 (function
yuuji@80 1247 (lambda ()
yuuji@80 1248 (YaTeX-quick-in-environment-p "table")))))
yuuji@80 1249 (defun YaTeX::figref (argp) ; For the style file of IPSJ journal
yuuji@80 1250 (YaTeX::ref
yuuji@80 1251 argp nil nil
yuuji@80 1252 (function
yuuji@80 1253 (lambda ()
yuuji@80 1254 (YaTeX-quick-in-environment-p "figure")))))
yuuji@232 1255 (defun YaTeX::eqref (argp)
yuuji@232 1256 (YaTeX::ref
yuuji@232 1257 argp nil nil
yuuji@232 1258 (function
yuuji@232 1259 (lambda ()
yuuji@232 1260 (YaTeX-in-math-mode-p)))))
yuuji@70 1261
yuuji@80 1262 (defun YaTeX::cite-collect-bibs-external (bibptn &rest files)
yuuji@80 1263 "Collect bibentry from FILES(variable length argument) ;
yuuji@70 1264 and print them to standard output."
yuuji@70 1265 ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html
yuuji@80 1266 (let*((tb (get-buffer-create " *bibtmp*"))
yuuji@80 1267 (bibitemsep "^\\s *@[A-Za-z]")
yuuji@80 1268 (target (if (string< "" bibptn) bibptn bibitemsep))
yuuji@80 1269 (checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep))
yuuji@80 1270 beg
yuuji@80 1271 (searchnext
yuuji@80 1272 (if (string< "" bibptn)
yuuji@80 1273 (function
yuuji@80 1274 (lambda()
yuuji@80 1275 (setq beg (point))
yuuji@80 1276 (and
yuuji@80 1277 (prog1
yuuji@80 1278 (re-search-forward target nil t)
yuuji@80 1279 (end-of-line))
yuuji@80 1280 (re-search-backward bibitemsep beg t))))
yuuji@80 1281 (function
yuuji@80 1282 (lambda()
yuuji@80 1283 (re-search-forward target nil t)))))
yuuji@80 1284 )
yuuji@70 1285 (save-excursion
yuuji@70 1286 (set-buffer tb)
yuuji@80 1287 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))
yuuji@70 1288 (while files
yuuji@70 1289 (erase-buffer)
yuuji@70 1290 (cond
yuuji@70 1291 ((file-exists-p (car files))
yuuji@70 1292 (insert-file-contents (car files)))
yuuji@70 1293 ((file-exists-p (concat (car files) ".bib"))
yuuji@70 1294 (insert-file-contents (concat (car files) ".bib"))))
yuuji@70 1295 (save-excursion
yuuji@70 1296 (goto-char (point-min))
yuuji@80 1297 (while (funcall searchnext)
yuuji@70 1298 (skip-chars-forward "^{,")
yuuji@80 1299 (setq beg (point))
yuuji@70 1300 (if (= (char-after (point)) ?{)
yuuji@70 1301 (princ (format "%sbibitem{%s}%s\n"
yuuji@70 1302 YaTeX-ec
yuuji@70 1303 (buffer-substring
yuuji@70 1304 (1+ (point))
yuuji@70 1305 (progn (skip-chars-forward "^,\n")
yuuji@70 1306 (point)))
yuuji@80 1307 (mapconcat
yuuji@80 1308 (function
yuuji@80 1309 (lambda (kwd)
yuuji@80 1310 (goto-char beg)
yuuji@80 1311 (if (re-search-forward
yuuji@80 1312 (concat kwd "\\s *=") nil t)
yuuji@80 1313 (buffer-substring
yuuji@80 1314 (progn
yuuji@80 1315 (goto-char (match-end 0))
yuuji@80 1316 (skip-chars-forward " \t\n")
yuuji@80 1317 (point))
yuuji@80 1318 (progn
yuuji@80 1319 (if (looking-at "[{\"]")
yuuji@80 1320 (forward-sexp 1)
yuuji@80 1321 (forward-char 1)
yuuji@80 1322 (skip-chars-forward "^,}"))
yuuji@80 1323 (point))))))
yuuji@80 1324 '("author" "year" "title" )
yuuji@80 1325 ";"))))
yuuji@80 1326 (and (re-search-forward bibitemsep nil t)
yuuji@80 1327 (forward-line -1))))
yuuji@80 1328 (setq files (cdr files)))
yuuji@80 1329 (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)))))
yuuji@70 1330
yuuji@77 1331 (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem"
yuuji@77 1332 "*Regexp of macro name of bibitem definition")
yuuji@77 1333
yuuji@80 1334 (defun YaTeX::cite-collect-bibs-internal (bibptn)
yuuji@70 1335 "Collect bibentry in the current buffer and print them to standard output."
yuuji@77 1336 (let ((ptn (concat YaTeX-ec-regexp
yuuji@77 1337 "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b"))
yuuji@80 1338 (lim (concat YaTeX-ec-regexp
yuuji@80 1339 "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)"
yuuji@80 1340 "\\|\\(end{\\)"))
yuuji@70 1341 (pcnt (regexp-quote YaTeX-comment-prefix)))
yuuji@80 1342 ;; Using bibptn not yet implemented.
yuuji@80 1343 ;; Do you need it?? 2005/11/22
yuuji@70 1344 (save-excursion
yuuji@70 1345 (while (YaTeX-re-search-active-forward ptn pcnt nil t)
yuuji@70 1346 (skip-chars-forward "^{\n")
yuuji@70 1347 (or (eolp)
yuuji@80 1348 (princ (format "%sbibitem%s %s\n"
yuuji@70 1349 YaTeX-ec
yuuji@70 1350 (buffer-substring
yuuji@80 1351 (point)
yuuji@80 1352 (progn (forward-sexp 1) (point)))
yuuji@80 1353 (buffer-substring
yuuji@80 1354 (progn (skip-chars-forward "\n \t") (point))
yuuji@80 1355 (save-excursion
yuuji@80 1356 (if (YaTeX-re-search-active-forward
yuuji@80 1357 lim pcnt nil t)
yuuji@80 1358 (progn
yuuji@80 1359 (goto-char (match-beginning 0))
yuuji@80 1360 (skip-chars-backward "\n \t")
yuuji@80 1361 (point))
yuuji@80 1362 (point-end-of-line)))))))))))
yuuji@70 1363
yuuji@80 1364 (defun YaTeX::cite (argp &rest dummy)
yuuji@48 1365 (cond
yuuji@48 1366 ((eq argp 1)
yuuji@70 1367 (let* ((cb (current-buffer))
yuuji@70 1368 (f (file-name-nondirectory buffer-file-name))
yuuji@70 1369 (d default-directory)
yuuji@70 1370 (hilit-auto-highlight nil)
yuuji@70 1371 (pcnt (regexp-quote YaTeX-comment-prefix))
yuuji@70 1372 (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}"))
yuuji@80 1373 (bibptn (read-string "Pattern: "))
yuuji@70 1374 (bbuf (get-buffer-create " *bibitems*"))
yuuji@70 1375 (standard-output bbuf)
yuuji@80 1376 (me 'YaTeX::cite) ;shuld set this for using YaTeX::ref
yuuji@70 1377 bibs files)
yuuji@70 1378 (set-buffer bbuf)(erase-buffer)(set-buffer cb)
yuuji@70 1379 (save-excursion
yuuji@70 1380 (goto-char (point-min))
yuuji@70 1381 ;;(1)search external bibdata
yuuji@70 1382 (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
yuuji@70 1383 (apply 'YaTeX::cite-collect-bibs-external
yuuji@80 1384 bibptn
yuuji@70 1385 (YaTeX-split-string
yuuji@70 1386 (YaTeX-match-string 1) ",")))
yuuji@70 1387 ;;(2)search direct \bibitem usage
yuuji@80 1388 (YaTeX::cite-collect-bibs-internal bibptn)
yuuji@70 1389 (if (progn
yuuji@70 1390 (YaTeX-visit-main t)
yuuji@70 1391 (not (eq (current-buffer) cb)))
yuuji@70 1392 (save-excursion
yuuji@70 1393 (goto-char (point-min))
yuuji@70 1394 ;;(1)search external bibdata
yuuji@70 1395 (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
yuuji@70 1396 (apply 'YaTeX::cite-collect-bibs-external
yuuji@80 1397 bibptn
yuuji@70 1398 (YaTeX-split-string
yuuji@70 1399 (YaTeX-match-string 1) ",")))
yuuji@70 1400 ;;(2)search internal
yuuji@80 1401 (YaTeX::cite-collect-bibs-internal bibptn)))
yuuji@70 1402 ;;Now bbuf holds the list of bibitem
yuuji@70 1403 (set-buffer bbuf)
yuuji@80 1404 ;;;(switch-to-buffer bbuf)
yuuji@80 1405 (if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer))
yuuji@77 1406 (YaTeX::ref
yuuji@77 1407 argp
yuuji@77 1408 (concat "\\\\\\("
yuuji@77 1409 YaTeX::cite-bibitem-macro-regexp
yuuji@77 1410 "\\)\\(\\[.*\\]\\)?")
yuuji@77 1411 "cite"))))
yuuji@77 1412
yuuji@48 1413 (t nil)))
yuuji@11 1414
yuuji@167 1415 (defun YaTeX::bibitem (argp)
yuuji@167 1416 "Add-in function to insert argument of \\bibitem."
yuuji@167 1417 (YaTeX::label argp "label" "cite"))
yuuji@167 1418
yuuji@77 1419 ;;; for Harvard citation style
yuuji@77 1420 (fset 'YaTeX::citeasnoun 'YaTeX::cite)
yuuji@77 1421 (fset 'YaTeX::possessivecite 'YaTeX::cite)
yuuji@77 1422 (fset 'YaTeX::citeyear 'YaTeX::cite)
yuuji@77 1423 (fset 'YaTeX::citename 'YaTeX::cite)
yuuji@80 1424 (fset 'YaTeX::citep 'YaTeX::cite)
yuuji@80 1425 (fset 'YaTeX::citet 'YaTeX::cite)
yuuji@70 1426
yuuji@48 1427 (defun YaTeX-select-other-yatex-buffer ()
yuuji@48 1428 "Select buffer from all yatex-mode's buffers interactivelly."
yuuji@48 1429 (interactive)
yuuji@48 1430 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list))
yuuji@48 1431 (lnum -1) buf rv
yuuji@11 1432 (ff "**find-file**"))
yuuji@12 1433 (YaTeX-showup-buffer
yuuji@12 1434 lbuf (function (lambda (x) 1))) ;;Select next window surely.
yuuji@69 1435 (save-excursion
yuuji@69 1436 (set-buffer (get-buffer lbuf))
yuuji@69 1437 (setq buffer-read-only nil)
yuuji@69 1438 (erase-buffer))
yuuji@69 1439 (let ((standard-output (get-buffer lbuf)))
yuuji@11 1440 (while blist
yuuji@48 1441 (princ
yuuji@48 1442 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
yuuji@48 1443 (buffer-name (car blist))))
yuuji@11 1444 (setq blist (cdr blist)))
yuuji@11 1445 (princ (format "':{%s}" ff)))
yuuji@59 1446 (YaTeX-showup-buffer lbuf nil t)
yuuji@11 1447 (YaTeX::label-setup-key-map)
yuuji@11 1448 (setq buffer-read-only t)
yuuji@11 1449 (use-local-map YaTeX-label-select-map)
yuuji@11 1450 (message YaTeX-label-guide-msg)
yuuji@11 1451 (unwind-protect
yuuji@11 1452 (progn
yuuji@11 1453 (recursive-edit)
yuuji@11 1454 (set-buffer lbuf)
yuuji@11 1455 (beginning-of-line)
yuuji@11 1456 (setq rv
yuuji@11 1457 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
yuuji@11 1458 (buffer-substring (match-beginning 1) (match-end 1)) nil)))
yuuji@11 1459 (kill-buffer lbuf))
yuuji@48 1460 (if (string= rv ff)
yuuji@48 1461 (progn
yuuji@48 1462 (call-interactively 'find-file)
yuuji@48 1463 (current-buffer))
yuuji@69 1464 rv)))
yuuji@48 1465
yuuji@48 1466 (defun YaTeX-label-other ()
yuuji@48 1467 (let ((rv (YaTeX-select-other-yatex-buffer)))
yuuji@11 1468 (cond
yuuji@11 1469 ((null rv) "")
yuuji@11 1470 (t
yuuji@11 1471 (set-buffer rv)
yuuji@80 1472 (funcall me argp labelcmd refcmd)))))
yuuji@11 1473
yuuji@13 1474 ;;
yuuji@13 1475 ; completion for the arguments of \newcommand
yuuji@13 1476 ;;
yuuji@13 1477 (defun YaTeX::newcommand (&optional argp)
yuuji@13 1478 (cond
yuuji@13 1479 ((= argp 1)
yuuji@13 1480 (let ((command (read-string "Define newcommand: " "\\")))
yuuji@13 1481 (put 'YaTeX::newcommand 'command (substring command 1))
yuuji@13 1482 command))
yuuji@13 1483 ((= argp 2)
yuuji@13 1484 (let ((argc
yuuji@13 1485 (string-to-int (read-string "Number of arguments(Default 0): ")))
yuuji@13 1486 (def (read-string "Definition: "))
yuuji@13 1487 (command (get 'YaTeX::newcommand 'command)))
yuuji@13 1488 ;;!!! It's illegal to insert string in the add-in function !!!
yuuji@13 1489 (if (> argc 0) (insert (format "[%d]" argc)))
yuuji@13 1490 (if (and (stringp command)
yuuji@13 1491 (string< "" command)
yuuji@51 1492 (y-or-n-p "Update dictionary?"))
yuuji@18 1493 (cond
yuuji@18 1494 ((= argc 0)
yuuji@18 1495 (YaTeX-update-table
yuuji@18 1496 (list command)
yuuji@18 1497 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table))
yuuji@18 1498 ((= argc 1)
yuuji@18 1499 (YaTeX-update-table
yuuji@18 1500 (list command)
yuuji@18 1501 'section-table 'user-section-table 'tmp-section-table))
yuuji@18 1502 (t (YaTeX-update-table
yuuji@18 1503 (list command argc)
yuuji@18 1504 'section-table 'user-section-table 'tmp-section-table))))
yuuji@13 1505 (message "")
yuuji@13 1506 def ;return command name
yuuji@13 1507 ))
yuuji@69 1508 (t "")))
yuuji@13 1509
yuuji@80 1510 (defun YaTeX::newcounter (&optional argp)
yuuji@80 1511 (cond
yuuji@80 1512 ((= argp 1)
yuuji@80 1513 (read-string "New counter name: "))
yuuji@80 1514 (t "")))
yuuji@80 1515
yuuji@16 1516 ;;
yuuji@16 1517 ; completion for the arguments of \pagestyle
yuuji@16 1518 ;;
yuuji@16 1519 (defun YaTeX::pagestyle (&optional argp)
yuuji@16 1520 "Read the pagestyle with completion."
yuuji@16 1521 (completing-read
yuuji@16 1522 "Page style: "
yuuji@69 1523 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil)))
yuuji@69 1524
yuuji@51 1525 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle)
yuuji@51 1526
yuuji@16 1527 ;;
yuuji@16 1528 ; completion for the arguments of \pagenumbering
yuuji@16 1529 ;;
yuuji@16 1530 (defun YaTeX::pagenumbering (&optional argp)
yuuji@16 1531 "Read the numbering style."
yuuji@16 1532 (completing-read
yuuji@16 1533 "Page numbering style: "
yuuji@69 1534 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))))
yuuji@13 1535
yuuji@23 1536 ;;
yuuji@23 1537 ; Length
yuuji@23 1538 ;;
yuuji@23 1539 (defvar YaTeX:style-parameters-default
yuuji@23 1540 '(("\\arraycolsep")
yuuji@23 1541 ("\\arrayrulewidth")
yuuji@23 1542 ("\\baselineskip")
yuuji@23 1543 ("\\columnsep")
yuuji@23 1544 ("\\columnseprule")
yuuji@23 1545 ("\\doublerulesep")
yuuji@23 1546 ("\\evensidemargin")
yuuji@23 1547 ("\\footheight")
yuuji@23 1548 ("\\footskip")
yuuji@23 1549 ("\\headheight")
yuuji@23 1550 ("\\headsep")
yuuji@23 1551 ("\\itemindent")
yuuji@23 1552 ("\\itemsep")
yuuji@23 1553 ("\\labelsep")
yuuji@23 1554 ("\\labelwidth")
yuuji@23 1555 ("\\leftmargin")
yuuji@23 1556 ("\\linewidth")
yuuji@23 1557 ("\\listparindent")
yuuji@23 1558 ("\\marginparsep")
yuuji@23 1559 ("\\marginparwidth")
yuuji@23 1560 ("\\mathindent")
yuuji@23 1561 ("\\oddsidemargin")
yuuji@23 1562 ("\\parindent")
yuuji@23 1563 ("\\parsep")
yuuji@23 1564 ("\\parskip")
yuuji@23 1565 ("\\partopsep")
yuuji@23 1566 ("\\rightmargin")
yuuji@23 1567 ("\\tabcolsep")
yuuji@23 1568 ("\\textheight")
yuuji@23 1569 ("\\textwidth")
yuuji@23 1570 ("\\topmargin")
yuuji@23 1571 ("\\topsep")
yuuji@23 1572 ("\\topskip")
yuuji@23 1573 )
yuuji@23 1574 "Alist of LaTeX style parameters.")
yuuji@23 1575 (defvar YaTeX:style-parameters-private nil
yuuji@23 1576 "*User definable alist of style parameters.")
yuuji@49 1577 (defvar YaTeX:style-parameters-local nil
yuuji@49 1578 "*User definable alist of local style parameters.")
yuuji@23 1579
yuuji@23 1580 (defvar YaTeX:length-history nil "Holds history of length.")
yuuji@51 1581 (put 'YaTeX:length-history 'no-default t)
yuuji@23 1582 (defun YaTeX::setlength (&optional argp)
yuuji@23 1583 "YaTeX add-in function for arguments of \\setlength."
yuuji@23 1584 (cond
yuuji@23 1585 ((equal 1 argp)
yuuji@49 1586 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")
yuuji@49 1587 (YaTeX-cplread-with-learning
yuuji@49 1588 "Length variable: "
yuuji@49 1589 'YaTeX:style-parameters-default
yuuji@49 1590 'YaTeX:style-parameters-private
yuuji@49 1591 'YaTeX:style-parameters-local
yuuji@49 1592 nil nil "\\")
yuuji@49 1593 )
yuuji@23 1594 ((equal 2 argp)
yuuji@69 1595 (read-string-with-history "Length: " nil 'YaTeX:length-history))))
yuuji@69 1596
yuuji@23 1597 (fset 'YaTeX::addtolength 'YaTeX::setlength)
yuuji@23 1598
yuuji@23 1599 (defun YaTeX::settowidth (&optional argp)
yuuji@23 1600 "YaTeX add-in function for arguments of \\settowidth."
yuuji@23 1601 (cond
yuuji@23 1602 ((equal 1 argp)
yuuji@49 1603 (YaTeX-cplread-with-learning
yuuji@49 1604 "Length variable: "
yuuji@49 1605 'YaTeX:style-parameters-default
yuuji@49 1606 'YaTeX:style-parameters-private
yuuji@49 1607 'YaTeX:style-parameters-local
yuuji@49 1608 nil nil "\\"))
yuuji@23 1609 ((equal 2 argp)
yuuji@69 1610 (read-string "Text: "))))
yuuji@69 1611
yuuji@23 1612 (defun YaTeX::newlength (&optional argp)
yuuji@23 1613 "YaTeX add-in function for arguments of \\newlength"
yuuji@23 1614 (cond
yuuji@23 1615 ((equal argp 1)
yuuji@23 1616 (let ((length (read-string "Length variable: " "\\")))
yuuji@49 1617 (if (string< "" length)
yuuji@49 1618 (YaTeX-update-table
yuuji@49 1619 (list length)
yuuji@49 1620 'YaTeX:style-parameters-default
yuuji@49 1621 'YaTeX:style-parameters-private
yuuji@49 1622 'YaTeX:style-parameters-local))
yuuji@69 1623 length))))
yuuji@23 1624
yuuji@23 1625 ;; \multicolumn's arguments
yuuji@23 1626 (defun YaTeX::multicolumn (&optional argp)
yuuji@23 1627 "YaTeX add-in function for arguments of \\multicolumn."
yuuji@23 1628 (cond
yuuji@23 1629 ((equal 1 argp)
yuuji@23 1630 (read-string "Number of columns: "))
yuuji@23 1631 ((equal 2 argp)
yuuji@79 1632 (YaTeX:read-oneof "|lrc" nil t))
yuuji@23 1633 ((equal 3 argp)
yuuji@69 1634 (read-string "Item: "))))
yuuji@23 1635
yuuji@49 1636 (defvar YaTeX:documentstyles-default
yuuji@49 1637 '(("article") ("jarticle") ("j-article")
yuuji@49 1638 ("book") ("jbook") ("j-book")
yuuji@49 1639 ("report") ("jreport") ("j-report")
yuuji@49 1640 ("letter") ("ascjletter"))
yuuji@49 1641 "List of LaTeX documentstyles.")
yuuji@49 1642 (defvar YaTeX:documentstyles-private nil
yuuji@49 1643 "*User defined list of LaTeX documentstyles.")
yuuji@49 1644 (defvar YaTeX:documentstyles-local nil
yuuji@49 1645 "*User defined list of local LaTeX documentstyles.")
yuuji@49 1646 (defvar YaTeX:documentstyle-options-default
yuuji@49 1647 '(("a4j") ("a5j") ("b4j") ("b5j")
yuuji@49 1648 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig"))
yuuji@49 1649 "List of LaTeX documentstyle options.")
yuuji@49 1650 (defvar YaTeX:documentstyle-options-private nil
yuuji@49 1651 "*User defined list of LaTeX documentstyle options.")
yuuji@49 1652 (defvar YaTeX:documentstyle-options-local nil
yuuji@49 1653 "List of LaTeX local documentstyle options.")
yuuji@49 1654
yuuji@49 1655 (defun YaTeX:documentstyle ()
yuuji@49 1656 (let*((delim ",")
yuuji@49 1657 (dt (append YaTeX:documentstyle-options-local
yuuji@49 1658 YaTeX:documentstyle-options-private
yuuji@49 1659 YaTeX:documentstyle-options-default))
yuuji@49 1660 (minibuffer-completion-table dt)
yuuji@49 1661 (opt (read-from-minibuffer
yuuji@49 1662 "Style options ([opt1,opt2,...]): "
yuuji@51 1663 nil YaTeX-minibuffer-completion-map nil))
yuuji@49 1664 (substr opt) o)
yuuji@49 1665 (if (string< "" opt)
yuuji@49 1666 (progn
yuuji@49 1667 (while substr
yuuji@49 1668 (setq o (substring substr 0 (string-match delim substr)))
yuuji@49 1669 (or (assoc o dt)
yuuji@49 1670 (YaTeX-update-table
yuuji@49 1671 (list o)
yuuji@49 1672 'YaTeX:documentstyle-options-default
yuuji@49 1673 'YaTeX:documentstyle-options-private
yuuji@49 1674 'YaTeX:documentstyle-options-local))
yuuji@49 1675 (setq substr
yuuji@49 1676 (if (string-match delim substr)
yuuji@49 1677 (substring substr (1+ (string-match delim substr))))))
yuuji@49 1678 (concat "[" opt "]"))
yuuji@49 1679 "")))
yuuji@49 1680
yuuji@49 1681 (defun YaTeX::documentstyle (&optional argp)
yuuji@51 1682 "YaTeX add-in function for arguments of \\documentstyle."
yuuji@49 1683 (cond
yuuji@49 1684 ((equal argp 1)
yuuji@72 1685 (setq YaTeX-env-name "document")
yuuji@49 1686 (let ((sname
yuuji@49 1687 (YaTeX-cplread-with-learning
yuuji@49 1688 (format "Documentstyle (default %s): "
yuuji@49 1689 YaTeX-default-document-style)
yuuji@49 1690 'YaTeX:documentstyles-default
yuuji@49 1691 'YaTeX:documentstyles-private
yuuji@49 1692 'YaTeX:documentstyles-local)))
yuuji@49 1693 (if (string= "" sname) (setq sname YaTeX-default-document-style))
yuuji@69 1694 (setq YaTeX-default-document-style sname)))))
yuuji@49 1695
yuuji@80 1696 (defun YaTeX::include (argp &optional prompt)
yuuji@86 1697 "Read file name setting default directory to that of main file."
yuuji@80 1698 (cond
yuuji@80 1699 ((= argp 1)
yuuji@86 1700 (save-excursion
yuuji@86 1701 (YaTeX-visit-main t)
yuuji@86 1702 (let*((insert-default-directory)
yuuji@86 1703 (file (read-file-name (or prompt "Input file: ") "")))
yuuji@86 1704 (setq file (substring file 0 (string-match "\\.tex$" file))))))))
yuuji@80 1705
yuuji@80 1706 (fset 'YaTeX::input 'YaTeX::include)
yuuji@80 1707
yuuji@80 1708
yuuji@57 1709 ;;; -------------------- LaTeX2e stuff --------------------
yuuji@57 1710 (defvar YaTeX:documentclass-options-default
yuuji@70 1711 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt")
yuuji@57 1712 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape")
yuuji@57 1713 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib")
yuuji@70 1714 ("tombow") ("titlepage") ("notitlepage") ("dvips")
yuuji@175 1715 ("mingoth") ;for jsarticle
yuuji@57 1716 ("clock") ;for slides class only
yuuji@57 1717 )
yuuji@57 1718 "Default options list for documentclass")
yuuji@57 1719 (defvar YaTeX:documentclass-options-private nil
yuuji@57 1720 "*User defined options list for documentclass")
yuuji@57 1721 (defvar YaTeX:documentclass-options-local nil
yuuji@57 1722 "*User defined options list for local documentclass")
yuuji@57 1723
yuuji@57 1724 (defun YaTeX:documentclass ()
yuuji@57 1725 (let*((delim ",")
yuuji@57 1726 (dt (append YaTeX:documentclass-options-local
yuuji@57 1727 YaTeX:documentclass-options-private
yuuji@57 1728 YaTeX:documentclass-options-default))
yuuji@57 1729 (minibuffer-completion-table dt)
yuuji@57 1730 (opt (read-from-minibuffer
yuuji@57 1731 "Documentclass options ([opt1,opt2,...]): "
yuuji@57 1732 nil YaTeX-minibuffer-completion-map nil))
yuuji@57 1733 (substr opt) o)
yuuji@57 1734 (if (string< "" opt)
yuuji@57 1735 (progn
yuuji@57 1736 (while substr
yuuji@70 1737
yuuji@57 1738 (setq o (substring substr 0 (string-match delim substr)))
yuuji@57 1739 (or (assoc o dt)
yuuji@57 1740 (YaTeX-update-table
yuuji@57 1741 (list o)
yuuji@57 1742 'YaTeX:documentclass-options-default
yuuji@57 1743 'YaTeX:documentclass-options-private
yuuji@57 1744 'YaTeX:documentclass-options-local))
yuuji@57 1745 (setq substr
yuuji@57 1746 (if (string-match delim substr)
yuuji@57 1747 (substring substr (1+ (string-match delim substr))))))
yuuji@57 1748 (concat "[" opt "]"))
yuuji@57 1749 "")))
yuuji@57 1750
yuuji@57 1751 (defvar YaTeX:documentclasses-default
yuuji@57 1752 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook")
yuuji@175 1753 ("jsarticle") ("jsbook")
yuuji@57 1754 ("j-article") ("j-report") ("j-book")
yuuji@57 1755 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc"))
yuuji@57 1756 "Default documentclass alist")
yuuji@57 1757 (defvar YaTeX:documentclasses-private nil
yuuji@57 1758 "*User defined documentclass alist")
yuuji@57 1759 (defvar YaTeX:documentclasses-local nil
yuuji@57 1760 "*User defined local documentclass alist")
yuuji@57 1761 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article")
yuuji@57 1762 "*Default documentclass")
yuuji@57 1763
yuuji@57 1764 (defun YaTeX::documentclass (&optional argp)
yuuji@57 1765 (cond
yuuji@57 1766 ((equal argp 1)
yuuji@72 1767 (setq YaTeX-env-name "document")
yuuji@57 1768 (let ((sname
yuuji@57 1769 (YaTeX-cplread-with-learning
yuuji@57 1770 (format "Documentclass (default %s): " YaTeX-default-documentclass)
yuuji@57 1771 'YaTeX:documentclasses-default
yuuji@57 1772 'YaTeX:documentclasses-private
yuuji@57 1773 'YaTeX:documentclasses-local)))
yuuji@57 1774 (if (string= "" sname) (setq sname YaTeX-default-documentclass))
yuuji@57 1775 (setq YaTeX-default-documentclass sname)))))
yuuji@57 1776
yuuji@70 1777 (defvar YaTeX:latex2e-named-color-alist
yuuji@70 1778 '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot")
yuuji@70 1779 ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange")
yuuji@70 1780 ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed")
yuuji@70 1781 ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon")
yuuji@70 1782 ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry")
yuuji@70 1783 ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid")
yuuji@70 1784 ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet")
yuuji@70 1785 ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue")
yuuji@70 1786 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue")
yuuji@70 1787 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen")
yuuji@70 1788 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen")
yuuji@70 1789 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen")
yuuji@70 1790 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White"))
yuuji@141 1791 "Colors defined in $TEXMF/tex/plain/dvips/colordvi.tex")
yuuji@70 1792
yuuji@70 1793 (defvar YaTeX:latex2e-basic-color-alist
yuuji@70 1794 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan")
yuuji@70 1795 ("magenta"))
yuuji@70 1796 "Basic colors")
yuuji@70 1797
yuuji@70 1798 (defun YaTeX:textcolor ()
yuuji@70 1799 "Add-in for \\color's option"
yuuji@70 1800 (if (y-or-n-p "Use `named' color? ")
yuuji@70 1801 "[named]"))
yuuji@70 1802
yuuji@70 1803 (defun YaTeX::color-completing-read (prompt)
yuuji@70 1804 (let ((completion-ignore-case t)
yuuji@70 1805 (namedp (save-excursion
yuuji@70 1806 (skip-chars-backward "^\n\\[\\\\")
yuuji@70 1807 (looking-at "named"))))
yuuji@70 1808 (completing-read
yuuji@70 1809 prompt
yuuji@70 1810 (if namedp
yuuji@70 1811 YaTeX:latex2e-named-color-alist
yuuji@70 1812 YaTeX:latex2e-basic-color-alist)
yuuji@70 1813 nil t)))
yuuji@70 1814
yuuji@70 1815 (defun YaTeX::textcolor (argp)
yuuji@70 1816 "Add-in for \\color's argument"
yuuji@70 1817 (cond
yuuji@70 1818 ((= argp 1) (YaTeX::color-completing-read "Color: "))
yuuji@70 1819 ((= argp 2) (read-string "Colored string: "))))
yuuji@70 1820
yuuji@70 1821 (fset 'YaTeX:color 'YaTeX:textcolor)
yuuji@70 1822 (fset 'YaTeX::color 'YaTeX::textcolor)
yuuji@70 1823 (fset 'YaTeX:colorbox 'YaTeX:textcolor)
yuuji@70 1824 (fset 'YaTeX::colorbox 'YaTeX::textcolor)
yuuji@70 1825 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor)
yuuji@80 1826 (fset 'YaTeX:pagecolor 'YaTeX:textcolor)
yuuji@80 1827 (fset 'YaTeX::pagecolor 'YaTeX::textcolor)
yuuji@70 1828
yuuji@70 1829 (defun YaTeX::fcolorbox (argp)
yuuji@70 1830 (cond
yuuji@70 1831 ((= argp 1) (YaTeX::color-completing-read "Frame color: "))
yuuji@70 1832 ((= argp 2) (YaTeX::color-completing-read "Inner color: "))
yuuji@70 1833 ((= argp 3) (read-string "Colored string: "))))
yuuji@70 1834
yuuji@70 1835 (defun YaTeX:scalebox ()
yuuji@80 1836 "Add-in for \\scalebox"
yuuji@80 1837 (let ((vmag (read-string
yuuji@80 1838 (if YaTeX-japan "倍率(負で反転): "
yuuji@80 1839 "Magnification(Negative for flipped): ")))
yuuji@80 1840 (hmag (read-string (if YaTeX-japan "縦倍率(省略可): "
yuuji@80 1841 "Vertical magnification(Optional): "))))
yuuji@70 1842 (if (and hmag (string< "" hmag))
yuuji@70 1843 (format "{%s}[%s]" vmag hmag)
yuuji@70 1844 (format "{%s}" vmag))))
yuuji@70 1845
yuuji@80 1846 (defun YaTeX:rotatebox ()
yuuji@80 1847 "Optional argument add-in for \\rotatebox"
yuuji@80 1848 (message "Rotate origin? (N)one (O)rigin (X)-Y: ")
yuuji@80 1849 (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something)
yuuji@80 1850 (cond
yuuji@80 1851 ((memq c '(?O ?o))
yuuji@80 1852 (if (string< "" (setq r (YaTeX:read-oneof "htbpB")))
yuuji@80 1853 (concat "[origin=" r "]")))
yuuji@80 1854 ((memq c '(?X ?x ?Y ?y))
yuuji@80 1855 (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx))
yuuji@80 1856 x (if (string< "x=" r) r)
yuuji@80 1857 r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy))
yuuji@80 1858 y (if (string< "y=" r) r)
yuuji@80 1859 something (or x y))
yuuji@80 1860 (format "%s%s%s%s%s"
yuuji@80 1861 (if something "[" "")
yuuji@80 1862 (if x x "")
yuuji@80 1863 (if (and x y) "," "")
yuuji@80 1864 (if y y "")
yuuji@80 1865 (if something "]" ""))))))
yuuji@80 1866
yuuji@80 1867 (defun YaTeX::rotatebox (argp)
yuuji@80 1868 "Argument add-in for \\rotatebox"
yuuji@80 1869 (cond
yuuji@80 1870 ((= argp 1)
yuuji@80 1871 (read-string (if YaTeX-japan "回転角(度; 左回り): "
yuuji@80 1872 "Angle in degree(unclockwise): ")))
yuuji@80 1873 ((= argp 2)
yuuji@80 1874 (read-string (if YaTeX-japan "テキスト: " "Text: ")))))
yuuji@80 1875
yuuji@73 1876 (defun YaTeX:includegraphics ()
yuuji@73 1877 "Add-in for \\includegraphics's option"
yuuji@73 1878 (let (width height (scale "") angle str)
yuuji@237 1879 (setq width (YaTeX-read-string-or-skip "Width: ")
yuuji@237 1880 height (YaTeX-read-string-or-skip "Height: "))
yuuji@73 1881 (or (string< width "") (string< "" height)
yuuji@237 1882 (setq scale (YaTeX-read-string-or-skip "Scale: ")))
yuuji@237 1883 (setq angle (YaTeX-read-string-or-skip "Angle(0-359): "))
yuuji@73 1884 (setq str
yuuji@73 1885 (mapconcat
yuuji@73 1886 'concat
yuuji@73 1887 (delq nil
yuuji@73 1888 (mapcar '(lambda (s)
yuuji@73 1889 (and (stringp (symbol-value s))
yuuji@73 1890 (string< "" (symbol-value s))
yuuji@73 1891 (format "%s=%s" s (symbol-value s))))
yuuji@73 1892 '(width height scale angle)))
yuuji@73 1893 ","))
yuuji@246 1894 (setq YaTeX-section-name "caption")
yuuji@73 1895 (if (string= "" str) ""
yuuji@73 1896 (concat "[" str "]"))))
yuuji@73 1897
yuuji@70 1898 (defun YaTeX::includegraphics (argp)
yuuji@70 1899 "Add-in for \\includegraphics"
yuuji@80 1900 (YaTeX::include argp "Image File: "))
yuuji@70 1901
yuuji@86 1902 (defun YaTeX::verbfile (argp)
yuuji@86 1903 "Add-in for \\verbfile"
yuuji@86 1904 (YaTeX::include argp "Virbatim File: "))
yuuji@86 1905
yuuji@68 1906 (defun YaTeX:caption ()
yuuji@72 1907 (setq YaTeX-section-name "label")
yuuji@68 1908 nil)
yuuji@68 1909
yuuji@80 1910
yuuji@79 1911 (defvar YaTeX::usepackage-alist-default
yuuji@79 1912 '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable")
yuuji@79 1913 ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox")
yuuji@79 1914 ("amsmath") ("amssymb") ("xymtex") ("chemist")
yuuji@79 1915 ("a4j") ("array") ("epsf") ("color") ("epsfig") ("floatfig")
yuuji@80 1916 ("landscape") ("path") ("supertabular") ("twocolumn")
yuuji@80 1917 ("latexsym") ("times") ("makeidx"))
yuuji@80 1918 "Default completion table for arguments of \\usepackage")
yuuji@79 1919
yuuji@79 1920 (defvar YaTeX::usepackage-alist-private nil
yuuji@79 1921 "*Private completion list of the argument for usepackage")
yuuji@79 1922
yuuji@79 1923 (defvar YaTeX::usepackage-alist-local nil
yuuji@79 1924 "Directory local completion list of the argument for usepackage")
yuuji@79 1925
yuuji@79 1926 (defun YaTeX::usepackage (&optional argp)
yuuji@79 1927 (cond
yuuji@79 1928 ((equal argp 1)
yuuji@79 1929 (setq YaTeX-env-name "document")
yuuji@80 1930 (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map)
yuuji@80 1931 (delim ","))
yuuji@80 1932 (YaTeX-cplread-with-learning
yuuji@80 1933 (if YaTeX-japan "Use package(カンマで区切ってOK): "
yuuji@80 1934 "Use package(delimitable by comma): ")
yuuji@80 1935 'YaTeX::usepackage-alist-default
yuuji@80 1936 'YaTeX::usepackage-alist-private
yuuji@80 1937 'YaTeX::usepackage-alist-local)))))
yuuji@79 1938
yuuji@79 1939 (defun YaTeX::mask (argp)
yuuji@79 1940 (cond
yuuji@79 1941 ((equal argp 1)
yuuji@79 1942 (read-string "String: "))
yuuji@79 1943 ((equal argp 2)
yuuji@79 1944 (let (c)
yuuji@79 1945 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K)))
yuuji@79 1946 (message "Mask type(A..K): ")
yuuji@79 1947 (setq c (upcase (read-char))))
yuuji@79 1948 (format "%c" c)))))
yuuji@79 1949
yuuji@79 1950 (defun YaTeX::maskbox (argp)
yuuji@79 1951 (cond
yuuji@79 1952 ((equal argp 1)
yuuji@79 1953 (read-string "Width: "))
yuuji@79 1954 ((equal argp 2)
yuuji@79 1955 (read-string "Height: "))
yuuji@79 1956 ((equal argp 3)
yuuji@79 1957 (let (c)
yuuji@79 1958 (while (not (memq c '(?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K)))
yuuji@79 1959 (message "Mask type(A..K): ")
yuuji@79 1960 (setq c (upcase (read-char))))
yuuji@79 1961 (format "%c" c)))
yuuji@79 1962 ((equal argp 4)
yuuji@79 1963 (YaTeX:read-oneof "lcr" 'quick))
yuuji@79 1964 ((equal argp 5)
yuuji@80 1965 (read-string "String: "))))
yuuji@80 1966
yuuji@80 1967 (defun YaTeX::textcircled (argp)
yuuji@80 1968 (cond
yuuji@80 1969 ((equal argp 1)
yuuji@80 1970 (let ((char (read-string "Circled char: "))
yuuji@80 1971 (left "") (right "") c)
yuuji@80 1972 (setq c (read-char
yuuji@80 1973 "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:"))
yuuji@80 1974 (cond
yuuji@80 1975 ((memq c '(?s ?S)) (setq left "{\\small " right "}"))
yuuji@80 1976 ((memq c '(?t ?T)) (setq left "{\\tiny " right "}"))
yuuji@80 1977 ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}")))
yuuji@80 1978 (format "%s%s%s" left char right)))))
yuuji@79 1979
yuuji@68 1980 ;;; -------------------- math-mode stuff --------------------
yuuji@68 1981 (defun YaTeX::tilde (&optional pos)
yuuji@68 1982 "For accent macros in mathmode"
yuuji@68 1983 (cond
yuuji@68 1984 ((equal pos 1)
yuuji@68 1985 (message "Put accent on variable: ")
yuuji@68 1986 (let ((v (char-to-string (read-char))) (case-fold-search nil))
yuuji@68 1987 (message "")
yuuji@68 1988 (cond
yuuji@68 1989 ((string-match "i\\|j" v)
yuuji@68 1990 (concat "\\" v "math"))
yuuji@68 1991 ((string-match "[\r\n\t ]" v)
yuuji@68 1992 "")
yuuji@68 1993 (t v))))
yuuji@68 1994 (nil "")))
yuuji@68 1995
yuuji@68 1996 (fset 'YaTeX::hat 'YaTeX::tilde)
yuuji@68 1997 (fset 'YaTeX::check 'YaTeX::tilde)
yuuji@68 1998 (fset 'YaTeX::bar 'YaTeX::tilde)
yuuji@68 1999 (fset 'YaTeX::dot 'YaTeX::tilde)
yuuji@68 2000 (fset 'YaTeX::ddot 'YaTeX::tilde)
yuuji@68 2001 (fset 'YaTeX::vec 'YaTeX::tilde)
yuuji@68 2002
yuuji@68 2003 (defun YaTeX::widetilde (&optional pos)
yuuji@68 2004 "For multichar accent macros in mathmode"
yuuji@68 2005 (cond
yuuji@68 2006 ((equal pos 1)
yuuji@68 2007 (let ((m "Put over chars[%s ]: ") v v2)
yuuji@68 2008 (message m " ")
yuuji@68 2009 (setq v (char-to-string (read-char)))
yuuji@68 2010 (message "")
yuuji@68 2011 (if (string-match "[\r\n\t ]" v)
yuuji@68 2012 ""
yuuji@68 2013 (message m v)
yuuji@68 2014 (setq v2 (char-to-string (read-char)))
yuuji@68 2015 (message "")
yuuji@68 2016 (if (string-match "[\r\n\t ]" v2)
yuuji@68 2017 v
yuuji@68 2018 (concat v v2)))))
yuuji@68 2019 (nil "")))
yuuji@68 2020
yuuji@68 2021 (fset 'YaTeX::widehat 'YaTeX::widetilde)
yuuji@68 2022 (fset 'YaTeX::overline 'YaTeX::widetilde)
yuuji@68 2023 (fset 'YaTeX::overrightarrow 'YaTeX::widetilde)
yuuji@68 2024
yuuji@79 2025 ;
yuuji@79 2026 ; for \frac{}{} region
yuuji@79 2027 (defun YaTeX::frac-region (beg end)
yuuji@79 2028 (if (catch 'done
yuuji@79 2029 (while (re-search-forward "\\s *\\(\\\\over\\|/\\)\\s *" end t)
yuuji@79 2030 (goto-char (match-beginning 0))
yuuji@79 2031 (if (y-or-n-p
yuuji@79 2032 (format "Replace this `%s' with `}{'" (YaTeX-match-string 0)))
yuuji@79 2033 (throw 'done t))
yuuji@79 2034 (goto-char (match-end 0))))
yuuji@79 2035 (let (p (b0 (match-beginning 0)) e0)
yuuji@79 2036 (replace-match "}{")
yuuji@79 2037 (setq e0 (point))
yuuji@79 2038 (save-restriction
yuuji@79 2039 (narrow-to-region beg end)
yuuji@79 2040 (goto-char e0)
yuuji@79 2041 (skip-chars-forward " \t")
yuuji@79 2042 (setq p (point))
yuuji@79 2043 (YaTeX-goto-corresponding-paren)
yuuji@79 2044 (forward-char 1)
yuuji@79 2045 (skip-chars-forward " \t\r\n")
yuuji@79 2046 (if (= end (1+ (point)))
yuuji@79 2047 (progn
yuuji@79 2048 (goto-char p)
yuuji@79 2049 (if (looking-at "\\\\") (forward-char 1))
yuuji@79 2050 (YaTeX-kill-paren nil)))
yuuji@79 2051 (goto-char beg)
yuuji@79 2052 (skip-chars-forward " \t")
yuuji@79 2053 (setq p (point))
yuuji@79 2054 (YaTeX-goto-corresponding-paren)
yuuji@79 2055 (forward-char 1)
yuuji@79 2056 (skip-chars-forward " \t\r\n")
yuuji@79 2057 (if (>= (point) b0)
yuuji@79 2058 (progn
yuuji@79 2059 (goto-char p)
yuuji@79 2060 (if (looking-at "\\\\") (forward-char 1))
yuuji@79 2061 (YaTeX-kill-paren nil))))))
yuuji@79 2062 (message ""))
yuuji@68 2063
yuuji@80 2064 (defun YaTeX::DeclareMathOperator (argp)
yuuji@80 2065 (cond
yuuji@80 2066 ((equal argp 1)
yuuji@80 2067 (read-string "Operator: " "\\"))))
yuuji@80 2068
yuuji@68 2069 ;;;
yuuji@68 2070 ;; Add-in functions for large-type command.
yuuji@68 2071 ;;;
yuuji@68 2072 (defun YaTeX:em ()
yuuji@68 2073 (cond
yuuji@68 2074 ((eq YaTeX-current-completion-type 'large) "\\/")
yuuji@68 2075 (t nil)))
yuuji@68 2076 (fset 'YaTeX:it 'YaTeX:em)
yuuji@68 2077
yuuji@23 2078 ;;; -------------------- End of yatexadd --------------------
yuuji@23 2079 (provide 'yatexadd)
yuuji@72 2080 ; Local variables:
yuuji@72 2081 ; fill-prefix: ";;; "
yuuji@72 2082 ; paragraph-start: "^$\\| \\|;;;$"
yuuji@72 2083 ; paragraph-separate: "^$\\| \\|;;;$"
yuuji@80 2084 ; coding: sjis
yuuji@72 2085 ; End: