yatex

annotate yatexadd.el @ 23:b00c74813e56

Change the YaTeX-math-mode's prefix from `,' to `;'. Add YaTeX-apropos, YaTeX-what-column, YaTeX-beginning-of-environment, YaTeX-end-of-environment. Add variables YaTeX-default-pop-window-height, YaTeX-close-paren-always, YaTeX-no-begend-shortcut, YaTeX-auto-math-mode. Remove Greek letters from maketitle-type. Make YaTeX-inner-environment two times faster and more reliable. C-u for [prefix] k kills contents too. Fix the detection of the range of section-type commands when nested. Add \end{ completion. Add YaTeX-generate-simple. Refine documents(using Texinfo). %#REQUIRE for sub-preambles.
author yuuji
date Thu, 07 Jul 1994 16:37:05 +0000
parents adc2f1472409
children ef686a35472d
rev   line source
yuuji@6 1 ;;; -*- Emacs-Lisp -*-
yuuji@8 2 ;;; YaTeX add-in functions.
yuuji@23 3 ;;; yatexadd.el rev.9
yuuji@14 4 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
yuuji@23 5 ;;; Last modified Mon Jun 27 17:00:19 1994 on figaro
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@6 13 "*Your favorite default rule format."
yuuji@6 14 )
yuuji@23 15 (defvar YaTeX:tabular-thick-vrule "\\vrule width %s"
yuuji@23 16 "*Vertical thick line format (without @{}). %s'll be replaced by its width."
yuuji@23 17 )
yuuji@23 18 (defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}"
yuuji@23 19 "*Horizontal thick line format. %s will be replaced by its width."
yuuji@23 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@6 54
yuuji@23 55 (message "Dont forget to remove null line at the end of tabular.")
yuuji@23 56 (format "%s%s{%s}%s"
yuuji@23 57 width loc rule
yuuji@23 58 (if (and (boundp 'region-mode) region-mode)
yuuji@23 59 "" ;do nothing in region-mode
yuuji@23 60 (format "\n%s\n%s \\\\ \\hline\n%s\n\\\\ %s"
yuuji@23 61 hline and and hline))))
yuuji@18 62 )
yuuji@18 63 (fset 'YaTeX:tabular* 'YaTeX:tabular)
yuuji@18 64 (defun YaTeX:array ()
yuuji@18 65 (concat (YaTeX:read-position "tb")
yuuji@18 66 "{" (read-string "Column format: ") "}")
yuuji@6 67 )
yuuji@6 68
yuuji@23 69 (defun YaTeX:read-oneof (oneof)
yuuji@23 70 (let ((pos "") loc (guide ""))
yuuji@23 71 (and (boundp 'name) name (setq guide (format "%s " name)))
yuuji@6 72 (while (not (string-match
yuuji@8 73 (setq loc (read-key-sequence
yuuji@23 74 (format "%s position (`%s') [%s]: "
yuuji@23 75 guide oneof pos)));name is in YaTeX-addin
yuuji@6 76 "\r\^g\n"))
yuuji@6 77 (cond
yuuji@8 78 ((string-match loc oneof)
yuuji@6 79 (if (not (string-match loc pos))
yuuji@6 80 (setq pos (concat pos loc))))
yuuji@6 81 ((and (string-match loc "\C-h\C-?") (> (length pos) 0))
yuuji@6 82 (setq pos (substring pos 0 (1- (length pos)))))
yuuji@6 83 (t
yuuji@6 84 (ding)
yuuji@8 85 (message "Please input one of `%s'." oneof)
yuuji@6 86 (sit-for 3))))
yuuji@8 87 (message "")
yuuji@23 88 pos)
yuuji@23 89 )
yuuji@23 90
yuuji@23 91 (defun YaTeX:read-position (oneof)
yuuji@23 92 "Read a LaTeX (optional) position format such as `[htbp]'."
yuuji@23 93 (let ((pos (YaTeX:read-oneof oneof)))
yuuji@23 94 (if (string= pos "") "" (concat "[" pos "]")))
yuuji@8 95 )
yuuji@8 96
yuuji@8 97 (defun YaTeX:table ()
yuuji@8 98 "YaTeX add-in function for table environment."
yuuji@8 99 (YaTeX:read-position "htbp")
yuuji@6 100 )
yuuji@6 101
yuuji@6 102 (defun YaTeX:description ()
yuuji@6 103 "Truly poor service:-)"
yuuji@6 104 (setq single-command "item[]")
yuuji@8 105 ""
yuuji@6 106 )
yuuji@6 107
yuuji@6 108 (defun YaTeX:itemize ()
yuuji@6 109 "It's also poor service."
yuuji@6 110 (setq single-command "item")
yuuji@8 111 ""
yuuji@6 112 )
yuuji@6 113
yuuji@6 114 (fset 'YaTeX:enumerate 'YaTeX:itemize)
yuuji@8 115
yuuji@11 116 (defun YaTeX:picture ()
yuuji@11 117 "Ask the size of coordinates of picture environment."
yuuji@11 118 (concat (YaTeX:read-coordinates "Picture size")
yuuji@11 119 (YaTeX:read-coordinates "Initial position"))
yuuji@11 120 )
yuuji@11 121
yuuji@12 122 (defun YaTeX:equation ()
yuuji@12 123 (if (fboundp 'YaTeX-toggle-math-mode)
yuuji@12 124 (YaTeX-toggle-math-mode t)) ;force math-mode ON.
yuuji@12 125 )
yuuji@12 126 (fset 'YaTeX:eqnarray 'YaTeX:equation)
yuuji@12 127 (fset 'YaTeX:displaymath 'YaTeX:equation)
yuuji@12 128
yuuji@16 129 (defun YaTeX:list ()
yuuji@16 130 "%\n{} %default label\n{} %formatting parameter"
yuuji@16 131 )
yuuji@16 132
yuuji@18 133 (defun YaTeX:minipage ()
yuuji@18 134 (concat (YaTeX:read-position "cbt")
yuuji@18 135 "{" (read-string "Width: ") "}")
yuuji@18 136 )
yuuji@18 137
yuuji@8 138 ;;;
yuuji@8 139 ;;Sample functions for section-type command.
yuuji@8 140 ;;;
yuuji@8 141 (defun YaTeX:multiput ()
yuuji@8 142 (concat (YaTeX:read-coordinates "Pos")
yuuji@8 143 (YaTeX:read-coordinates "Step")
yuuji@8 144 "{" (read-string "How many times: ") "}")
yuuji@8 145 )
yuuji@8 146
yuuji@8 147 (defun YaTeX:put ()
yuuji@8 148 (YaTeX:read-coordinates "Pos")
yuuji@8 149 )
yuuji@8 150
yuuji@8 151 (defun YaTeX:makebox ()
yuuji@23 152 (cond
yuuji@23 153 ((YaTeX-in-environment-p "picture")
yuuji@23 154 (concat (YaTeX:read-coordinates "Dimension")
yuuji@23 155 (YaTeX:read-position "lrtb")))
yuuji@23 156 (t
yuuji@23 157 (let ((width (read-string "Width: ")))
yuuji@23 158 (if (string< "" width)
yuuji@23 159 (progn
yuuji@23 160 (or (equal (aref width 0) ?\[)
yuuji@23 161 (setq width (concat "[" width "]")))
yuuji@23 162 (concat width (YaTeX:read-position "lr")))))))
yuuji@8 163 )
yuuji@8 164
yuuji@8 165 (defun YaTeX:framebox ()
yuuji@8 166 (if (YaTeX-quick-in-environment-p "picture")
yuuji@8 167 (YaTeX:makebox))
yuuji@8 168 )
yuuji@8 169
yuuji@8 170 (defun YaTeX:dashbox ()
yuuji@8 171 (concat "{" (read-string "Dash dimension: ") "}"
yuuji@8 172 (YaTeX:read-coordinates "Dimension"))
yuuji@8 173 )
yuuji@8 174
yuuji@23 175 (defun YaTeX:left ()
yuuji@23 176 (let (c)
yuuji@23 177 (while (not (string-match
yuuji@23 178 (progn (message "Which parenthesis? One of [{(|)}]: ")
yuuji@23 179 (setq c (regexp-quote (char-to-string (read-char)))))
yuuji@23 180 "[{(|)}]")))
yuuji@23 181 (setq single-command "right")
yuuji@23 182 (cond
yuuji@23 183 ((string-match c "[(|)]") c)
yuuji@23 184 (t (concat "\\" c))))
yuuji@23 185 )
yuuji@23 186 (fset 'YaTeX:right 'YaTeX:left)
yuuji@23 187
yuuji@8 188 (defun YaTeX:read-coordinates (&optional mes varX varY)
yuuji@8 189 (concat
yuuji@8 190 "("
yuuji@8 191 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X")))
yuuji@8 192 ","
yuuji@8 193 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y")))
yuuji@8 194 ")")
yuuji@8 195 )
yuuji@8 196
yuuji@8 197 ;;;
yuuji@8 198 ;;Sample functions for maketitle-type command.
yuuji@8 199 ;;;
yuuji@8 200 (defun YaTeX:sum ()
yuuji@8 201 "Read range of summation."
yuuji@8 202 (YaTeX:check-completion-type 'maketitle)
yuuji@8 203 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))
yuuji@8 204 )
yuuji@8 205
yuuji@8 206 (fset 'YaTeX:int 'YaTeX:sum)
yuuji@8 207
yuuji@8 208 (defun YaTeX:lim ()
yuuji@8 209 "Insert limit notation of \\lim."
yuuji@8 210 (YaTeX:check-completion-type 'maketitle)
yuuji@8 211 (let ((var (read-string "Variable: ")) limit)
yuuji@8 212 (if (string= "" var) ""
yuuji@8 213 (setq limit (read-string "Limit ($ means infinity): "))
yuuji@8 214 (if (string= "$" limit) (setq limit "\\infty"))
yuuji@8 215 (concat "_{" var " \\rightarrow " limit "}")))
yuuji@8 216 )
yuuji@8 217
yuuji@8 218 (defun YaTeX:gcd ()
yuuji@8 219 "Add-in function for \\gcd(m,n)."
yuuji@8 220 (YaTeX:check-completion-type 'maketitle)
yuuji@8 221 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")
yuuji@8 222 )
yuuji@8 223
yuuji@8 224 (defun YaTeX:read-boundary (ULchar)
yuuji@8 225 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar."
yuuji@11 226 (let ((bndry (read-string (concat ULchar "{???} ($ for infinity): "))))
yuuji@8 227 (if (string= bndry "") ""
yuuji@11 228 (if (string= bndry "$") (setq bndry "\\infty"))
yuuji@8 229 (concat ULchar "{" bndry "}")))
yuuji@8 230 )
yuuji@8 231
yuuji@14 232 (defun YaTeX:verb ()
yuuji@14 233 "Enclose \\verb's contents with the same characters."
yuuji@14 234 (let ((quote-char (read-string "Quoting char: " "|"))
yuuji@14 235 (contents (read-string "Quoted contents: ")))
yuuji@14 236 (concat quote-char contents quote-char))
yuuji@14 237 )
yuuji@23 238 (fset 'YaTeX:verb* 'YaTeX:verb)
yuuji@14 239
yuuji@14 240 ;;;
yuuji@14 241 ;;Subroutine
yuuji@14 242 ;;;
yuuji@14 243
yuuji@8 244 (defun YaTeX:check-completion-type (type)
yuuji@8 245 "Check valid completion type."
yuuji@8 246 (if (not (eq type YaTeX-current-completion-type))
yuuji@8 247 (error "This should be completed with %s-type completion." type))
yuuji@8 248 )
yuuji@11 249
yuuji@11 250
yuuji@11 251 ;;;
yuuji@11 252 ;;; [[Add-in functions for reading section arguments]]
yuuji@11 253 ;;;
yuuji@11 254 ;; All of add-in functions for reading sections arguments should
yuuji@11 255 ;; take an argument ARGP that specify the argument position.
yuuji@11 256 ;; If argument position is out of range, nil should be returned,
yuuji@11 257 ;; else nil should NOT be returned.
yuuji@13 258
yuuji@13 259 ;;
yuuji@13 260 ; Label selection
yuuji@13 261 ;;
yuuji@11 262 (defvar YaTeX-label-menu-other
yuuji@11 263 (if YaTeX-japan "':‘¼‚̃oƒbƒtƒ@‚̃‰ƒxƒ‹\n" "':LABEL IN OTHER BUFFER.\n"))
yuuji@23 264 (defvar YaTeX-label-menu-repeat
yuuji@23 265 (if YaTeX-japan ".:’¼‘O‚Ì\\ref‚Æ“¯‚¶\n" "/:REPEAT LAST \ref{}\n"))
yuuji@11 266 (defvar YaTeX-label-menu-any
yuuji@11 267 (if YaTeX-japan "*:”CˆÓ‚Ì•¶Žš—ñ\n" "*:ANY STRING.\n"))
yuuji@11 268 (defvar YaTeX-label-buffer "*Label completions*")
yuuji@11 269 (defvar YaTeX-label-guide-msg "Select label and hit RETURN.")
yuuji@11 270 (defvar YaTeX-label-select-map nil
yuuji@11 271 "Key map used in label selection buffer.")
yuuji@11 272 (defun YaTeX::label-setup-key-map ()
yuuji@11 273 (if YaTeX-label-select-map nil
yuuji@11 274 (message "Setting up label selection mode map...")
yuuji@11 275 (setq YaTeX-label-select-map (copy-keymap global-map))
yuuji@11 276 (suppress-keymap YaTeX-label-select-map)
yuuji@11 277 (substitute-all-key-definition
yuuji@11 278 'previous-line 'YaTeX::label-previous YaTeX-label-select-map)
yuuji@11 279 (substitute-all-key-definition
yuuji@11 280 'next-line 'YaTeX::label-next YaTeX-label-select-map)
yuuji@11 281 (define-key YaTeX-label-select-map "\C-n" 'YaTeX::label-next)
yuuji@11 282 (define-key YaTeX-label-select-map "\C-p" 'YaTeX::label-previous)
yuuji@11 283 (define-key YaTeX-label-select-map "<" 'beginning-of-buffer)
yuuji@11 284 (define-key YaTeX-label-select-map ">" 'end-of-buffer)
yuuji@11 285 (define-key YaTeX-label-select-map "\C-m" 'exit-recursive-edit)
yuuji@11 286 (define-key YaTeX-label-select-map "\C-j" 'exit-recursive-edit)
yuuji@11 287 (define-key YaTeX-label-select-map " " 'exit-recursive-edit)
yuuji@11 288 (define-key YaTeX-label-select-map "\C-g" 'abort-recursive-edit)
yuuji@11 289 (define-key YaTeX-label-select-map "/" 'isearch-forward)
yuuji@11 290 (define-key YaTeX-label-select-map "?" 'isearch-backward)
yuuji@11 291 (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag)
yuuji@23 292 (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag)
yuuji@11 293 (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag)
yuuji@11 294 (message "Setting up label selection mode map...Done")
yuuji@11 295 (let ((key ?A))
yuuji@11 296 (while (<= key ?Z)
yuuji@11 297 (define-key YaTeX-label-select-map (char-to-string key)
yuuji@11 298 'YaTeX::label-search-tag)
yuuji@11 299 (define-key YaTeX-label-select-map (char-to-string (+ key (- ?a ?A)))
yuuji@11 300 'YaTeX::label-search-tag)
yuuji@11 301 (setq key (1+ key)))))
yuuji@11 302 )
yuuji@11 303 (defun YaTeX::label-next ()
yuuji@11 304 (interactive) (forward-line 1) (message YaTeX-label-guide-msg))
yuuji@11 305 (defun YaTeX::label-previous ()
yuuji@11 306 (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
yuuji@11 307 (defun YaTeX::label-search-tag ()
yuuji@11 308 (interactive)
yuuji@23 309 (let ((case-fold-search t) (tag (regexp-quote (this-command-keys))))
yuuji@11 310 (cond
yuuji@11 311 ((save-excursion
yuuji@11 312 (forward-char 1)
yuuji@23 313 (re-search-forward (concat "^" tag) nil t))
yuuji@11 314 (goto-char (match-beginning 0)))
yuuji@11 315 ((save-excursion
yuuji@11 316 (goto-char (point-min))
yuuji@23 317 (re-search-forward (concat "^" tag) nil t))
yuuji@11 318 (goto-char (match-beginning 0))))
yuuji@11 319 (message YaTeX-label-guide-msg))
yuuji@11 320 )
yuuji@11 321 (defun YaTeX::ref (argp)
yuuji@11 322 (cond
yuuji@11 323 ((= argp 1)
yuuji@11 324 (save-excursion
yuuji@11 325 (let ((lnum 0) e0 m1 e1 label label-list (buf (current-buffer))
yuuji@11 326 (p (point)) initl line)
yuuji@11 327 (goto-char (point-min))
yuuji@11 328 (message "Collecting labels...")
yuuji@11 329 (save-window-excursion
yuuji@12 330 (YaTeX-showup-buffer
yuuji@12 331 YaTeX-label-buffer (function (lambda (x) (window-width x))))
yuuji@11 332 (with-output-to-temp-buffer YaTeX-label-buffer
yuuji@11 333 (while (re-search-forward "\\label{\\([^}]+\\)}" nil t)
yuuji@11 334 (setq e0 (match-end 0) m1 (match-beginning 1) e1 (match-end 1))
yuuji@11 335 (if (search-backward
yuuji@11 336 YaTeX-comment-prefix (point-beginning-of-line) t) nil
yuuji@11 337 (setq label (buffer-substring m1 e1)
yuuji@11 338 label-list (cons label label-list))
yuuji@11 339 (or initl
yuuji@11 340 (if (< p (point)) (setq initl lnum)))
yuuji@11 341 (beginning-of-line)
yuuji@11 342 (skip-chars-forward " \t\n" nil)
yuuji@11 343 (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
yuuji@11 344 (buffer-substring (point) (point-end-of-line))))
yuuji@11 345 (setq lnum (1+ lnum))
yuuji@11 346 (message "Collecting \\label{}... %d" lnum))
yuuji@11 347 (goto-char e0))
yuuji@11 348 (princ YaTeX-label-menu-other)
yuuji@23 349 (princ YaTeX-label-menu-repeat)
yuuji@11 350 (princ YaTeX-label-menu-any)
yuuji@11 351 );with
yuuji@11 352 (goto-char p)
yuuji@11 353 (message "Collecting labels...Done")
yuuji@11 354 (pop-to-buffer YaTeX-label-buffer)
yuuji@11 355 (YaTeX::label-setup-key-map)
yuuji@11 356 (setq truncate-lines t)
yuuji@11 357 (setq buffer-read-only t)
yuuji@11 358 (use-local-map YaTeX-label-select-map)
yuuji@11 359 (message YaTeX-label-guide-msg)
yuuji@11 360 (goto-line (or initl lnum)) ;goto recently defined label line
yuuji@11 361 (unwind-protect
yuuji@11 362 (progn
yuuji@11 363 (recursive-edit)
yuuji@11 364 (set-buffer (get-buffer YaTeX-label-buffer)) ;assertion
yuuji@11 365 (beginning-of-line)
yuuji@11 366 (setq line (count-lines (point-min)(point)))
yuuji@11 367 (cond
yuuji@11 368 ((= line lnum) (setq label (YaTeX-label-other)))
yuuji@23 369 ((= line (1+ lnum))
yuuji@23 370 (save-excursion
yuuji@23 371 (switch-to-buffer buf)
yuuji@23 372 (goto-char p)
yuuji@23 373 (if (re-search-backward "\\\\ref{\\([^}]+\\)}" nil t)
yuuji@23 374 (setq label (buffer-substring
yuuji@23 375 (match-beginning 1) (match-end 1)))
yuuji@23 376 (setq label ""))))
yuuji@23 377 ((>= line (+ lnum 2))
yuuji@11 378 (setq label (read-string "\\ref{???}: ")))
yuuji@11 379 (t (setq label (nth (- lnum line 1) label-list)))))
yuuji@11 380 (bury-buffer YaTeX-label-buffer)))
yuuji@11 381 label
yuuji@11 382 ))
yuuji@11 383 ))
yuuji@11 384 )
yuuji@16 385 (fset 'YaTeX::pageref 'YaTeX::ref)
yuuji@11 386
yuuji@11 387 (defun YaTeX-label-other ()
yuuji@11 388 (let ((lbuf "*YaTeX mode buffers*") (blist (buffer-list)) (lnum -1) buf rv
yuuji@11 389 (ff "**find-file**"))
yuuji@12 390 (YaTeX-showup-buffer
yuuji@12 391 lbuf (function (lambda (x) 1))) ;;Select next window surely.
yuuji@11 392 (with-output-to-temp-buffer lbuf
yuuji@11 393 (while blist
yuuji@11 394 (if (and (buffer-file-name (setq buf (car blist)))
yuuji@11 395 (progn (set-buffer buf) (eq major-mode 'yatex-mode)))
yuuji@11 396 (princ
yuuji@11 397 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
yuuji@11 398 (buffer-name buf))))
yuuji@11 399 (setq blist (cdr blist)))
yuuji@11 400 (princ (format "':{%s}" ff)))
yuuji@11 401 (pop-to-buffer lbuf)
yuuji@11 402 (YaTeX::label-setup-key-map)
yuuji@11 403 (setq buffer-read-only t)
yuuji@11 404 (use-local-map YaTeX-label-select-map)
yuuji@11 405 (message YaTeX-label-guide-msg)
yuuji@11 406 (unwind-protect
yuuji@11 407 (progn
yuuji@11 408 (recursive-edit)
yuuji@11 409 (set-buffer lbuf)
yuuji@11 410 (beginning-of-line)
yuuji@11 411 (setq rv
yuuji@11 412 (if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
yuuji@11 413 (buffer-substring (match-beginning 1) (match-end 1)) nil)))
yuuji@11 414 (kill-buffer lbuf))
yuuji@11 415 (cond
yuuji@11 416 ((null rv) "")
yuuji@11 417 ((string= rv ff)
yuuji@11 418 (call-interactively 'find-file)
yuuji@11 419 (YaTeX::ref argp))
yuuji@11 420 (t
yuuji@11 421 (set-buffer rv)
yuuji@11 422 (YaTeX::ref argp)))
yuuji@11 423 )
yuuji@11 424 )
yuuji@11 425
yuuji@13 426 ;;
yuuji@13 427 ; completion for the arguments of \newcommand
yuuji@13 428 ;;
yuuji@13 429 (defun YaTeX::newcommand (&optional argp)
yuuji@13 430 (cond
yuuji@13 431 ((= argp 1)
yuuji@13 432 (let ((command (read-string "Define newcommand: " "\\")))
yuuji@13 433 (put 'YaTeX::newcommand 'command (substring command 1))
yuuji@13 434 command))
yuuji@13 435 ((= argp 2)
yuuji@13 436 (let ((argc
yuuji@13 437 (string-to-int (read-string "Number of arguments(Default 0): ")))
yuuji@13 438 (def (read-string "Definition: "))
yuuji@13 439 (command (get 'YaTeX::newcommand 'command)))
yuuji@13 440 ;;!!! It's illegal to insert string in the add-in function !!!
yuuji@13 441 (if (> argc 0) (insert (format "[%d]" argc)))
yuuji@13 442 (if (and (stringp command)
yuuji@13 443 (string< "" command)
yuuji@13 444 (y-or-n-p "Update user completion table?"))
yuuji@18 445 (cond
yuuji@18 446 ((= argc 0)
yuuji@18 447 (YaTeX-update-table
yuuji@18 448 (list command)
yuuji@18 449 'singlecmd-table 'user-singlecmd-table 'tmp-singlecmd-table))
yuuji@18 450 ((= argc 1)
yuuji@18 451 (YaTeX-update-table
yuuji@18 452 (list command)
yuuji@18 453 'section-table 'user-section-table 'tmp-section-table))
yuuji@18 454 (t (YaTeX-update-table
yuuji@18 455 (list command argc)
yuuji@18 456 'section-table 'user-section-table 'tmp-section-table))))
yuuji@13 457 (message "")
yuuji@13 458 def ;return command name
yuuji@13 459 ))
yuuji@13 460 (t ""))
yuuji@13 461 )
yuuji@13 462
yuuji@16 463 ;;
yuuji@16 464 ; completion for the arguments of \pagestyle
yuuji@16 465 ;;
yuuji@16 466 (defun YaTeX::pagestyle (&optional argp)
yuuji@16 467 "Read the pagestyle with completion."
yuuji@16 468 (completing-read
yuuji@16 469 "Page style: "
yuuji@16 470 '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))
yuuji@16 471 )
yuuji@16 472 ;;
yuuji@16 473 ; completion for the arguments of \pagenumbering
yuuji@16 474 ;;
yuuji@16 475 (defun YaTeX::pagenumbering (&optional argp)
yuuji@16 476 "Read the numbering style."
yuuji@16 477 (completing-read
yuuji@16 478 "Page numbering style: "
yuuji@16 479 '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))
yuuji@16 480 )
yuuji@13 481
yuuji@23 482 ;;
yuuji@23 483 ; Length
yuuji@23 484 ;;
yuuji@23 485 (defvar YaTeX:style-parameters-default
yuuji@23 486 '(("\\arraycolsep")
yuuji@23 487 ("\\arrayrulewidth")
yuuji@23 488 ("\\baselineskip")
yuuji@23 489 ("\\columnsep")
yuuji@23 490 ("\\columnseprule")
yuuji@23 491 ("\\doublerulesep")
yuuji@23 492 ("\\evensidemargin")
yuuji@23 493 ("\\footheight")
yuuji@23 494 ("\\footskip")
yuuji@23 495 ("\\headheight")
yuuji@23 496 ("\\headsep")
yuuji@23 497 ("\\itemindent")
yuuji@23 498 ("\\itemsep")
yuuji@23 499 ("\\labelsep")
yuuji@23 500 ("\\labelwidth")
yuuji@23 501 ("\\leftmargin")
yuuji@23 502 ("\\linewidth")
yuuji@23 503 ("\\listparindent")
yuuji@23 504 ("\\marginparsep")
yuuji@23 505 ("\\marginparwidth")
yuuji@23 506 ("\\mathindent")
yuuji@23 507 ("\\oddsidemargin")
yuuji@23 508 ("\\parindent")
yuuji@23 509 ("\\parsep")
yuuji@23 510 ("\\parskip")
yuuji@23 511 ("\\partopsep")
yuuji@23 512 ("\\rightmargin")
yuuji@23 513 ("\\tabcolsep")
yuuji@23 514 ("\\textheight")
yuuji@23 515 ("\\textwidth")
yuuji@23 516 ("\\topmargin")
yuuji@23 517 ("\\topsep")
yuuji@23 518 ("\\topskip")
yuuji@23 519 )
yuuji@23 520 "Alist of LaTeX style parameters.")
yuuji@23 521 (defvar YaTeX:style-parameters-private nil
yuuji@23 522 "*User definable alist of style parameters.")
yuuji@23 523 (defvar YaTeX:style-parameters-private nil
yuuji@23 524 "Holds the union of LaTeX style parameters.")
yuuji@23 525 (setq YaTeX:style-parameters
yuuji@23 526 (append YaTeX:style-parameters-private YaTeX:style-parameters-default))
yuuji@23 527
yuuji@23 528 (defvar YaTeX:length-history nil "Holds history of length.")
yuuji@23 529 (defun YaTeX::setlength (&optional argp)
yuuji@23 530 "YaTeX add-in function for arguments of \\setlength."
yuuji@23 531 (cond
yuuji@23 532 ((equal 1 argp)
yuuji@23 533 (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\"))
yuuji@23 534 ((equal 2 argp)
yuuji@23 535 (let ((minibuffer-history-symbol 'YaTeX:length-history))
yuuji@23 536 (read-string "Length: "))))
yuuji@23 537 )
yuuji@23 538 (fset 'YaTeX::addtolength 'YaTeX::setlength)
yuuji@23 539
yuuji@23 540 (defun YaTeX::settowidth (&optional argp)
yuuji@23 541 "YaTeX add-in function for arguments of \\settowidth."
yuuji@23 542 (cond
yuuji@23 543 ((equal 1 argp)
yuuji@23 544 (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\"))
yuuji@23 545 ((equal 2 argp)
yuuji@23 546 (read-string "Text: ")))
yuuji@23 547 )
yuuji@23 548 (defun YaTeX::newlength (&optional argp)
yuuji@23 549 "YaTeX add-in function for arguments of \\newlength"
yuuji@23 550 (cond
yuuji@23 551 ((equal argp 1)
yuuji@23 552 (let ((length (read-string "Length variable: " "\\")))
yuuji@23 553 (or (assoc length YaTeX:style-parameters-private)
yuuji@23 554 (setq YaTeX:style-parameters-private
yuuji@23 555 (cons (list length) YaTeX:style-parameters-private)
yuuji@23 556 YaTeX:style-parameters
yuuji@23 557 (cons (list length) YaTeX:style-parameters)))
yuuji@23 558 length)))
yuuji@23 559 )
yuuji@23 560
yuuji@23 561 ;; \multicolumn's arguments
yuuji@23 562 (defun YaTeX::multicolumn (&optional argp)
yuuji@23 563 "YaTeX add-in function for arguments of \\multicolumn."
yuuji@23 564 (cond
yuuji@23 565 ((equal 1 argp)
yuuji@23 566 (read-string "Number of columns: "))
yuuji@23 567 ((equal 2 argp)
yuuji@23 568 (let (c)
yuuji@23 569 (while (not (string-match
yuuji@23 570 (progn (message "Format(one of l,r,c): ")
yuuji@23 571 (setq c (char-to-string (read-char))))
yuuji@23 572 "lrc")))
yuuji@23 573 c))
yuuji@23 574 ((equal 3 argp)
yuuji@23 575 (read-string "Item: ")))
yuuji@23 576 )
yuuji@23 577
yuuji@23 578 ;;; -------------------- End of yatexadd --------------------
yuuji@23 579 (provide 'yatexadd)