yatex

annotate yatexadd.el @ 611:e87c3271b8fd

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