yatex

annotate yatexadd.el @ 234:b75390dd4260

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