yatex

annotate yatexadd.el @ 219:ad4e0a008972

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