yatex

annotate yatexadd.el @ 70:44e3a5e1e883

Fix makefile for Windows Brush up label completion \cite completion Support much more about LaTeX2e --- [yahtml] English Info (By Jun Ohya) Automatic pixel size detection for <img src="..."> Aware global-class of css definition & for char-entity reference
author yuuji
date Sun, 09 Apr 2000 03:37:47 +0000
parents 807c1e7e68b7
children 0aaebd07dad0
rev   line source
yuuji@6 1 ;;; -*- Emacs-Lisp -*-
yuuji@8 2 ;;; YaTeX add-in functions.
yuuji@68 3 ;;; yatexadd.el rev.14
yuuji@70 4 ;;; (c )1991-1999 by HIROSE Yuuji.[yuuji@yatex.org]
yuuji@70 5 ;;; Last modified Fri Mar 17 20:21:45 2000 on firestorm
yuuji@8 6 ;;; $Id$
yuuji@6 7
yuuji@6 8 ;;;
yuuji@6 9 ;;Sample functions for LaTeX environment.
yuuji@6 10 ;;;
yuuji@6 11 (defvar YaTeX:tabular-default-rule
yuuji@6 12 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}"
yuuji@69 13 "*Your favorite default rule format.")
yuuji@69 14
yuuji@23 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s"
yuuji@69 16 "*Vertical thick line format (without @{}). %s'll be replaced by its width.")
yuuji@69 17
yuuji@23 18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}"
yuuji@69 19 "*Horizontal thick line format. %s will be replaced by its width.")
yuuji@69 20
yuuji@6 21 (defun YaTeX:tabular ()
yuuji@18 22 "YaTeX add-in function for tabular environment.
yuuji@18 23 Notice that this function refers the let-variable `env' in
yuuji@18 24 YaTeX-make-begin-end."
yuuji@23 25 (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline"))
yuuji@18 26 (if (string= env "tabular*")
yuuji@18 27 (setq width (concat "{" (read-string "Width: ") "}")))
yuuji@18 28 (setq loc (YaTeX:read-position "tb")
yuuji@23 29 bars (string-to-int
yuuji@23 30 (read-string "Number of columns(0 for default format): " "3")))
yuuji@23 31 (if (<= bars 0)
yuuji@23 32 (setq ;if 0, simple format
yuuji@23 33 rule YaTeX:tabular-default-rule
yuuji@23 34 and "& &")
yuuji@23 35 (while (< j bars) ;repeat bars-1 times
yuuji@23 36 (setq rule (concat rule "c|")
yuuji@23 37 and (concat and "& ")
yuuji@23 38 j (1+ j)))
yuuji@23 39 (setq rule (concat rule "c"))
yuuji@23 40 (message "(N)ormal-frame or (T)hick frame? [nt]")
yuuji@23 41 (setq ans (read-char))
yuuji@23 42 (cond
yuuji@23 43 ((or (equal ans ?t) (equal ans ?T))
yuuji@23 44 (setq ans (read-string "Rule width: " "1pt")
yuuji@23 45 rule (concat
yuuji@23 46 "@{" (format YaTeX:tabular-thick-vrule ans) "}"
yuuji@23 47 rule
yuuji@23 48 "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}")
yuuji@23 49 hline (format YaTeX:tabular-thick-hrule ans)))
yuuji@23 50 (t (setq rule (concat "|" rule "|")
yuuji@23 51 hline "\\hline"))))
yuuji@23 52
yuuji@6 53 (setq rule (read-string "rule format: " rule))
yuuji@58 54 (setq 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@18 59 (defun YaTeX:array ()
yuuji@18 60 (concat (YaTeX:read-position "tb")
yuuji@69 61 "{" (read-string "Column format: ") "}"))
yuuji@6 62
yuuji@23 63 (defun YaTeX:read-oneof (oneof)
yuuji@23 64 (let ((pos "") loc (guide ""))
yuuji@23 65 (and (boundp 'name) name (setq guide (format "%s " name)))
yuuji@6 66 (while (not (string-match
yuuji@8 67 (setq loc (read-key-sequence
yuuji@23 68 (format "%s position (`%s') [%s]: "
yuuji@68 69 guide oneof pos));name is in YaTeX-addin
yuuji@68 70 loc (if (fboundp 'events-to-keys)
yuuji@68 71 (events-to-keys loc) loc))
yuuji@6 72 "\r\^g\n"))
yuuji@6 73 (cond
yuuji@8 74 ((string-match loc oneof)
yuuji@6 75 (if (not (string-match loc pos))
yuuji@6 76 (setq pos (concat pos loc))))
yuuji@6 77 ((and (string-match loc "\C-h\C-?") (> (length pos) 0))
yuuji@6 78 (setq pos (substring pos 0 (1- (length pos)))))
yuuji@6 79 (t
yuuji@6 80 (ding)
yuuji@8 81 (message "Please input one of `%s'." oneof)
yuuji@6 82 (sit-for 3))))
yuuji@8 83 (message "")
yuuji@69 84 pos))
yuuji@23 85
yuuji@23 86 (defun YaTeX:read-position (oneof)
yuuji@23 87 "Read a LaTeX (optional) position format such as `[htbp]'."
yuuji@23 88 (let ((pos (YaTeX:read-oneof oneof)))
yuuji@69 89 (if (string= pos "") "" (concat "[" pos "]"))))
yuuji@8 90
yuuji@8 91 (defun YaTeX:table ()
yuuji@8 92 "YaTeX add-in function for table environment."
yuuji@68 93 (setq env-name "tabular"
yuuji@68 94 section-name "caption")
yuuji@69 95 (YaTeX:read-position "htbp"))
yuuji@6 96
yuuji@46 97 (fset 'YaTeX:figure 'YaTeX:table)
yuuji@46 98 (fset 'YaTeX:figure* 'YaTeX:table)
yuuji@46 99
yuuji@46 100
yuuji@6 101 (defun YaTeX:description ()
yuuji@6 102 "Truly poor service:-)"
yuuji@6 103 (setq single-command "item[]")
yuuji@69 104 "")
yuuji@6 105
yuuji@6 106 (defun YaTeX:itemize ()
yuuji@6 107 "It's also poor service."
yuuji@6 108 (setq single-command "item")
yuuji@69 109 "")
yuuji@6 110
yuuji@6 111 (fset 'YaTeX:enumerate 'YaTeX:itemize)
yuuji@8 112
yuuji@11 113 (defun YaTeX:picture ()
yuuji@11 114 "Ask the size of coordinates of picture environment."
yuuji@11 115 (concat (YaTeX:read-coordinates "Picture size")
yuuji@69 116 (YaTeX:read-coordinates "Initial position")))
yuuji@11 117
yuuji@12 118 (defun YaTeX:equation ()
yuuji@59 119 (YaTeX-jmode-off)
yuuji@12 120 (if (fboundp 'YaTeX-toggle-math-mode)
yuuji@69 121 (YaTeX-toggle-math-mode t))) ;force math-mode ON.
yuuji@69 122
yuuji@59 123 (mapcar '(lambda (f) (fset f 'YaTeX:equation))
yuuji@59 124 '(YaTeX:eqnarray YaTeX:eqnarray* YaTeX:align YaTeX:align*
yuuji@59 125 YaTeX:split YaTeX:multline YaTeX:multline* YaTeX:gather YaTeX:gather*
yuuji@59 126 YaTeX:aligned* YaTeX:gathered YaTeX:gathered*
yuuji@59 127 YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat*
yuuji@59 128 YaTeX:xxalignat YaTeX:xxalignat*))
yuuji@12 129
yuuji@16 130 (defun YaTeX:list ()
yuuji@69 131 "%\n{} %default label\n{} %formatting parameter")
yuuji@16 132
yuuji@18 133 (defun YaTeX:minipage ()
yuuji@18 134 (concat (YaTeX:read-position "cbt")
yuuji@69 135 "{" (read-string "Width: ") "}"))
yuuji@18 136
yuuji@64 137 (defun YaTeX:thebibliography ()
yuuji@64 138 (setq section-name "bibitem")
yuuji@69 139 "")
yuuji@64 140
yuuji@8 141 ;;;
yuuji@8 142 ;;Sample functions for section-type command.
yuuji@8 143 ;;;
yuuji@8 144 (defun YaTeX:multiput ()
yuuji@8 145 (concat (YaTeX:read-coordinates "Pos")
yuuji@8 146 (YaTeX:read-coordinates "Step")
yuuji@69 147 "{" (read-string "How many times: ") "}"))
yuuji@8 148
yuuji@8 149 (defun YaTeX:put ()
yuuji@69 150 (YaTeX:read-coordinates "Pos"))
yuuji@8 151
yuuji@8 152 (defun YaTeX:makebox ()
yuuji@23 153 (cond
yuuji@23 154 ((YaTeX-in-environment-p "picture")
yuuji@23 155 (concat (YaTeX:read-coordinates "Dimension")
yuuji@23 156 (YaTeX:read-position "lrtb")))
yuuji@23 157 (t
yuuji@23 158 (let ((width (read-string "Width: ")))
yuuji@23 159 (if (string< "" width)
yuuji@23 160 (progn
yuuji@23 161 (or (equal (aref width 0) ?\[)
yuuji@23 162 (setq width (concat "[" width "]")))
yuuji@69 163 (concat width (YaTeX:read-position "lr"))))))))
yuuji@8 164
yuuji@8 165 (defun YaTeX:framebox ()
yuuji@8 166 (if (YaTeX-quick-in-environment-p "picture")
yuuji@69 167 (YaTeX:makebox)))
yuuji@8 168
yuuji@8 169 (defun YaTeX:dashbox ()
yuuji@8 170 (concat "{" (read-string "Dash dimension: ") "}"
yuuji@69 171 (YaTeX:read-coordinates "Dimension")))
yuuji@8 172
yuuji@51 173 (defvar YaTeX-minibuffer-quick-map nil)
yuuji@51 174 (if YaTeX-minibuffer-quick-map nil
yuuji@51 175 (setq YaTeX-minibuffer-quick-map
yuuji@51 176 (copy-keymap minibuffer-local-completion-map))
yuuji@51 177 (let ((ch (1+ ? )))
yuuji@51 178 (while (< ch 127)
yuuji@51 179 (define-key YaTeX-minibuffer-quick-map (char-to-string ch)
yuuji@51 180 'YaTeX-minibuffer-quick-complete)
yuuji@51 181 (setq ch (1+ ch)))))
yuuji@51 182
yuuji@51 183 (defvar YaTeX:left-right-delimiters
yuuji@51 184 '(("(" . ")") (")" . "(") ("[" . "]") ("]" . "[")
yuuji@51 185 ("\\{" . "\\}") ("\\}" . "\\{") ("|") ("\\|")
yuuji@51 186 ("\\lfloor" . "\\rfloor") ("\\lceil" . "\\rceil")
yuuji@51 187 ("\\langle" . "\\rangle") ("/") (".")
yuuji@51 188 ("\\rfloor" . "\\rfloor") ("\\rceil" . "\\lceil")
yuuji@51 189 ("\\rangle" . "\\langle") ("\\backslash")
yuuji@51 190 ("\\uparrow") ("\\downarrow") ("\\updownarrow") ("\\Updownarrow"))
yuuji@51 191 "TeX math delimiter, which can be completed after \\right or \\left.")
yuuji@51 192
yuuji@51 193 (defvar YaTeX:left-right-default nil "Default string of YaTeX:right.")
yuuji@51 194
yuuji@23 195 (defun YaTeX:left ()
yuuji@51 196 (let ((minibuffer-completion-table YaTeX:left-right-delimiters)
yuuji@51 197 delimiter (leftp (string= single-command "left")))
yuuji@51 198 (setq delimiter
yuuji@51 199 (read-from-minibuffer
yuuji@51 200 (format "Delimiter%s: "
yuuji@51 201 (if YaTeX:left-right-default
yuuji@51 202 (format "(default=`%s')" YaTeX:left-right-default)
yuuji@51 203 "(SPC for menu)"))
yuuji@51 204 nil YaTeX-minibuffer-quick-map))
yuuji@51 205 (if (string= "" delimiter) (setq delimiter YaTeX:left-right-default))
yuuji@51 206 (setq single-command (if leftp "right" "left")
yuuji@51 207 YaTeX:left-right-default
yuuji@51 208 (or (cdr (assoc delimiter YaTeX:left-right-delimiters)) delimiter))
yuuji@51 209 delimiter))
yuuji@51 210
yuuji@23 211 (fset 'YaTeX:right 'YaTeX:left)
yuuji@23 212
yuuji@51 213
yuuji@8 214 (defun YaTeX:read-coordinates (&optional mes varX varY)
yuuji@8 215 (concat
yuuji@8 216 "("
yuuji@8 217 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X")))
yuuji@8 218 ","
yuuji@8 219 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y")))
yuuji@69 220 ")"))
yuuji@8 221
yuuji@8 222 ;;;
yuuji@8 223 ;;Sample functions for maketitle-type command.
yuuji@8 224 ;;;
yuuji@8 225 (defun YaTeX:sum ()
yuuji@8 226 "Read range of summation."
yuuji@8 227 (YaTeX:check-completion-type 'maketitle)
yuuji@69 228 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^")))
yuuji@8 229
yuuji@8 230 (fset 'YaTeX:int 'YaTeX:sum)
yuuji@8 231
yuuji@8 232 (defun YaTeX:lim ()
yuuji@8 233 "Insert limit notation of \\lim."
yuuji@8 234 (YaTeX:check-completion-type 'maketitle)
yuuji@8 235 (let ((var (read-string "Variable: ")) limit)
yuuji@8 236 (if (string= "" var) ""
yuuji@8 237 (setq limit (read-string "Limit ($ means infinity): "))
yuuji@8 238 (if (string= "$" limit) (setq limit "\\infty"))
yuuji@69 239 (concat "_{" var " \\rightarrow " limit "}"))))
yuuji@8 240
yuuji@8 241 (defun YaTeX:gcd ()
yuuji@8 242 "Add-in function for \\gcd(m,n)."
yuuji@8 243 (YaTeX:check-completion-type 'maketitle)
yuuji@69 244 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)"))
yuuji@8 245
yuuji@8 246 (defun YaTeX:read-boundary (ULchar)
yuuji@8 247 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar."
yuuji@11 248 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): "))))
yuuji@8 249 (if (string= bndry "") ""
yuuji@11 250 (if (string= bndry "$") (setq bndry "\\infty"))
yuuji@69 251 (concat ULchar "{" bndry "}"))))
yuuji@8 252
yuuji@14 253 (defun YaTeX:verb ()
yuuji@14 254 "Enclose \\verb's contents with the same characters."
yuuji@14 255 (let ((quote-char (read-string "Quoting char: " "|"))
yuuji@14 256 (contents (read-string "Quoted contents: ")))
yuuji@69 257 (concat quote-char contents quote-char)))
yuuji@69 258
yuuji@23 259 (fset 'YaTeX:verb* 'YaTeX:verb)
yuuji@14 260
yuuji@43 261 (defun YaTeX:footnotemark ()
yuuji@43 262 (setq section-name "footnotetext")
yuuji@69 263 nil)
yuuji@43 264
yuuji@48 265 (defun YaTeX:cite ()
yuuji@48 266 (let ((comment (read-string "Comment for citation: ")))
yuuji@48 267 (if (string= comment "") ""
yuuji@69 268 (concat "[" comment "]"))))
yuuji@48 269
yuuji@48 270 (defun YaTeX:bibitem ()
yuuji@64 271 (let ((label (read-string "Citation label for bibitem: ")))
yuuji@48 272 (if (string= label "") ""
yuuji@69 273 (concat "[" label "]"))))
yuuji@48 274
yuuji@53 275 (defun YaTeX:item ()
yuuji@53 276 (YaTeX-indent-line)
yuuji@53 277 (setq section-name "label")
yuuji@53 278 " ")
yuuji@52 279 (fset 'YaTeX:item\[\] 'YaTeX:item)
yuuji@52 280 (fset 'YaTeX:subitem 'YaTeX:item)
yuuji@52 281 (fset 'YaTeX:subsubitem 'YaTeX:item)
yuuji@52 282
yuuji@58 283 (defun YaTeX:linebreak ()
yuuji@58 284 (let (obl)
yuuji@58 285 (message "Break strength 0,1,2,3,4 (default: 4): ")
yuuji@58 286 (setq obl (char-to-string (read-char)))
yuuji@58 287 (if (string-match "[0-4]" obl)
yuuji@58 288 (concat "[" obl "]")
yuuji@69 289 "")))
yuuji@58 290 (fset 'YaTeX:pagebreak 'YaTeX:linebreak)
yuuji@58 291
yuuji@14 292 ;;;
yuuji@14 293 ;;Subroutine
yuuji@14 294 ;;;
yuuji@14 295
yuuji@8 296 (defun YaTeX:check-completion-type (type)
yuuji@8 297 "Check valid completion type."
yuuji@8 298 (if (not (eq type YaTeX-current-completion-type))
yuuji@69 299 (error "This should be completed with %s-type completion." type)))
yuuji@11 300
yuuji@11 301
yuuji@11 302 ;;;
yuuji@11 303 ;;; [[Add-in functions for reading section arguments]]
yuuji@11 304 ;;;
yuuji@11 305 ;; All of add-in functions for reading sections arguments should
yuuji@11 306 ;; take an argument ARGP that specify the argument position.
yuuji@11 307 ;; If argument position is out of range, nil should be returned,
yuuji@11 308 ;; else nil should NOT be returned.
yuuji@13 309
yuuji@13 310 ;;
yuuji@13 311 ; Label selection
yuuji@13 312 ;;
yuuji@11 313 (defvar YaTeX-label-menu-other
yuuji@11 314 (if YaTeX-japan "':̃obt@̃x\n" "':LABEL IN OTHER BUFFER.\n"))
yuuji@23 315 (defvar YaTeX-label-menu-repeat
yuuji@23 316 (if YaTeX-japan ".:O\\refƓ\n" "/:REPEAT LAST \ref{}\n"))
yuuji@11 317 (defvar YaTeX-label-menu-any
yuuji@11 318 (if YaTeX-japan "*:Cӂ̕\n" "*:ANY STRING.\n"))
yuuji@11 319 (defvar YaTeX-label-buffer "*Label completions*")
yuuji@11 320 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
yuuji@11 321 (defvar YaTeX-label-select-map nil
yuuji@11 322 "Key map used in label selection buffer.")
yuuji@11 323 (defun YaTeX::label-setup-key-map ()
yuuji@11 324 (if YaTeX-label-select-map nil
yuuji@11 325 (message "Setting up label selection mode map...")
yuuji@68 326 ;(setq YaTeX-label-select-map (copy-keymap global-map))
yuuji@68 327 (setq YaTeX-label-select-map (make-keymap))
yuuji@11 328 (suppress-keymap YaTeX-label-select-map)
yuuji@11 329 (substitute-all-key-definition
yuuji@11 330 'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
yuuji@11 331 (substitute-all-key-definition
yuuji@11 332 'next-line 'YaTeX::label-next YaTeX-label-select-map)
yuuji@11 333 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next)
yuuji@11 334 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous)
yuuji@11 335 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer)
yuuji@11 336 (define-key YaTeX-label-select-map ">" 'end-of-buffer)
yuuji@11 337 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit)
yuuji@11 338 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit)
yuuji@11 339 (define-key YaTeX-label-select-map " " 'exit-recursive-edit)
yuuji@11 340 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit)
yuuji@11 341 (define-key YaTeX-label-select-map "/" 'isearch-forward)
yuuji@11 342 (define-key YaTeX-label-select-map "?" 'isearch-backward)
yuuji@11 343 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag)
yuuji@23 344 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag)
yuuji@11 345 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag)
yuuji@11 346 (message "Setting up label selection mode map...Done")
yuuji@11 347 (let ((key ?A))
yuuji@11 348 (while (<= key ?Z)
yuuji@11 349 (define-key YaTeX-label-select-map (char-to-string key)
yuuji@11 350 'YaTeX::label-search-tag)
yuuji@11 351 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
yuuji@11 352 'YaTeX::label-search-tag)
yuuji@69 353 (setq key (1+ key))))))
yuuji@69 354
yuuji@11 355 (defun YaTeX::label-next ()
yuuji@11 356 (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
yuuji@11 357 (defun YaTeX::label-previous ()
yuuji@11 358 (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
yuuji@11 359 (defun YaTeX::label-search-tag ()
yuuji@11 360 (interactive)
yuuji@68 361 (let ((case-fold-search t)
yuuji@68 362 (tag (regexp-quote (char-to-string last-command-char))))
yuuji@11 363 (cond
yuuji@11 364 ((save-excursion
yuuji@11 365 (forward-char 1)
yuuji@23 366 (re-search-forward (concat "^" tag) nil t))
yuuji@11 367 (goto-char (match-beginning 0)))
yuuji@11 368 ((save-excursion
yuuji@11 369 (goto-char (point-min))
yuuji@23 370 (re-search-forward (concat "^" tag) nil t))
yuuji@11 371 (goto-char (match-beginning 0))))
yuuji@69 372 (message YaTeX-label-guide-msg)))
yuuji@69 373
yuuji@70 374 ; (defun YaTeX::ref (argp &optional labelcmd refcmd)
yuuji@70 375 ; (cond
yuuji@70 376 ; ((= argp 1)
yuuji@70 377 ; (let ((lnum 0) e0 label label-list (buf (current-buffer))
yuuji@70 378 ; (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref"))
yuuji@70 379 ; (p (point)) initl line cf)
yuuji@70 380 ; (message "Collecting labels...")
yuuji@70 381 ; (save-window-excursion
yuuji@70 382 ; (YaTeX-showup-buffer
yuuji@70 383 ; YaTeX-label-buffer (function (lambda (x) (window-width x))))
yuuji@70 384 ; (if (fboundp 'select-frame) (setq cf (selected-frame)))
yuuji@70 385 ; (if (eq (window-buffer (minibuffer-window)) buf)
yuuji@70 386 ; (progn
yuuji@70 387 ; (other-window 1)
yuuji@70 388 ; (setq buf (current-buffer))
yuuji@70 389 ; (set-buffer buf)
yuuji@70 390 ; ;(message "cb=%s" buf)(sit-for 3)
yuuji@70 391 ; ))
yuuji@70 392 ; (save-excursion
yuuji@70 393 ; (set-buffer (get-buffer-create YaTeX-label-buffer))
yuuji@70 394 ; (setq buffer-read-only nil)
yuuji@70 395 ; (erase-buffer))
yuuji@70 396 ; (save-excursion
yuuji@70 397 ; (goto-char (point-min))
yuuji@70 398 ; (let ((standard-output (get-buffer YaTeX-label-buffer)))
yuuji@70 399 ; (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
yuuji@70 400 ; (while (YaTeX-re-search-active-forward
yuuji@70 401 ; (concat "\\\\" labelcmd "\\b")
yuuji@70 402 ; (regexp-quote YaTeX-comment-prefix) nil t)
yuuji@70 403 ; (goto-char (match-beginning 0))
yuuji@70 404 ; (skip-chars-forward "^{")
yuuji@70 405 ; (setq label
yuuji@70 406 ; (buffer-substring
yuuji@70 407 ; (1+ (point))
yuuji@70 408 ; (prog2 (forward-list 1) (setq e0 (1- (point)))))
yuuji@70 409 ; label-list (cons label label-list))
yuuji@70 410 ; (or initl
yuuji@70 411 ; (if (< p (point)) (setq initl lnum)))
yuuji@70 412 ; (beginning-of-line)
yuuji@70 413 ; (skip-chars-forward " \t\n" nil)
yuuji@70 414 ; (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
yuuji@70 415 ; (buffer-substring (point) (point-end-of-line))))
yuuji@70 416 ; (setq lnum (1+ lnum))
yuuji@70 417 ; (message "Collecting \\%s{}... %d" labelcmd lnum)
yuuji@70 418 ; (goto-char e0))
yuuji@70 419 ; (princ YaTeX-label-menu-other)
yuuji@70 420 ; (princ YaTeX-label-menu-repeat)
yuuji@70 421 ; (princ YaTeX-label-menu-any)
yuuji@70 422 ; );standard-output
yuuji@70 423 ; (goto-char p)
yuuji@70 424 ; (or initl (setq initl lnum))
yuuji@70 425 ; (message "Collecting %s...Done" labelcmd)
yuuji@70 426 ; (if (fboundp 'select-frame) (select-frame cf))
yuuji@70 427 ; (YaTeX-showup-buffer YaTeX-label-buffer nil t)
yuuji@70 428 ; (YaTeX::label-setup-key-map)
yuuji@70 429 ; (setq truncate-lines t)
yuuji@70 430 ; (setq buffer-read-only t)
yuuji@70 431 ; (use-local-map YaTeX-label-select-map)
yuuji@70 432 ; (message YaTeX-label-guide-msg)
yuuji@70 433 ; (goto-line (1+ initl)) ;goto recently defined label line
yuuji@70 434 ; (switch-to-buffer (current-buffer))
yuuji@70 435 ; (unwind-protect
yuuji@70 436 ; (progn
yuuji@70 437 ; (recursive-edit)
yuuji@70 438 ; (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
yuuji@70 439 ; (beginning-of-line)
yuuji@70 440 ; (setq line (1- (count-lines (point-min)(point))))
yuuji@70 441 ; (cond
yuuji@70 442 ; ((= line -1) (setq label ""))
yuuji@70 443 ; ((= line lnum) (setq label (YaTeX-label-other)))
yuuji@70 444 ; ((= line (1+ lnum))
yuuji@70 445 ; (save-excursion
yuuji@70 446 ; (switch-to-buffer buf)
yuuji@70 447 ; (goto-char p)
yuuji@70 448 ; (if (re-search-backward
yuuji@70 449 ; (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
yuuji@70 450 ; (setq label (YaTeX-match-string 1))
yuuji@70 451 ; (setq label ""))))
yuuji@70 452 ; ((>= line (+ lnum 2))
yuuji@70 453 ; (setq label (read-string (format "\\%s{???}: " refcmd))))
yuuji@70 454 ; (t (setq label (nth (- lnum line 1) label-list)))))
yuuji@70 455 ; (bury-buffer YaTeX-label-buffer)))
yuuji@70 456 ; label)))))
yuuji@70 457
yuuji@70 458 (defun YaTeX::ref-generate-label ()
yuuji@70 459 "Generate a label string which is unique in current buffer."
yuuji@70 460 (let ((default (substring (current-time-string) 4)))
yuuji@70 461 (read-string "Give a label for this line: "
yuuji@70 462 (if YaTeX-emacs-19 (cons default 1) default))))
yuuji@70 463
yuuji@70 464 (defun YaTeX::ref-getset-label (buffer point)
yuuji@70 465 "Get label string in the BUFFER near the POINT.
yuuji@70 466 Make \\label{xx} if no label."
yuuji@70 467 (let (boundary inspoint cc newlabel (labelholder "label") mathp env)
yuuji@70 468 ;(set-buffer buffer)
yuuji@70 469 (switch-to-buffer buffer)
yuuji@70 470 (save-excursion
yuuji@70 471 (goto-char point)
yuuji@70 472 (setq cc (current-column))
yuuji@70 473 (if (= (char-after (point)) ?\\) (forward-char 1))
yuuji@70 474 (cond
yuuji@70 475 ((looking-at YaTeX-sectioning-regexp)
yuuji@70 476 (skip-chars-forward "^{")
yuuji@70 477 (forward-list 1)
yuuji@70 478 (skip-chars-forward " \t\n")
yuuji@70 479 (setq boundary "\\S "))
yuuji@70 480 ((looking-at "item\\s ")
yuuji@70 481 (setq cc (+ cc 6))
yuuji@70 482 (setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")))
yuuji@70 483 ((looking-at "bibitem")
yuuji@70 484 (setq labelholder "bibitem")) ; label holder is bibitem itself
yuuji@70 485 ((string-match YaTeX::ref-mathenv-regexp
yuuji@70 486 (setq env (or (YaTeX-inner-environment t) "document")))
yuuji@70 487 (setq mathp t)
yuuji@70 488 (setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")))
yuuji@70 489 ((looking-at "caption\\|\\(begin\\)")
yuuji@70 490 (skip-chars-forward "^{")
yuuji@70 491 (if (match-beginning 1) (forward-list 1))
yuuji@70 492 (setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b")))
yuuji@70 493 (t ))
yuuji@70 494 (if (save-excursion (skip-chars-forward " \t") (looking-at "%"))
yuuji@70 495 (forward-line 1))
yuuji@70 496 (if (and (save-excursion
yuuji@70 497 (YaTeX-re-search-active-forward
yuuji@70 498 (concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
yuuji@70 499 (regexp-quote YaTeX-comment-prefix)
yuuji@70 500 nil 1))
yuuji@70 501 (match-beginning 1))
yuuji@70 502 ;; if \label{hoge} found, return it
yuuji@70 503 (buffer-substring
yuuji@70 504 (progn
yuuji@70 505 (goto-char (match-end 0))
yuuji@70 506 (skip-chars-forward "^{") (1+ (point)))
yuuji@70 507 (progn
yuuji@70 508 (forward-sexp 1) (1- (point))))
yuuji@70 509 ;;else make a label
yuuji@70 510 (goto-char (match-beginning 0))
yuuji@70 511 (skip-chars-backward " \t\n")
yuuji@70 512 (save-excursion (setq newlabel (YaTeX::ref-generate-label)))
yuuji@70 513 (delete-region (point) (progn (skip-chars-backward " \t") (point)))
yuuji@70 514 (if mathp nil
yuuji@70 515 (insert "\n")
yuuji@70 516 (YaTeX-reindent cc))
yuuji@70 517 (insert (format "\\label{%s}" newlabel))
yuuji@70 518 newlabel))))
yuuji@70 519
yuuji@70 520 (defvar YaTeX::ref-labeling-regexp-alist
yuuji@70 521 '(("\\\\begin{java}{\\([^}]+\\)}" . 1)
yuuji@70 522 ("\\\\elabel{\\([^}]+\\)}" . 1)))
yuuji@70 523 (defvar YaTeX::ref-labeling-regexp
yuuji@70 524 (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
yuuji@70 525 (defvar YaTeX::ref-mathenv-regexp
yuuji@70 526 "equation\\|eqnarray\\|align\\|gather\\|alignat\\|xalignat")
yuuji@70 527 (defvar YaTeX::ref-enumerateenv-regexp
yuuji@70 528 "enumerate")
yuuji@70 529
yuuji@70 530 (defvar YaTeX::ref-labeling-section-level 2
yuuji@70 531 "ref⊮ŎWZNVjOR}h̉x
yuuji@70 532 YaTeX-sectioning-level̐lŎw.")
yuuji@70 533
yuuji@48 534 (defun YaTeX::ref (argp &optional labelcmd refcmd)
yuuji@70 535 (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache
yuuji@70 536 (require 'yatexsec)
yuuji@11 537 (cond
yuuji@11 538 ((= argp 1)
yuuji@70 539 (let*((lnum 0) e0 x cmd label match-point point-list boundary
yuuji@70 540 (buf (current-buffer))
yuuji@70 541 (llv YaTeX::ref-labeling-section-level)
yuuji@70 542 (mathenvs YaTeX::ref-mathenv-regexp)
yuuji@70 543 (enums YaTeX::ref-enumerateenv-regexp)
yuuji@70 544 (counter
yuuji@70 545 (or labelcmd
yuuji@70 546 (concat
yuuji@70 547 YaTeX-ec-regexp "\\(\\("
yuuji@70 548 (mapconcat
yuuji@70 549 'concat
yuuji@70 550 (delq nil
yuuji@70 551 (mapcar
yuuji@70 552 (lambda (s)
yuuji@70 553 (if (>= llv (cdr s))
yuuji@70 554 (car s)))
yuuji@70 555 YaTeX-sectioning-level))
yuuji@70 556 "\\|")
yuuji@70 557 "\\|caption\\){"
yuuji@70 558 "\\|\\(begin{\\(" mathenvs "\\|" enums "\\)\\)\\)")))
yuuji@70 559 (regexp (concat "\\(" counter
yuuji@70 560 "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
yuuji@70 561 (itemsep (concat YaTeX-ec-regexp
yuuji@70 562 "\\(\\(bib\\)?item\\|begin\\|end\\)"))
yuuji@70 563 (refcmd (or refcmd "ref"))
yuuji@70 564 (p (point)) initl line cf
yuuji@70 565 (percent (regexp-quote YaTeX-comment-prefix))
yuuji@70 566 (output
yuuji@70 567 (function
yuuji@70 568 (lambda (label p)
yuuji@70 569 (while (setq x (string-match "\n" label))
yuuji@70 570 (aset label x ? ))
yuuji@70 571 (while (setq x (string-match "[ \t\n][ \t\n]+" label))
yuuji@70 572 (setq label (concat
yuuji@70 573 (substring label 0 (1+ (match-beginning 0)))
yuuji@70 574 (substring label (match-end 0)))))
yuuji@70 575 (princ (format "%c: <<%s>>\n" (+ (% lnum 26) ?A) label))
yuuji@70 576 (setq point-list (cons p point-list))
yuuji@70 577 (message "Collecting labels... %d" lnum)
yuuji@70 578 (setq lnum (1+ lnum)))))
yuuji@70 579 )
yuuji@60 580 (message "Collecting labels...")
yuuji@60 581 (save-window-excursion
yuuji@60 582 (YaTeX-showup-buffer
yuuji@60 583 YaTeX-label-buffer (function (lambda (x) (window-width x))))
yuuji@60 584 (if (fboundp 'select-frame) (setq cf (selected-frame)))
yuuji@60 585 (if (eq (window-buffer (minibuffer-window)) buf)
yuuji@60 586 (progn
yuuji@60 587 (other-window 1)
yuuji@60 588 (setq buf (current-buffer))
yuuji@70 589 (set-buffer buf)))
yuuji@60 590 (save-excursion
yuuji@69 591 (set-buffer (get-buffer-create YaTeX-label-buffer))
yuuji@69 592 (setq buffer-read-only nil)
yuuji@69 593 (erase-buffer))
yuuji@69 594 (save-excursion
yuuji@70 595 (set-buffer buf)
yuuji@60 596 (goto-char (point-min))
yuuji@69 597 (let ((standard-output (get-buffer YaTeX-label-buffer)))
yuuji@60 598 (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
yuuji@48 599 (while (YaTeX-re-search-active-forward
yuuji@70 600 regexp ;;counter
yuuji@70 601 percent nil t)
yuuji@70 602 ;(goto-char (match-beginning 0))
yuuji@70 603 (setq e0 (match-end 0))
yuuji@70 604 (cond
yuuji@70 605 ((match-string 1)
yuuji@70 606 ;;if standard counter commands found
yuuji@70 607 (setq cmd (YaTeX-match-string 2))
yuuji@70 608 (setq match-point (match-beginning 0))
yuuji@70 609 (or initl
yuuji@70 610 (if (< p (point)) (setq initl lnum)))
yuuji@70 611 (cond
yuuji@70 612 ((string-match mathenvs cmd) ;;if matches mathematical env
yuuji@70 613 ;(skip-chars-forward "} \t\n")
yuuji@70 614 (forward-line 1)
yuuji@70 615 (setq x (point))
yuuji@70 616 (catch 'scan
yuuji@70 617 (while (YaTeX-re-search-active-forward
yuuji@70 618 (concat "\\\\\\\\$\\|\\\\end{\\(" mathenvs "\\)")
yuuji@70 619 percent nil t)
yuuji@70 620 (let ((quit (match-beginning 1)))
yuuji@70 621 (funcall output
yuuji@70 622 (buffer-substring x (match-beginning 0))
yuuji@70 623 x)
yuuji@70 624 (if quit (throw 'scan t)))
yuuji@70 625 (setq x (point))))
yuuji@70 626 (setq e0 (point)))
yuuji@70 627 ((string-match enums cmd)
yuuji@70 628 ;(skip-chars-forward "} \t\n")
yuuji@70 629 (save-restriction
yuuji@70 630 (narrow-to-region
yuuji@70 631 (point)
yuuji@70 632 (save-excursion
yuuji@70 633 (YaTeX-goto-corresponding-environment) (point)))
yuuji@70 634 (forward-line 1)
yuuji@70 635 (while (YaTeX-re-search-active-forward
yuuji@70 636 (concat YaTeX-ec-regexp "item\\s ")
yuuji@70 637 percent nil t)
yuuji@70 638 (setq x (match-beginning 0))
yuuji@70 639 (funcall
yuuji@70 640 output
yuuji@70 641 (buffer-substring
yuuji@70 642 (match-beginning 0)
yuuji@70 643 (if (re-search-forward itemsep nil t)
yuuji@70 644 (progn (goto-char (match-beginning 0))
yuuji@70 645 (skip-chars-backward " \t")
yuuji@70 646 (1- (point)))
yuuji@70 647 (point-end-of-line)))
yuuji@70 648 x))))
yuuji@70 649
yuuji@70 650 ((= (char-after (1- (point))) ?{)
yuuji@70 651 (setq label (buffer-substring
yuuji@70 652 (match-beginning 0)
yuuji@70 653 (progn (forward-char -1)
yuuji@70 654 (forward-list 1)
yuuji@70 655 (point))))
yuuji@70 656 (funcall output label match-point))
yuuji@70 657 (t
yuuji@70 658 (skip-chars-forward " \t")
yuuji@70 659 (setq label (buffer-substring
yuuji@70 660 (match-beginning 0)
yuuji@70 661 (if (re-search-forward
yuuji@70 662 itemsep
yuuji@70 663 nil t)
yuuji@70 664 (progn
yuuji@70 665 (goto-char (match-beginning 0))
yuuji@70 666 (skip-chars-backward " \t")
yuuji@70 667 (1- (point)))
yuuji@70 668 (point-end-of-line))))
yuuji@70 669 (funcall output label match-point)
yuuji@70 670 ))
yuuji@70 671 ) ;;put label buffer
yuuji@70 672 ;;
yuuji@70 673 ;; if user defined label found
yuuji@70 674 (t
yuuji@70 675 ;; memorize line number and label into property
yuuji@70 676 (goto-char (match-beginning 0))
yuuji@70 677 (let ((list YaTeX::ref-labeling-regexp-alist)
yuuji@70 678 (cache (symbol-plist 'YaTeX::ref-labeling-regexp)))
yuuji@70 679 (while list
yuuji@70 680 (if (looking-at (car (car list)))
yuuji@70 681 (progn
yuuji@70 682 (setq label (YaTeX-match-string 0))
yuuji@70 683 (put 'YaTeX::ref-labeling-regexp lnum
yuuji@70 684 (YaTeX-match-string (cdr (car list))))
yuuji@70 685 (funcall output label 0) ;;0 is dummy, never used
yuuji@70 686 (setq list nil)))
yuuji@70 687 (setq list (cdr list))))
yuuji@70 688 ))
yuuji@11 689 (goto-char e0))
yuuji@11 690 (princ YaTeX-label-menu-other)
yuuji@23 691 (princ YaTeX-label-menu-repeat)
yuuji@11 692 (princ YaTeX-label-menu-any)
yuuji@69 693 );standard-output
yuuji@11 694 (goto-char p)
yuuji@60 695 (or initl (setq initl lnum))
yuuji@70 696 (message "Collecting labels...Done")
yuuji@60 697 (if (fboundp 'select-frame) (select-frame cf))
yuuji@59 698 (YaTeX-showup-buffer YaTeX-label-buffer nil t)
yuuji@11 699 (YaTeX::label-setup-key-map)
yuuji@11 700 (setq truncate-lines t)
yuuji@11 701 (setq buffer-read-only t)
yuuji@11 702 (use-local-map YaTeX-label-select-map)
yuuji@11 703 (message YaTeX-label-guide-msg)
yuuji@60 704 (goto-line (1+ initl)) ;goto recently defined label line
yuuji@68 705 (switch-to-buffer (current-buffer))
yuuji@11 706 (unwind-protect
yuuji@11 707 (progn
yuuji@11 708 (recursive-edit)
yuuji@70 709
yuuji@11 710 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
yuuji@11 711 (beginning-of-line)
yuuji@60 712 (setq line (1- (count-lines (point-min)(point))))
yuuji@11 713 (cond
yuuji@60 714 ((= line -1) (setq label ""))
yuuji@11 715 ((= line lnum) (setq label (YaTeX-label-other)))
yuuji@23 716 ((= line (1+ lnum))
yuuji@23 717 (save-excursion
yuuji@23 718 (switch-to-buffer buf)
yuuji@23 719 (goto-char p)
yuuji@48 720 (if (re-search-backward
yuuji@48 721 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
yuuji@48 722 (setq label (YaTeX-match-string 1))
yuuji@23 723 (setq label ""))))
yuuji@23 724 ((>= line (+ lnum 2))
yuuji@48 725 (setq label (read-string (format "\\%s{???}: " refcmd))))
yuuji@70 726 (t ;(setq label (nth (- lnum line 1) label-list))
yuuji@70 727 (setq label
yuuji@70 728 (or (get 'YaTeX::ref-labeling-regexp line)
yuuji@70 729 (YaTeX::ref-getset-label
yuuji@70 730 buf (nth (- lnum line 1) point-list))))
yuuji@70 731 )))
yuuji@11 732 (bury-buffer YaTeX-label-buffer)))
yuuji@69 733 label)))))
yuuji@69 734
yuuji@16 735 (fset 'YaTeX::pageref 'YaTeX::ref)
yuuji@70 736
yuuji@70 737 (defun YaTeX::cite-collect-bibs-external (&rest files)
yuuji@70 738 "Collect bibentry from FILES(variable length argument);
yuuji@70 739 and print them to standard output."
yuuji@70 740 ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html
yuuji@70 741 (let ((tb (get-buffer-create " *bibtmp*")))
yuuji@70 742 (save-excursion
yuuji@70 743 (set-buffer tb)
yuuji@70 744 (while files
yuuji@70 745 (erase-buffer)
yuuji@70 746 (cond
yuuji@70 747 ((file-exists-p (car files))
yuuji@70 748 (insert-file-contents (car files)))
yuuji@70 749 ((file-exists-p (concat (car files) ".bib"))
yuuji@70 750 (insert-file-contents (concat (car files) ".bib"))))
yuuji@70 751 (save-excursion
yuuji@70 752 (goto-char (point-min))
yuuji@70 753 (while (re-search-forward "^\\s *@[A-Za-z]" nil t)
yuuji@70 754 (skip-chars-forward "^{,")
yuuji@70 755 (if (= (char-after (point)) ?{)
yuuji@70 756 (princ (format "%sbibitem{%s}%s\n"
yuuji@70 757 YaTeX-ec
yuuji@70 758 (buffer-substring
yuuji@70 759 (1+ (point))
yuuji@70 760 (progn (skip-chars-forward "^,\n")
yuuji@70 761 (point)))
yuuji@70 762 (if (re-search-forward "title\\s *=" nil t)
yuuji@70 763 (buffer-substring
yuuji@70 764 (progn
yuuji@70 765 (goto-char (match-end 0))
yuuji@70 766 (skip-chars-forward " \t\n")
yuuji@70 767 (point))
yuuji@70 768 (progn
yuuji@70 769 (if (looking-at "[{\"]")
yuuji@70 770 (forward-sexp 1)
yuuji@70 771 (forward-char 1)
yuuji@70 772 (skip-chars-forward "^,"))
yuuji@70 773 (point)))))))))
yuuji@70 774 (setq files (cdr files))))))
yuuji@70 775
yuuji@70 776 (defun YaTeX::cite-collect-bibs-internal ()
yuuji@70 777 "Collect bibentry in the current buffer and print them to standard output."
yuuji@70 778 (let ((ptn (concat YaTeX-ec-regexp "bibitem\\b"))
yuuji@70 779 (pcnt (regexp-quote YaTeX-comment-prefix)))
yuuji@70 780 (save-excursion
yuuji@70 781 (while (YaTeX-re-search-active-forward ptn pcnt nil t)
yuuji@70 782 (skip-chars-forward "^{\n")
yuuji@70 783 (or (eolp)
yuuji@70 784 (princ (format "%sbibitem{%s}\n"
yuuji@70 785 YaTeX-ec
yuuji@70 786 (buffer-substring
yuuji@70 787 (1+ (point))
yuuji@70 788 (progn (forward-sexp 1) (point))))))))))
yuuji@70 789
yuuji@48 790 (defun YaTeX::cite (argp)
yuuji@48 791 (cond
yuuji@48 792 ((eq argp 1)
yuuji@70 793 (let* ((cb (current-buffer))
yuuji@70 794 (f (file-name-nondirectory buffer-file-name))
yuuji@70 795 (d default-directory)
yuuji@70 796 (hilit-auto-highlight nil)
yuuji@70 797 (pcnt (regexp-quote YaTeX-comment-prefix))
yuuji@70 798 (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}"))
yuuji@70 799 (bbuf (get-buffer-create " *bibitems*"))
yuuji@70 800 (standard-output bbuf)
yuuji@70 801 bibs files)
yuuji@70 802 (set-buffer bbuf)(erase-buffer)(set-buffer cb)
yuuji@70 803 (save-excursion
yuuji@70 804 (goto-char (point-min))
yuuji@70 805 ;;(1)search external bibdata
yuuji@70 806 (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
yuuji@70 807 (apply 'YaTeX::cite-collect-bibs-external
yuuji@70 808 (YaTeX-split-string
yuuji@70 809 (YaTeX-match-string 1) ",")))
yuuji@70 810 ;;(2)search direct \bibitem usage
yuuji@70 811 (YaTeX::cite-collect-bibs-internal)
yuuji@70 812 (if (progn
yuuji@70 813 (YaTeX-visit-main t)
yuuji@70 814 (not (eq (current-buffer) cb)))
yuuji@70 815 (save-excursion
yuuji@70 816 (goto-char (point-min))
yuuji@70 817 ;;(1)search external bibdata
yuuji@70 818 (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
yuuji@70 819 (apply 'YaTeX::cite-collect-bibs-external
yuuji@70 820 (YaTeX-split-string
yuuji@70 821 (YaTeX-match-string 1) ",")))
yuuji@70 822 ;;(2)search internal
yuuji@70 823 (YaTeX::cite-collect-bibs-internal)))
yuuji@70 824 ;;Now bbuf holds the list of bibitem
yuuji@70 825 (set-buffer bbuf)
yuuji@70 826 (YaTeX::ref argp "\\\\\\(bibitem\\)\\(\\[.*\\]\\)?" "cite"))))
yuuji@70 827
yuuji@48 828 (t nil)))
yuuji@11 829
yuuji@70 830 (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref))
yuuji@70 831
yuuji@48 832 (defun YaTeX-yatex-buffer-list ()
yuuji@48 833 (save-excursion
yuuji@48 834 (delq nil (mapcar (function (lambda (buf)
yuuji@48 835 (set-buffer buf)
yuuji@48 836 (if (eq major-mode 'yatex-mode) buf)))
yuuji@69 837 (buffer-list)))))
yuuji@48 838
yuuji@48 839 (defun YaTeX-select-other-yatex-buffer ()
yuuji@48 840 "Select buffer from all yatex-mode's buffers interactivelly."
yuuji@48 841 (interactive)
yuuji@48 842 (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list))
yuuji@48 843 (lnum -1) buf rv
yuuji@11 844 (ff "**find-file**"))
yuuji@12 845 (YaTeX-showup-buffer
yuuji@12 846 lbuf (function (lambda (x) 1))) ;;Select next window surely.
yuuji@69 847 (save-excursion
yuuji@69 848 (set-buffer (get-buffer lbuf))
yuuji@69 849 (setq buffer-read-only nil)
yuuji@69 850 (erase-buffer))
yuuji@69 851 (let ((standard-output (get-buffer lbuf)))
yuuji@11 852 (while blist
yuuji@48 853 (princ
yuuji@48 854 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
yuuji@48 855 (buffer-name (car blist))))
yuuji@11 856 (setq blist (cdr blist)))
yuuji@11 857 (princ (format "':{%s}" ff)))
yuuji@59 858 (YaTeX-showup-buffer lbuf nil t)
yuuji@11 859 (YaTeX::label-setup-key-map)
yuuji@11 860 (setq buffer-read-only t)
yuuji@11 861 (use-local-map YaTeX-label-select-map)
yuuji@11 862 (message YaTeX-label-guide-msg)
yuuji@11 863 (unwind-protect
yuuji@11 864 (progn
yuuji@11 865 (recursive-edit)
yuuji@11 866 (set-buffer lbuf)
yuuji@11 867 (beginning-of-line)
yuuji@11 868 (setq rv
yuuji@11 869 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
yuuji@11 870 (buffer-substring (match-beginning 1) (match-end 1)) nil)))
yuuji@11 871 (kill-buffer lbuf))
yuuji@48 872 (if (string= rv ff)
yuuji@48 873 (progn
yuuji@48 874 (call-interactively 'find-file)
yuuji@48 875 (current-buffer))
yuuji@69 876 rv)))
yuuji@48 877
yuuji@48 878 (defun YaTeX-label-other ()
yuuji@48 879 (let ((rv (YaTeX-select-other-yatex-buffer)))
yuuji@11 880 (cond
yuuji@11 881 ((null rv) "")
yuuji@11 882 (t
yuuji@11 883 (set-buffer rv)
yuuji@69 884 (YaTeX::ref argp labelcmd refcmd)))))
yuuji@11 885
yuuji@13 886 ;;
yuuji@13 887 ; completion for the arguments of \newcommand
yuuji@13 888 ;;
yuuji@13 889 (defun YaTeX::newcommand (&optional argp)
yuuji@13 890 (cond
yuuji@13 891 ((= argp 1)
yuuji@13 892 (let ((command (read-string "Define newcommand: " "\\")))
yuuji@13 893 (put 'YaTeX::newcommand 'command (substring command 1))
yuuji@13 894 command))
yuuji@13 895 ((= argp 2)
yuuji@13 896 (let ((argc
yuuji@13 897 (string-to-int (read-string "Number of arguments(Default 0): ")))
yuuji@13 898 (def (read-string "Definition: "))
yuuji@13 899 (command (get 'YaTeX::newcommand 'command)))
yuuji@13 900 ;;!!! It's illegal to insert string in the add-in function !!!
yuuji@13 901 (if (> argc 0) (insert (format "[%d]" argc)))
yuuji@13 902 (if (and (stringp command)
yuuji@13 903 (string< "" command)
yuuji@51 904 (y-or-n-p "Update dictionary?"))
yuuji@18 905 (cond
yuuji@18 906 ((= argc 0)
yuuji@18 907 (YaTeX-update-table
yuuji@18 908 (list command)
yuuji@18 909 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table))
yuuji@18 910 ((= argc 1)
yuuji@18 911 (YaTeX-update-table
yuuji@18 912 (list command)
yuuji@18 913 'section-table 'user-section-table 'tmp-section-table))
yuuji@18 914 (t (YaTeX-update-table
yuuji@18 915 (list command argc)
yuuji@18 916 'section-table 'user-section-table 'tmp-section-table))))
yuuji@13 917 (message "")
yuuji@13 918 def ;return command name
yuuji@13 919 ))
yuuji@69 920 (t "")))
yuuji@13 921
yuuji@16 922 ;;
yuuji@16 923 ; completion for the arguments of \pagestyle
yuuji@16 924 ;;
yuuji@16 925 (defun YaTeX::pagestyle (&optional argp)
yuuji@16 926 "Read the pagestyle with completion."
yuuji@16 927 (completing-read
yuuji@16 928 "Page style: "
yuuji@69 929 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil)))
yuuji@69 930
yuuji@51 931 (fset 'YaTeX::thispagestyle 'YaTeX::pagestyle)
yuuji@51 932
yuuji@16 933 ;;
yuuji@16 934 ; completion for the arguments of \pagenumbering
yuuji@16 935 ;;
yuuji@16 936 (defun YaTeX::pagenumbering (&optional argp)
yuuji@16 937 "Read the numbering style."
yuuji@16 938 (completing-read
yuuji@16 939 "Page numbering style: "
yuuji@69 940 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))))
yuuji@13 941
yuuji@23 942 ;;
yuuji@23 943 ; Length
yuuji@23 944 ;;
yuuji@23 945 (defvar YaTeX:style-parameters-default
yuuji@23 946 '(("\\arraycolsep")
yuuji@23 947 ("\\arrayrulewidth")
yuuji@23 948 ("\\baselineskip")
yuuji@23 949 ("\\columnsep")
yuuji@23 950 ("\\columnseprule")
yuuji@23 951 ("\\doublerulesep")
yuuji@23 952 ("\\evensidemargin")
yuuji@23 953 ("\\footheight")
yuuji@23 954 ("\\footskip")
yuuji@23 955 ("\\headheight")
yuuji@23 956 ("\\headsep")
yuuji@23 957 ("\\itemindent")
yuuji@23 958 ("\\itemsep")
yuuji@23 959 ("\\labelsep")
yuuji@23 960 ("\\labelwidth")
yuuji@23 961 ("\\leftmargin")
yuuji@23 962 ("\\linewidth")
yuuji@23 963 ("\\listparindent")
yuuji@23 964 ("\\marginparsep")
yuuji@23 965 ("\\marginparwidth")
yuuji@23 966 ("\\mathindent")
yuuji@23 967 ("\\oddsidemargin")
yuuji@23 968 ("\\parindent")
yuuji@23 969 ("\\parsep")
yuuji@23 970 ("\\parskip")
yuuji@23 971 ("\\partopsep")
yuuji@23 972 ("\\rightmargin")
yuuji@23 973 ("\\tabcolsep")
yuuji@23 974 ("\\textheight")
yuuji@23 975 ("\\textwidth")
yuuji@23 976 ("\\topmargin")
yuuji@23 977 ("\\topsep")
yuuji@23 978 ("\\topskip")
yuuji@23 979 )
yuuji@23 980 "Alist of LaTeX style parameters.")
yuuji@23 981 (defvar YaTeX:style-parameters-private nil
yuuji@23 982 "*User definable alist of style parameters.")
yuuji@49 983 (defvar YaTeX:style-parameters-local nil
yuuji@49 984 "*User definable alist of local style parameters.")
yuuji@23 985
yuuji@23 986 (defvar YaTeX:length-history nil "Holds history of length.")
yuuji@51 987 (put 'YaTeX:length-history 'no-default t)
yuuji@23 988 (defun YaTeX::setlength (&optional argp)
yuuji@23 989 "YaTeX add-in function for arguments of \\setlength."
yuuji@23 990 (cond
yuuji@23 991 ((equal 1 argp)
yuuji@49 992 ;;(completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")
yuuji@49 993 (YaTeX-cplread-with-learning
yuuji@49 994 "Length variable: "
yuuji@49 995 'YaTeX:style-parameters-default
yuuji@49 996 'YaTeX:style-parameters-private
yuuji@49 997 'YaTeX:style-parameters-local
yuuji@49 998 nil nil "\\")
yuuji@49 999 )
yuuji@23 1000 ((equal 2 argp)
yuuji@69 1001 (read-string-with-history "Length: " nil 'YaTeX:length-history))))
yuuji@69 1002
yuuji@23 1003 (fset 'YaTeX::addtolength 'YaTeX::setlength)
yuuji@23 1004
yuuji@23 1005 (defun YaTeX::settowidth (&optional argp)
yuuji@23 1006 "YaTeX add-in function for arguments of \\settowidth."
yuuji@23 1007 (cond
yuuji@23 1008 ((equal 1 argp)
yuuji@49 1009 (YaTeX-cplread-with-learning
yuuji@49 1010 "Length variable: "
yuuji@49 1011 'YaTeX:style-parameters-default
yuuji@49 1012 'YaTeX:style-parameters-private
yuuji@49 1013 'YaTeX:style-parameters-local
yuuji@49 1014 nil nil "\\"))
yuuji@23 1015 ((equal 2 argp)
yuuji@69 1016 (read-string "Text: "))))
yuuji@69 1017
yuuji@23 1018 (defun YaTeX::newlength (&optional argp)
yuuji@23 1019 "YaTeX add-in function for arguments of \\newlength"
yuuji@23 1020 (cond
yuuji@23 1021 ((equal argp 1)
yuuji@23 1022 (let ((length (read-string "Length variable: " "\\")))
yuuji@49 1023 (if (string< "" length)
yuuji@49 1024 (YaTeX-update-table
yuuji@49 1025 (list length)
yuuji@49 1026 'YaTeX:style-parameters-default
yuuji@49 1027 'YaTeX:style-parameters-private
yuuji@49 1028 'YaTeX:style-parameters-local))
yuuji@69 1029 length))))
yuuji@23 1030
yuuji@23 1031 ;; \multicolumn's arguments
yuuji@23 1032 (defun YaTeX::multicolumn (&optional argp)
yuuji@23 1033 "YaTeX add-in function for arguments of \\multicolumn."
yuuji@23 1034 (cond
yuuji@23 1035 ((equal 1 argp)
yuuji@23 1036 (read-string "Number of columns: "))
yuuji@23 1037 ((equal 2 argp)
yuuji@23 1038 (let (c)
yuuji@23 1039 (while (not (string-match
yuuji@23 1040 (progn (message "Format(one of l,r,c): ")
yuuji@23 1041 (setq c (char-to-string (read-char))))
yuuji@23 1042 "lrc")))
yuuji@23 1043 c))
yuuji@23 1044 ((equal 3 argp)
yuuji@69 1045 (read-string "Item: "))))
yuuji@23 1046
yuuji@49 1047 (defvar YaTeX:documentstyles-default
yuuji@49 1048 '(("article") ("jarticle") ("j-article")
yuuji@49 1049 ("book") ("jbook") ("j-book")
yuuji@49 1050 ("report") ("jreport") ("j-report")
yuuji@49 1051 ("letter") ("ascjletter"))
yuuji@49 1052 "List of LaTeX documentstyles.")
yuuji@49 1053 (defvar YaTeX:documentstyles-private nil
yuuji@49 1054 "*User defined list of LaTeX documentstyles.")
yuuji@49 1055 (defvar YaTeX:documentstyles-local nil
yuuji@49 1056 "*User defined list of local LaTeX documentstyles.")
yuuji@49 1057 (defvar YaTeX:documentstyle-options-default
yuuji@49 1058 '(("a4j") ("a5j") ("b4j") ("b5j")
yuuji@49 1059 ("twocolumn") ("jtwocolumn") ("epsf") ("epsfig") ("epsbox") ("nfig"))
yuuji@49 1060 "List of LaTeX documentstyle options.")
yuuji@49 1061 (defvar YaTeX:documentstyle-options-private nil
yuuji@49 1062 "*User defined list of LaTeX documentstyle options.")
yuuji@49 1063 (defvar YaTeX:documentstyle-options-local nil
yuuji@49 1064 "List of LaTeX local documentstyle options.")
yuuji@49 1065
yuuji@49 1066 (defvar YaTeX-minibuffer-completion-map nil
yuuji@49 1067 "Minibuffer completion key map that allows comma completion.")
yuuji@49 1068 (if YaTeX-minibuffer-completion-map nil
yuuji@49 1069 (setq YaTeX-minibuffer-completion-map
yuuji@49 1070 (copy-keymap minibuffer-local-completion-map))
yuuji@49 1071 (define-key YaTeX-minibuffer-completion-map " "
yuuji@49 1072 'YaTeX-minibuffer-complete)
yuuji@49 1073 (define-key YaTeX-minibuffer-completion-map "\t"
yuuji@49 1074 'YaTeX-minibuffer-complete))
yuuji@49 1075
yuuji@49 1076 (defun YaTeX:documentstyle ()
yuuji@49 1077 (let*((delim ",")
yuuji@49 1078 (dt (append YaTeX:documentstyle-options-local
yuuji@49 1079 YaTeX:documentstyle-options-private
yuuji@49 1080 YaTeX:documentstyle-options-default))
yuuji@49 1081 (minibuffer-completion-table dt)
yuuji@49 1082 (opt (read-from-minibuffer
yuuji@49 1083 "Style options ([opt1,opt2,...]): "
yuuji@51 1084 nil YaTeX-minibuffer-completion-map nil))
yuuji@49 1085 (substr opt) o)
yuuji@49 1086 (if (string< "" opt)
yuuji@49 1087 (progn
yuuji@49 1088 (while substr
yuuji@49 1089 (setq o (substring substr 0 (string-match delim substr)))
yuuji@49 1090 (or (assoc o dt)
yuuji@49 1091 (YaTeX-update-table
yuuji@49 1092 (list o)
yuuji@49 1093 'YaTeX:documentstyle-options-default
yuuji@49 1094 'YaTeX:documentstyle-options-private
yuuji@49 1095 'YaTeX:documentstyle-options-local))
yuuji@49 1096 (setq substr
yuuji@49 1097 (if (string-match delim substr)
yuuji@49 1098 (substring substr (1+ (string-match delim substr))))))
yuuji@49 1099 (concat "[" opt "]"))
yuuji@49 1100 "")))
yuuji@49 1101
yuuji@49 1102 (defun YaTeX::documentstyle (&optional argp)
yuuji@51 1103 "YaTeX add-in function for arguments of \\documentstyle."
yuuji@49 1104 (cond
yuuji@49 1105 ((equal argp 1)
yuuji@51 1106 (setq env-name "document")
yuuji@49 1107 (let ((sname
yuuji@49 1108 (YaTeX-cplread-with-learning
yuuji@49 1109 (format "Documentstyle (default %s): "
yuuji@49 1110 YaTeX-default-document-style)
yuuji@49 1111 'YaTeX:documentstyles-default
yuuji@49 1112 'YaTeX:documentstyles-private
yuuji@49 1113 'YaTeX:documentstyles-local)))
yuuji@49 1114 (if (string= "" sname) (setq sname YaTeX-default-document-style))
yuuji@69 1115 (setq YaTeX-default-document-style sname)))))
yuuji@49 1116
yuuji@57 1117 ;;; -------------------- LaTeX2e stuff --------------------
yuuji@57 1118 (defvar YaTeX:documentclass-options-default
yuuji@70 1119 '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt")
yuuji@57 1120 ("latterpaper") ("legalpaper") ("executivepaper") ("landscape")
yuuji@57 1121 ("oneside") ("twoside") ("draft") ("final") ("leqno") ("fleqn") ("openbib")
yuuji@70 1122 ("tombow") ("titlepage") ("notitlepage") ("dvips")
yuuji@57 1123 ("clock") ;for slides class only
yuuji@57 1124 )
yuuji@57 1125 "Default options list for documentclass")
yuuji@57 1126 (defvar YaTeX:documentclass-options-private nil
yuuji@57 1127 "*User defined options list for documentclass")
yuuji@57 1128 (defvar YaTeX:documentclass-options-local nil
yuuji@57 1129 "*User defined options list for local documentclass")
yuuji@57 1130
yuuji@57 1131 (defun YaTeX:documentclass ()
yuuji@57 1132 (let*((delim ",")
yuuji@57 1133 (dt (append YaTeX:documentclass-options-local
yuuji@57 1134 YaTeX:documentclass-options-private
yuuji@57 1135 YaTeX:documentclass-options-default))
yuuji@57 1136 (minibuffer-completion-table dt)
yuuji@57 1137 (opt (read-from-minibuffer
yuuji@57 1138 "Documentclass options ([opt1,opt2,...]): "
yuuji@57 1139 nil YaTeX-minibuffer-completion-map nil))
yuuji@57 1140 (substr opt) o)
yuuji@57 1141 (if (string< "" opt)
yuuji@57 1142 (progn
yuuji@57 1143 (while substr
yuuji@70 1144
yuuji@57 1145 (setq o (substring substr 0 (string-match delim substr)))
yuuji@57 1146 (or (assoc o dt)
yuuji@57 1147 (YaTeX-update-table
yuuji@57 1148 (list o)
yuuji@57 1149 'YaTeX:documentclass-options-default
yuuji@57 1150 'YaTeX:documentclass-options-private
yuuji@57 1151 'YaTeX:documentclass-options-local))
yuuji@57 1152 (setq substr
yuuji@57 1153 (if (string-match delim substr)
yuuji@57 1154 (substring substr (1+ (string-match delim substr))))))
yuuji@57 1155 (concat "[" opt "]"))
yuuji@57 1156 "")))
yuuji@57 1157
yuuji@57 1158 (defvar YaTeX:documentclasses-default
yuuji@57 1159 '(("article") ("jarticle") ("report") ("jreport") ("book") ("jbook")
yuuji@57 1160 ("j-article") ("j-report") ("j-book")
yuuji@57 1161 ("letter") ("slides") ("ltxdoc") ("ltxguide") ("ltnews") ("proc"))
yuuji@57 1162 "Default documentclass alist")
yuuji@57 1163 (defvar YaTeX:documentclasses-private nil
yuuji@57 1164 "*User defined documentclass alist")
yuuji@57 1165 (defvar YaTeX:documentclasses-local nil
yuuji@57 1166 "*User defined local documentclass alist")
yuuji@57 1167 (defvar YaTeX-default-documentclass (if YaTeX-japan "jarticle" "article")
yuuji@57 1168 "*Default documentclass")
yuuji@57 1169
yuuji@57 1170 (defun YaTeX::documentclass (&optional argp)
yuuji@57 1171 (cond
yuuji@57 1172 ((equal argp 1)
yuuji@57 1173 (setq env-name "document")
yuuji@57 1174 (let ((sname
yuuji@57 1175 (YaTeX-cplread-with-learning
yuuji@57 1176 (format "Documentclass (default %s): " YaTeX-default-documentclass)
yuuji@57 1177 'YaTeX:documentclasses-default
yuuji@57 1178 'YaTeX:documentclasses-private
yuuji@57 1179 'YaTeX:documentclasses-local)))
yuuji@57 1180 (if (string= "" sname) (setq sname YaTeX-default-documentclass))
yuuji@57 1181 (setq YaTeX-default-documentclass sname)))))
yuuji@57 1182
yuuji@70 1183 (defvar YaTeX:latex2e-named-color-alist
yuuji@70 1184 '(("GreenYellow") ("Yellow") ("Goldenrod") ("Dandelion") ("Apricot")
yuuji@70 1185 ("Peach") ("Melon") ("YellowOrange") ("Orange") ("BurntOrange")
yuuji@70 1186 ("Bittersweet") ("RedOrange") ("Mahogany") ("Maroon") ("BrickRed")
yuuji@70 1187 ("Red") ("OrangeRed") ("RubineRed") ("WildStrawberry") ("Salmon")
yuuji@70 1188 ("CarnationPink") ("Magenta") ("VioletRed") ("Rhodamine") ("Mulberry")
yuuji@70 1189 ("RedViolet") ("Fuchsia") ("Lavender") ("Thistle") ("Orchid")("DarkOrchid")
yuuji@70 1190 ("Purple") ("Plum") ("Violet") ("RoyalPurple") ("BlueViolet")
yuuji@70 1191 ("Periwinkle") ("CadetBlue") ("CornflowerBlue") ("MidnightBlue")
yuuji@70 1192 ("NavyBlue") ("RoyalBlue") ("Blue") ("Cerulean") ("Cyan") ("ProcessBlue")
yuuji@70 1193 ("SkyBlue") ("Turquoise") ("TealBlue") ("Aquamarine") ("BlueGreen")
yuuji@70 1194 ("Emerald") ("JungleGreen") ("SeaGreen") ("Green") ("ForestGreen")
yuuji@70 1195 ("PineGreen") ("LimeGreen") ("YellowGreen") ("SpringGreen") ("OliveGreen")
yuuji@70 1196 ("RawSienna") ("Sepia") ("Brown") ("Tan") ("Gray") ("Black") ("White"))
yuuji@70 1197 "Colors defined in $TEXMF/tex/plain/colordvi.tex")
yuuji@70 1198
yuuji@70 1199 (defvar YaTeX:latex2e-basic-color-alist
yuuji@70 1200 '(("black") ("white") ("red") ("blue") ("yellow") ("green") ("cyan")
yuuji@70 1201 ("magenta"))
yuuji@70 1202 "Basic colors")
yuuji@70 1203
yuuji@70 1204 (defun YaTeX:textcolor ()
yuuji@70 1205 "Add-in for \\color's option"
yuuji@70 1206 (if (y-or-n-p "Use `named' color? ")
yuuji@70 1207 "[named]"))
yuuji@70 1208
yuuji@70 1209 (defun YaTeX::color-completing-read (prompt)
yuuji@70 1210 (let ((completion-ignore-case t)
yuuji@70 1211 (namedp (save-excursion
yuuji@70 1212 (skip-chars-backward "^\n\\[\\\\")
yuuji@70 1213 (looking-at "named"))))
yuuji@70 1214 (completing-read
yuuji@70 1215 prompt
yuuji@70 1216 (if namedp
yuuji@70 1217 YaTeX:latex2e-named-color-alist
yuuji@70 1218 YaTeX:latex2e-basic-color-alist)
yuuji@70 1219 nil t)))
yuuji@70 1220
yuuji@70 1221 (defun YaTeX::textcolor (argp)
yuuji@70 1222 "Add-in for \\color's argument"
yuuji@70 1223 (cond
yuuji@70 1224 ((= argp 1) (YaTeX::color-completing-read "Color: "))
yuuji@70 1225 ((= argp 2) (read-string "Colored string: "))))
yuuji@70 1226
yuuji@70 1227 (fset 'YaTeX:color 'YaTeX:textcolor)
yuuji@70 1228 (fset 'YaTeX::color 'YaTeX::textcolor)
yuuji@70 1229 (fset 'YaTeX:colorbox 'YaTeX:textcolor)
yuuji@70 1230 (fset 'YaTeX::colorbox 'YaTeX::textcolor)
yuuji@70 1231 (fset 'YaTeX:fcolorbox 'YaTeX:textcolor)
yuuji@70 1232
yuuji@70 1233 (defun YaTeX::fcolorbox (argp)
yuuji@70 1234 (cond
yuuji@70 1235 ((= argp 1) (YaTeX::color-completing-read "Frame color: "))
yuuji@70 1236 ((= argp 2) (YaTeX::color-completing-read "Inner color: "))
yuuji@70 1237 ((= argp 3) (read-string "Colored string: "))))
yuuji@70 1238
yuuji@70 1239 (defun YaTeX:scalebox ()
yuuji@70 1240 "Add-in for \\rotatebox"
yuuji@70 1241 (let ((vmag (read-string (if YaTeX-japan "{: " "Magnification: ")))
yuuji@70 1242 (hmag (read-string (if YaTeX-japan "{(ȗ): "
yuuji@70 1243 "Horizontal magnification(Optional): "))))
yuuji@70 1244 (if (and hmag (string< "" hmag))
yuuji@70 1245 (format "{%s}[%s]" vmag hmag)
yuuji@70 1246 (format "{%s}" vmag))))
yuuji@70 1247
yuuji@70 1248 (defun YaTeX::includegraphics (argp)
yuuji@70 1249 "Add-in for \\includegraphics"
yuuji@70 1250 (cond
yuuji@70 1251 ((= argp 1)
yuuji@70 1252 (read-file-name "EPS File: " ""))))
yuuji@70 1253
yuuji@68 1254 (defun YaTeX:caption ()
yuuji@68 1255 (setq section-name "label")
yuuji@68 1256 nil)
yuuji@68 1257
yuuji@68 1258 ;;; -------------------- math-mode stuff --------------------
yuuji@68 1259 (defun YaTeX::tilde (&optional pos)
yuuji@68 1260 "For accent macros in mathmode"
yuuji@68 1261 (cond
yuuji@68 1262 ((equal pos 1)
yuuji@68 1263 (message "Put accent on variable: ")
yuuji@68 1264 (let ((v (char-to-string (read-char))) (case-fold-search nil))
yuuji@68 1265 (message "")
yuuji@68 1266 (cond
yuuji@68 1267 ((string-match "i\\|j" v)
yuuji@68 1268 (concat "\\" v "math"))
yuuji@68 1269 ((string-match "[\r\n\t ]" v)
yuuji@68 1270 "")
yuuji@68 1271 (t v))))
yuuji@68 1272 (nil "")))
yuuji@68 1273
yuuji@68 1274 (fset 'YaTeX::hat 'YaTeX::tilde)
yuuji@68 1275 (fset 'YaTeX::check 'YaTeX::tilde)
yuuji@68 1276 (fset 'YaTeX::bar 'YaTeX::tilde)
yuuji@68 1277 (fset 'YaTeX::dot 'YaTeX::tilde)
yuuji@68 1278 (fset 'YaTeX::ddot 'YaTeX::tilde)
yuuji@68 1279 (fset 'YaTeX::vec 'YaTeX::tilde)
yuuji@68 1280
yuuji@68 1281 (defun YaTeX::widetilde (&optional pos)
yuuji@68 1282 "For multichar accent macros in mathmode"
yuuji@68 1283 (cond
yuuji@68 1284 ((equal pos 1)
yuuji@68 1285 (let ((m "Put over chars[%s ]: ") v v2)
yuuji@68 1286 (message m " ")
yuuji@68 1287 (setq v (char-to-string (read-char)))
yuuji@68 1288 (message "")
yuuji@68 1289 (if (string-match "[\r\n\t ]" v)
yuuji@68 1290 ""
yuuji@68 1291 (message m v)
yuuji@68 1292 (setq v2 (char-to-string (read-char)))
yuuji@68 1293 (message "")
yuuji@68 1294 (if (string-match "[\r\n\t ]" v2)
yuuji@68 1295 v
yuuji@68 1296 (concat v v2)))))
yuuji@68 1297 (nil "")))
yuuji@68 1298
yuuji@68 1299 (fset 'YaTeX::widehat 'YaTeX::widetilde)
yuuji@68 1300 (fset 'YaTeX::overline 'YaTeX::widetilde)
yuuji@68 1301 (fset 'YaTeX::overrightarrow 'YaTeX::widetilde)
yuuji@68 1302
yuuji@68 1303
yuuji@68 1304 ;;;
yuuji@68 1305 ;; Add-in functions for large-type command.
yuuji@68 1306 ;;;
yuuji@68 1307 (defun YaTeX:em ()
yuuji@68 1308 (cond
yuuji@68 1309 ((eq YaTeX-current-completion-type 'large) "\\/")
yuuji@68 1310 (t nil)))
yuuji@68 1311 (fset 'YaTeX:it 'YaTeX:em)
yuuji@68 1312
yuuji@23 1313 ;;; -------------------- End of yatexadd --------------------
yuuji@23 1314 (provide 'yatexadd)