yatex

annotate yatex.el @ 5:370a391533fd

Post fj.sources.
author yuuji
date Tue, 16 Feb 1993 08:51:15 +0000
parents 78dfe28b6a35
children 49be9ccb0b65
rev   line source
yuuji@0 1 ;;; -*- Emacs-Lisp -*-
yuuji@0 2 ;;; Yet Another tex-mode for emacs.
yuuji@5 3 ;;; yatex.el rev.1.37
yuuji@5 4 ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
yuuji@5 5 ;;; Last modified Fri Feb 12 16:05:54 1993 on VFR
yuuji@0 6
yuuji@5 7 ;; This software is distributed in the hope that it will be useful,
yuuji@5 8 ;; but WITHOUT ANY WARRANTY. No author or distributor
yuuji@5 9 ;; accepts responsibility to anyone for the consequences of using it
yuuji@5 10 ;; or for whether it serves any particular purpose or works at all,
yuuji@5 11 ;; unless he says so in writing. Refer to the GNU Emacs General Public
yuuji@5 12 ;; License for full details.
yuuji@5 13
yuuji@5 14 ;; Everyone is granted permission to copy, modify and redistribute
yuuji@5 15 ;; this software, but only under the conditions described in the
yuuji@5 16 ;; GNU Emacs General Public License. A copy of this license is
yuuji@5 17 ;; supposed to have been given to you along with this software so you
yuuji@5 18 ;; can know your rights and responsibilities. It should be in a
yuuji@5 19 ;; file named COPYING. Among other things, the copyright notice
yuuji@5 20 ;; and this notice must be preserved on all copies.
yuuji@5 21
yuuji@5 22 (provide 'yatex)
yuuji@3 23 (require 'comment)
yuuji@5 24 (defconst YaTeX-revision-number "1.37"
yuuji@0 25 "Revision number of running yatex.el"
yuuji@0 26 )
yuuji@0 27
yuuji@0 28 ;---------- Local variables ----------
yuuji@0 29 ;;;
yuuji@0 30 ;; Initialize local variable for yatex-mode.
yuuji@0 31 ;; Preserving user preferred definitions.
yuuji@0 32 ;; ** Check all of these defvar-ed values **
yuuji@0 33 ;; ** and setq other values more suitable **
yuuji@5 34 ;; ** for your site, if needed. **
yuuji@0 35 ;;;
yuuji@0 36 (defvar YaTeX-prefix "\^C"
yuuji@5 37 "*Prefix key to trigger YaTeX functions.
yuuji@0 38 You can select favorite prefix key by setq in your ~/.emacs."
yuuji@0 39 )
yuuji@0 40 (defvar YaTeX-open-lines 1
yuuji@5 41 "*Blank lines between text and \??{??}"
yuuji@0 42 )
yuuji@1 43 (defvar YaTeX-fill-prefix ""
yuuji@5 44 "*fill-prefix used for auto-fill-mode.
yuuji@5 45 The defalut value is null string."
yuuji@5 46 )
yuuji@5 47 (defvar YaTeX-fill-column 72
yuuji@5 48 "*fill-column used for auto-fill-mode."
yuuji@0 49 )
yuuji@4 50 (defvar YaTeX-comment-prefix "%"
yuuji@4 51 "TeX comment prefix."
yuuji@4 52 )
yuuji@5 53 (defvar YaTeX-current-position-register ?3
yuuji@5 54 "*All of YaTeX completing input store the current position into
yuuji@5 55 the register YaTeX-current-position-register. So every time you
yuuji@5 56 make a trip to any other part of text than you writing, you can
yuuji@5 57 return to editing paragraph by calling register-to-point with argument
yuuji@5 58 YaTeX-current-position-register."
yuuji@5 59 )
yuuji@4 60 (defvar YaTeX-user-completion-table
yuuji@5 61 (if (eq system-type 'ms-dos) "~/_yatexrc" "~/.yatexrc")
yuuji@5 62 "*Default filename in which user completion table is saved."
yuuji@0 63 )
yuuji@0 64 (defvar tex-command "jlatex"
yuuji@5 65 "*Default command for compiling LaTeX text."
yuuji@0 66 )
yuuji@0 67 (defvar dvi2-command ;previewer command for your site
yuuji@5 68 (if (eq system-type 'ms-dos) "dviout"
yuuji@5 69 (concat "xdvi -geo +0+0 -s 4 -display " (getenv "DISPLAY")))
yuuji@5 70 "*Default previewer command including its option.
yuuji@0 71 This default value is for X window system. If you want to use this
yuuji@0 72 default, you have to make sure the environment variable DISPLAY is
yuuji@0 73 correctly set."
yuuji@0 74 )
yuuji@5 75 (defvar dviprint-command-format
yuuji@5 76 (if (eq system-type 'ms-dos) "dviprt %s %f%t"
yuuji@5 77 "dvi2ps %f %t %s | lpr")
yuuji@5 78 "*Command line string to print out current file. Format string %s
yuuji@5 79 will be replaced by the filename. Do not forget to specify the
yuuji@5 80 `from usage' and `to usage' with their option by format string %f and %t.
yuuji@5 81 See also documentation of dviprint-from-format and dviprint-to-format."
yuuji@5 82 )
yuuji@5 83 (defvar dviprint-from-format
yuuji@5 84 (if (eq system-type 'ms-dos) "%b-" "-f %b")
yuuji@5 85 "*From page format of dvi filter. %b will turn to beginning page number."
yuuji@5 86 )
yuuji@5 87 (defvar dviprint-to-format
yuuji@5 88 (if (eq system-type 'ms-dos) "%e" "-t %e")
yuuji@5 89 "*To page format of dvi filter. %e will turn to end page number."
yuuji@5 90 )
yuuji@5 91 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE))
yuuji@5 92 "Whether yatex mode is running on Japanese environment or not."
yuuji@5 93 )
yuuji@5 94 (defvar YaTeX-default-document-style
yuuji@5 95 (concat (if YaTeX-japan "j") "article")
yuuji@5 96 "*Default LaTeX Documentstyle for YaTeX-typeset-region."
yuuji@5 97 )
yuuji@5 98 (defvar YaTeX-need-nonstop nil
yuuji@5 99 "*If t yatex automatically put `\nonstopmode{}' in current buffer
yuuji@5 100 before invoke latex command."
yuuji@5 101 )
yuuji@0 102 (defvar latex-warning-regexp "line.* [0-9]*"
yuuji@5 103 "*Regular expression of line number of warning message by latex command."
yuuji@0 104 )
yuuji@0 105 (defvar latex-error-regexp "l\\.[1-9][0-9]*"
yuuji@5 106 "*Regular expression of line number of latex error. Perhaps your latex
yuuji@0 107 command stops at this error message with line number of LaTeX source text."
yuuji@0 108 )
yuuji@1 109 (defvar latex-dos-emergency-message
yuuji@3 110 "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6
yuuji@5 111 "Because Demacs (GNU Emacs on DOS) cannot have concurrent process, the
yuuji@0 112 latex command which is stopping on a LaTeX error, is terminated by Demacs.
yuuji@0 113 Many latex command on DOS display some message when it is terminated by
yuuji@0 114 other process, user or OS. Define this variable a message string of your
yuuji@0 115 latex command on DOS shows at abnormal termination.
yuuji@0 116 Remember Demacs's call-process function is not oriented for interactive
yuuji@0 117 process."
yuuji@0 118 )
yuuji@5 119 (defvar latex-message-kanji-code 2
yuuji@5 120 "*Kanji coding system latex command types out.
yuuji@5 121 1 = Shift JIS, 2 = JIS, 3 = EUC."
yuuji@5 122 )
yuuji@5 123 (defvar NTT-jTeX nil
yuuji@5 124 "*Use NTT-jTeX for latex command."
yuuji@5 125 )
yuuji@0 126
yuuji@0 127 ;------------ Completion table ------------
yuuji@0 128 ; Set tex-section-like command possible completion
yuuji@0 129 (setq section-table
yuuji@0 130 '(("part") ("section") ("subsection") ("subsubsection")
yuuji@0 131 ("author") ("documentstyle") ("pagestyle")
yuuji@0 132 ("documentstyle[10pt]") ("documentstyle[11pt]")
yuuji@0 133 ("documentstyle[12pt]")
yuuji@3 134 ("title") ("chapter") ("part") ("paragraph")
yuuji@0 135 ("subparagraph") ("underline") ("label") ("footnote")
yuuji@0 136 ("hspace*") ("vspace*") ("bibliography") ("bibitem[]") ("cite[]")
yuuji@0 137 ("nocite") ("input") ("include") ("includeonly") ("mbox") ("hbox")
yuuji@0 138 ("caption") ("newcommand") ("setlength") ("addtolength")
yuuji@0 139 ("newenvironment") ("newtheorem")
yuuji@5 140 ("cline") ("framebox")
yuuji@0 141 ))
yuuji@0 142 (defvar user-section-table nil)
yuuji@0 143
yuuji@0 144 ; Set style possible completion
yuuji@0 145 (setq article-table
yuuji@0 146 '(("article") ("jarticle") ("report") ("jreport") ("jbook")
yuuji@0 147 ("4em") ("2ex")
yuuji@0 148 ("empty") ("headings") ("\\textwidth")
yuuji@0 149 ("\\oddsidemargin") ("\\evensidemargin")
yuuji@0 150 ("\\textheight") ("\\topmargin")
yuuji@0 151 ("\\bottommargin") ("\\footskip") ("\\footheight")
yuuji@5 152 ("\\baselineskip") ("\\baselinestretch") ("normalbaselineskip")
yuuji@0 153 ))
yuuji@0 154 (defvar user-article-table nil)
yuuji@0 155
yuuji@0 156 ; Set tex-environment possible completion
yuuji@0 157 (setq env-table
yuuji@0 158 '(("quote") ("quotation") ("center") ("verse") ("document")
yuuji@0 159 ("verbatim") ("itemize") ("enumerate") ("description")
yuuji@5 160 ("list{}") ("tabular") ("table") ("tabbing") ("titlepage")
yuuji@0 161 ("sloppypar") ("ref") ("quotation") ("quote") ("picture")
yuuji@0 162 ("eqnarray") ("figure") ("equation") ("abstract") ("array")
yuuji@5 163 ("thebibliography") ("theindex") ("flushleft") ("flushright")
yuuji@0 164 ))
yuuji@0 165 (defvar user-env-table nil)
yuuji@0 166
yuuji@0 167 ; Set {\Large }-like comletion
yuuji@0 168 (setq fontsize-table
yuuji@0 169 '(("rm") ("em") ("bf") ("boldmath") ("it") ("sl") ("sf") ("sc") ("tt")
yuuji@0 170 ("dg") ("dm")
yuuji@0 171 ("tiny") ("scriptsize") ("footnotesize") ("small")("normalsize")
yuuji@0 172 ("large") ("Large") ("LARGE") ("huge") ("Huge")
yuuji@0 173 ))
yuuji@0 174 (defvar user-fontsize-table nil)
yuuji@0 175
yuuji@0 176 (setq singlecmd-table
yuuji@5 177 '(("maketitle") ("sloppy") ("protect")
yuuji@0 178 ("alpha") ("beta") ("gamma") ("delta") ("epsilon") ("varepsilon")
yuuji@0 179 ("zeta") ("eta") ("theta")("vartheta") ("iota") ("kappa")
yuuji@0 180 ("lambda") ("mu") ("nu") ("xi") ("pi") ("varpi") ("rho") ("varrho")
yuuji@0 181 ("sigma") ("varsigma") ("tau") ("upsilon") ("phi") ("varphi")
yuuji@0 182 ("chi") ("psi") ("omega") ("Gamma") ("Delta") ("Theta") ("Lambda")
yuuji@0 183 ("Xi") ("Pi") ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega")
yuuji@5 184 ("LaTeX") ("TeX") ("item[]") ("appendix") ("hline")
yuuji@5 185 ("rightarrow") ("Rightarrow") ("leftarrow") ("Leftarrow")
yuuji@5 186 ("pagebreak")
yuuji@0 187 ))
yuuji@0 188 (defvar user-singlecmd-table nil)
yuuji@0 189
yuuji@0 190 ;---------- Key mode map ----------
yuuji@0 191 ;;;
yuuji@0 192 ;; Create new key map: YaTeX-mode-map
yuuji@0 193 ;; Do not change this section.
yuuji@0 194 ;;;
yuuji@4 195 (defvar YaTeX-inhibit-prefix-letter nil
yuuji@5 196 "*Switch which determins whether inhibit yatex.el from defining
yuuji@4 197 key sequence \"C-c letter\" or not."
yuuji@4 198 )
yuuji@0 199 (defvar YaTeX-mode-map nil
yuuji@0 200 "Keymap used in YaTeX mode."
yuuji@0 201 )
yuuji@4 202 (defvar YaTeX-typesetting-mode-map nil
yuuji@4 203 "Keymap userd in YaTeX typesetting buffer."
yuuji@4 204 )
yuuji@4 205 (defvar YaTeX-prefix-map nil
yuuji@4 206 "Keymap used when YaTeX-prefix key pushed."
yuuji@0 207 )
yuuji@0 208
yuuji@0 209 ;---------- Define deafult key bindings on YaTeX mode map ----------
yuuji@4 210 (defun YaTeX-define-key (key binding)
yuuji@4 211 "Define key on YaTeX-prefix-map"
yuuji@4 212 (if YaTeX-inhibit-prefix-letter
yuuji@4 213 (let ((c (aref key 0)))
yuuji@4 214 (cond
yuuji@4 215 ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a))))
yuuji@4 216 ((and (>= c ?A) (<= c ?Z)) (aset key 0 (1+ (- c ?A))))
yuuji@4 217 (t nil))))
yuuji@4 218 (define-key YaTeX-prefix-map key binding)
yuuji@4 219 )
yuuji@4 220 (defun YaTeX-define-begend-key (key env)
yuuji@4 221 "Define short cut YaTeX-make-begin-end key."
yuuji@4 222 (YaTeX-define-key
yuuji@4 223 key
yuuji@4 224 (list 'lambda '(arg) '(interactive "P")
yuuji@4 225 (list 'YaTeX-insert-begin-end env 'arg)))
yuuji@4 226 )
yuuji@4 227 (defun YaTeX-define-begend-region-key (key env)
yuuji@4 228 "Define short cut YaTeX-make-begin-end-region key."
yuuji@4 229 (YaTeX-define-key key (list 'lambda nil '(interactive)
yuuji@4 230 (list 'YaTeX-insert-begin-end env t)))
yuuji@4 231 )
yuuji@0 232 ;;;
yuuji@0 233 ;; Define key table
yuuji@0 234 ;;;
yuuji@0 235 (if YaTeX-mode-map
yuuji@0 236 nil
yuuji@0 237 (setq YaTeX-mode-map (make-sparse-keymap))
yuuji@4 238 (setq YaTeX-prefix-map (make-sparse-keymap))
yuuji@4 239 (define-key YaTeX-mode-map "\"" 'YaTeX-insert-quote)
yuuji@5 240 (define-key YaTeX-mode-map "{" 'YaTeX-insert-braces)
yuuji@5 241 (define-key YaTeX-mode-map "(" '(lambda () (interactive)
yuuji@5 242 (insert "()") (backward-char 1)))
yuuji@5 243 ;(define-key YaTeX-mode-map "[" 'YaTeX-insert-brackets)
yuuji@4 244 (define-key YaTeX-mode-map YaTeX-prefix YaTeX-prefix-map)
yuuji@4 245 (YaTeX-define-key "t" 'YaTeX-typeset-menu)
yuuji@5 246 (YaTeX-define-key "'" 'YaTeX-prev-error)
yuuji@5 247 (YaTeX-define-key "^" 'YaTeX-visit-main)
yuuji@5 248 (YaTeX-define-key "4^" 'YaTeX-visit-main-other-window)
yuuji@5 249 (YaTeX-define-key " " 'YaTeX-do-completion)
yuuji@4 250 (YaTeX-define-key "v" 'YaTeX-version)
yuuji@0 251
yuuji@5 252 (YaTeX-define-key "}" 'YaTeX-insert-braces-region)
yuuji@5 253 (YaTeX-define-key "]" 'YaTeX-insert-brackets-region)
yuuji@4 254 (YaTeX-define-key "d" 'YaTeX-insert-dollar)
yuuji@5 255 (YaTeX-define-key "i" 'YaTeX-fill-item)
yuuji@4 256 (YaTeX-define-key
yuuji@4 257 "\\" '(lambda () (interactive) (YaTeX-insert-string "$\\backslash$")))
yuuji@4 258 (YaTeX-define-begend-region-key "Bd" "document")
yuuji@4 259 (YaTeX-define-begend-key "bd" "document")
yuuji@4 260 (YaTeX-define-begend-region-key "BD" "description")
yuuji@4 261 (YaTeX-define-begend-key "bD" "description")
yuuji@4 262 (YaTeX-define-begend-region-key "Be" "enumerate")
yuuji@4 263 (YaTeX-define-begend-key "be" "enumerate")
yuuji@4 264 (YaTeX-define-begend-region-key "Bi" "itemize")
yuuji@4 265 (YaTeX-define-begend-key "bi" "itemize")
yuuji@4 266 (YaTeX-define-begend-region-key "Bt" "tabbing")
yuuji@4 267 (YaTeX-define-begend-key "bt" "tabbing")
yuuji@4 268 (YaTeX-define-begend-region-key "BT" "tabular")
yuuji@4 269 (YaTeX-define-begend-key "bT" "tabular")
yuuji@4 270 (YaTeX-define-begend-region-key "Bq" "quote")
yuuji@4 271 (YaTeX-define-begend-key "bq" "quote")
yuuji@4 272 (YaTeX-define-begend-region-key "BQ" "quotation")
yuuji@4 273 (YaTeX-define-begend-key "bQ" "quotation")
yuuji@4 274 (YaTeX-define-key "." 'YaTeX-comment-paragraph)
yuuji@4 275 (YaTeX-define-key "," 'YaTeX-uncomment-paragraph)
yuuji@4 276 (YaTeX-define-key ">" 'YaTeX-comment-region)
yuuji@4 277 (YaTeX-define-key "<" 'YaTeX-uncomment-region)
yuuji@4 278 (YaTeX-define-key "B " 'YaTeX-make-begin-end-region)
yuuji@4 279 (YaTeX-define-key "b " 'YaTeX-make-begin-end)
yuuji@4 280 (YaTeX-define-key "e" 'YaTeX-end-environment)
yuuji@4 281 (YaTeX-define-key "s" 'YaTeX-make-section)
yuuji@4 282 (YaTeX-define-key "L" 'YaTeX-make-fontsize-region)
yuuji@4 283 (YaTeX-define-key "l" 'YaTeX-make-fontsize)
yuuji@4 284 (YaTeX-define-key "m" 'YaTeX-make-singlecmd)
yuuji@5 285 (YaTeX-define-key "g" 'YaTeX-goto-corresponding-*)
yuuji@5 286 (YaTeX-define-key "k" 'YaTeX-kill-*)
yuuji@5 287 (YaTeX-define-key "c" 'YaTeX-change-*)
yuuji@5 288 (YaTeX-define-key "a" 'YaTeX-make-accent)
yuuji@5 289 (YaTeX-define-key "n"
yuuji@0 290 '(lambda () (interactive) (YaTeX-insert-string "\\\\")))
yuuji@0 291 (if (eq system-type 'ms-dos)
yuuji@5 292 (define-key YaTeX-prefix-map "L"
yuuji@0 293 '(lambda () (interactive)
yuuji@3 294 (set-screen-height YaTeX-saved-screen-height) (recenter))))
yuuji@0 295 )
yuuji@0 296
yuuji@4 297 (if YaTeX-typesetting-mode-map nil
yuuji@4 298 (setq YaTeX-typesetting-mode-map (make-keymap))
yuuji@4 299 (suppress-keymap YaTeX-typesetting-mode-map t)
yuuji@4 300 (define-key YaTeX-typesetting-mode-map " "
yuuji@0 301 'YaTeX-jump-error-line)
yuuji@0 302 )
yuuji@0 303
yuuji@0 304 ;---------- Customize as you like above ----------
yuuji@0 305
yuuji@0 306 ;---------- Define other variable ----------
yuuji@0 307 (defvar env-name "document") ;Initial tex-environment completion
yuuji@0 308 (defvar section-name "documentstyle[12pt]") ;Initial tex-section completion
yuuji@0 309 (defvar fontsize-name "large") ;Initial fontsize completion
yuuji@0 310 (defvar single-command "maketitle") ;Initial LaTeX single command
yuuji@0 311 (defvar YaTeX-user-table-has-read nil
yuuji@5 312 "Flag that means whether user completion table has been read or not."
yuuji@0 313 )
yuuji@4 314 (defvar YaTeX-user-table-modified nil
yuuji@4 315 "Flag that means whether user completion table has modified or not."
yuuji@4 316 )
yuuji@0 317 (defvar yatex-mode-hook nil
yuuji@5 318 "*List of functions to be called after .tex file is read
yuuji@5 319 and yatex-mode starts."
yuuji@5 320 )
yuuji@5 321 (defvar YaTeX-kanji-code-alist
yuuji@5 322 '((1 . *sjis*) (2 . *junet*) (3 . *euc-japan*))
yuuji@5 323 )
yuuji@5 324 (defvar YaTeX-kanji-code (if (eq system-type 'ms-dos) 1 2)
yuuji@5 325 "*File kanji code used by Japanese TeX."
yuuji@5 326 )
yuuji@5 327 (cond
yuuji@5 328 ((boundp 'MULE)
yuuji@5 329 (defvar YaTeX-coding-system
yuuji@5 330 (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))
yuuji@5 331 "File coding system used by Japanese TeX")
yuuji@5 332 (if (not (eq system-type 'ms-dos))
yuuji@5 333 (defvar YaTeX-latex-message-code *autoconv*)))
yuuji@5 334 ((boundp 'NEMACS)
yuuji@5 335 (defvar YaTeX-latex-message-code latex-message-kanji-code))
yuuji@5 336 )
yuuji@0 337 ;---------- Produce YaTeX-mode ----------
yuuji@0 338 ;;;
yuuji@0 339 ;; Major mode definition
yuuji@0 340 ;;;
yuuji@0 341 (defun yatex-mode ()
yuuji@0 342 (interactive)
yuuji@0 343 (kill-all-local-variables)
yuuji@0 344 (setq major-mode 'YaTeX-mode)
yuuji@5 345 (setq mode-name (if YaTeX-japan "‚â‚Ä‚Ó" "YaTeX"))
yuuji@4 346 (make-local-variable 'dvi2-command)
yuuji@5 347 (cond ((boundp 'MULE) ;;1992/12/21 by NIIMI Satoshi.
yuuji@5 348 ;; file-coding-system is buffer local variable
yuuji@5 349 (set-file-coding-system YaTeX-coding-system))
yuuji@5 350 ((boundp 'NEMACS)
yuuji@5 351 (make-local-variable 'kanji-fileio-code)
yuuji@5 352 (setq kanji-fileio-code YaTeX-kanji-code)))
yuuji@0 353 (make-local-variable 'fill-column)
yuuji@0 354 (make-local-variable 'fill-prefix)
yuuji@5 355 (setq fill-column YaTeX-fill-column
yuuji@0 356 fill-prefix YaTeX-fill-prefix)
yuuji@0 357 (use-local-map YaTeX-mode-map)
yuuji@0 358 (if (eq system-type 'ms-dos)
yuuji@3 359 (setq YaTeX-saved-screen-height (screen-height)))
yuuji@0 360 (if YaTeX-user-table-has-read nil
yuuji@0 361 (YaTeX-read-user-completion-table)
yuuji@0 362 (setq YaTeX-user-table-has-read t))
yuuji@5 363 (run-hooks 'text-mode-hook 'yatex-mode-hook)
yuuji@5 364 )
yuuji@5 365
yuuji@5 366 ;---------- Define macro ---------
yuuji@5 367 (defmacro point-beginning-of-line ()
yuuji@5 368 (save-excursion (beginning-of-line)(point))
yuuji@5 369 )
yuuji@5 370
yuuji@5 371 (defmacro point-end-of-line ()
yuuji@5 372 (save-excursion (end-of-line)(point))
yuuji@0 373 )
yuuji@0 374
yuuji@0 375 ;---------- Define YaTeX-mode functions ----------
yuuji@0 376 ;;;
yuuji@0 377 ;; YaTeX-mode functions
yuuji@0 378 ;;;
yuuji@0 379 (defun YaTeX-insert-begin-end (env arg)
yuuji@0 380 "Insert \begin{mode-name} and \end{mode-name}."
yuuji@0 381 (if arg
yuuji@0 382 (save-excursion
yuuji@0 383 (if (> (point) (mark)) (exchange-point-and-mark))
yuuji@5 384 (insert "\\begin{" env "}")
yuuji@5 385 (YaTeX-addin env)
yuuji@5 386 (insert "\n")
yuuji@5 387 (indent-relative-maybe)
yuuji@0 388 (exchange-point-and-mark)
yuuji@5 389 (insert "\\end{" env "}\n")
yuuji@5 390 (indent-relative-maybe))
yuuji@5 391 ;(delete-blank-lines)
yuuji@5 392 (let ((i 1))
yuuji@5 393 (insert "\\begin{" env "}")
yuuji@5 394 (YaTeX-addin env)
yuuji@5 395 (insert "\n")
yuuji@5 396 (indent-relative-maybe)
yuuji@5 397 ;;(newline (1+ (* 2 YaTeX-open-lines)))
yuuji@5 398 (while (<= i (1+ (* 2 YaTeX-open-lines)))
yuuji@5 399 (insert "\n")
yuuji@5 400 (indent-relative-maybe)
yuuji@5 401 (setq i (1+ i)))
yuuji@5 402 (insert "\\end{" env "}")
yuuji@5 403 (previous-line (+ 1 YaTeX-open-lines)));let i
yuuji@5 404 (if YaTeX-current-position-register
yuuji@5 405 (point-to-register YaTeX-current-position-register)))
yuuji@0 406 )
yuuji@0 407
yuuji@0 408 (defun YaTeX-make-begin-end (arg)
yuuji@0 409 "Make LaTeX environment command of \\begin{env.} ... \\end{env.}
yuuji@0 410 by completing read.
yuuji@0 411 If you invoke this command with universal argument,
yuuji@5 412 \(key binding for universal-argument is \\[universal-argument]\)
yuuji@0 413 you can put REGION into that environment between \\begin and \\end."
yuuji@0 414 (interactive "P")
yuuji@0 415 (let*
yuuji@0 416 ((mode (if arg " region" ""))
yuuji@0 417 (env
yuuji@5 418 (YaTeX-read-environment
yuuji@5 419 (format "Begin environment%s(default %s): " mode env-name))))
yuuji@0 420 (if (string= env "")
yuuji@0 421 (setq env env-name))
yuuji@0 422 (setq env-name env)
yuuji@4 423 (if (not (assoc env-name (append user-env-table env-table))) ;if not exist
yuuji@4 424 (setq user-env-table (cons (list env-name) user-env-table)
yuuji@4 425 YaTeX-user-table-modified t))
yuuji@0 426 (YaTeX-insert-begin-end env-name arg))
yuuji@0 427 )
yuuji@0 428
yuuji@0 429 (defun YaTeX-make-begin-end-region ()
yuuji@0 430 "Call YaTeX-make-begin-end with ARG to specify region mode."
yuuji@0 431 (interactive)
yuuji@0 432 (YaTeX-make-begin-end t)
yuuji@0 433 )
yuuji@0 434
yuuji@5 435 (defun YaTeX-inner-environment ()
yuuji@5 436 "Return current inner environment."
yuuji@5 437 (save-excursion
yuuji@5 438 (let ((nest 0) s)
yuuji@3 439 (while
yuuji@3 440 (and
yuuji@3 441 (>= nest 0)
yuuji@3 442 (re-search-backward
yuuji@4 443 "\\(\\\\begin{\\).*}\\|\\(\\\\end{\\).*}" (point-min) t))
yuuji@4 444 (if (re-search-backward "^[ ]*%" (point-beginning-of-line) t)
yuuji@4 445 nil ;ignore TeX comment usage.
yuuji@4 446 (setq nest (if (eq (match-beginning 0) (match-beginning 1))
yuuji@4 447 (1- nest) (1+ nest)))))
yuuji@3 448 (if (>= nest 0)
yuuji@5 449 nil
yuuji@4 450 (goto-char (match-end 1))
yuuji@3 451 (setq s (point))
yuuji@4 452 (skip-chars-forward "^}")
yuuji@5 453 (buffer-substring s (point))
yuuji@5 454 )))
yuuji@5 455 )
yuuji@5 456
yuuji@5 457 (defun YaTeX-end-environment ()
yuuji@5 458 "Close opening environment"
yuuji@5 459 (interactive)
yuuji@5 460 (let ((curp (point))
yuuji@5 461 (env (YaTeX-inner-environment)))
yuuji@5 462
yuuji@5 463 (if (not env) (error "No premature environment")
yuuji@3 464 (save-excursion
yuuji@3 465 (if (and (re-search-forward "^[^\\%]*\\\\end{.*}" (point-max) t)
yuuji@3 466 (progn (goto-char (match-beginning 0))
yuuji@3 467 (re-search-forward env (match-end 0) t)))
yuuji@3 468 (if (y-or-n-p
yuuji@3 469 (concat "Environment `" env
yuuji@3 470 "' was already closed. Force close?"))
yuuji@3 471 nil
yuuji@4 472 (error "end environment aborted."))))
yuuji@3 473 (message "") ;Erase (y or n) message.
yuuji@4 474 (insert "\\end{" env "}")
yuuji@4 475 (setq curp (point))
yuuji@5 476 (goto-char (match-end 0))
yuuji@4 477 (if (pos-visible-in-window-p)
yuuji@4 478 (sit-for 1)
yuuji@4 479 (message (concat "Matches \\begin{" env
yuuji@4 480 (format "} at line %d"
yuuji@5 481 (count-lines (point-min) (match-end 0))))))
yuuji@4 482 (goto-char curp))
yuuji@3 483 )
yuuji@3 484 )
yuuji@3 485
yuuji@0 486 (defun YaTeX-make-section (arg)
yuuji@0 487 "Make LaTeX \\section{} type command with completing read.
yuuji@0 488 With ARG of numeric, you can specify the number of argument of
yuuji@0 489 LaTeX command.
yuuji@0 490 For example, if you want to produce LaTeX command
yuuji@0 491
yuuji@0 492 \\addtolength{\\topmargin}{8mm}
yuuji@0 493
yuuji@5 494 which has two arguments. You can produce that sequence by typing...
yuuji@0 495 ESC 2 C-c s add SPC RET \\topm SPC RET 8mm RET
yuuji@0 496 \(by default\)
yuuji@0 497 You can complete symbol at LaTeX command and 1st argument."
yuuji@0 498 (interactive "p")
yuuji@0 499 (let*
yuuji@0 500 ((section
yuuji@0 501 (completing-read
yuuji@0 502 (format "\\???{} (default %s): " section-name)
yuuji@0 503 (append user-section-table section-table)
yuuji@0 504 nil nil))
yuuji@0 505 (section (if (string= section "") section-name section))
yuuji@0 506 (title
yuuji@0 507 (completing-read (concat "\\" section "{???}: ")
yuuji@0 508 (append user-article-table article-table)
yuuji@0 509 nil nil)))
yuuji@0 510 (setq section-name section)
yuuji@4 511 (if (not (assoc section-name (append user-section-table section-table)))
yuuji@0 512 (setq user-section-table
yuuji@4 513 (cons (list section-name) user-section-table)
yuuji@4 514 YaTeX-user-table-modified t))
yuuji@0 515 (insert "\\" section-name "{" title "}")
yuuji@5 516 (if YaTeX-current-position-register
yuuji@5 517 (point-to-register YaTeX-current-position-register))
yuuji@0 518 (let ((j 2))
yuuji@0 519 (while (<= j arg)
yuuji@0 520 (insert (concat "{" (read-string (format "Argument %d: " j))))
yuuji@0 521 (insert "}")
yuuji@0 522 (setq j (1+ j)))
yuuji@0 523 )
yuuji@0 524 (if (string= title "") (forward-char -1)
yuuji@0 525 nil))
yuuji@0 526 )
yuuji@0 527
yuuji@0 528 ;(defun YaTeX-make-section-region ()
yuuji@0 529 ; "Call YaTeX-make-section with ARG to specify region mode."
yuuji@0 530 ; (interactive)
yuuji@0 531 ; (YaTeX-make-section t)
yuuji@0 532 ;)
yuuji@0 533
yuuji@0 534 (defun YaTeX-make-fontsize (arg)
yuuji@0 535 "Make completion like {\\large ...} or {\\slant ...} in minibuffer.
yuuji@0 536 If you invoke this command with universal argument, you can put region
yuuji@0 537 into {\\xxx } braces.
yuuji@5 538 \(key binding for universal-argument is \\[universal-argument]\)"
yuuji@0 539 (interactive "P")
yuuji@0 540 (let* ((mode (if arg "region" ""))
yuuji@0 541 (fontsize
yuuji@0 542 (completing-read
yuuji@0 543 (format "{\\??? %s} (default %s): " mode fontsize-name)
yuuji@0 544 (append user-fontsize-table fontsize-table)
yuuji@0 545 nil nil )))
yuuji@0 546 (if (string= fontsize "")
yuuji@0 547 (setq fontsize fontsize-name))
yuuji@0 548 (setq fontsize-name fontsize)
yuuji@4 549 (if (not (assoc fontsize-name (append user-fontsize-table fontsize-table)))
yuuji@0 550 (setq user-fontsize-table
yuuji@4 551 (cons (list fontsize-name) user-fontsize-table)
yuuji@4 552 YaTeX-user-table-modified t))
yuuji@0 553 (if arg
yuuji@0 554 (save-excursion
yuuji@0 555 (if (> (point) (mark)) (exchange-point-and-mark))
yuuji@0 556 (insert "{\\" fontsize-name " ")
yuuji@0 557 (exchange-point-and-mark)
yuuji@0 558 (insert "}"))
yuuji@0 559 (insert "{\\" fontsize-name " }")
yuuji@5 560 (if YaTeX-current-position-register
yuuji@5 561 (point-to-register YaTeX-current-position-register))
yuuji@0 562 (forward-char -1)))
yuuji@0 563 )
yuuji@0 564
yuuji@0 565 (defun YaTeX-make-fontsize-region ()
yuuji@5 566 "Call function:YaTeX-make-fontsize with ARG to specify region mode."
yuuji@0 567 (interactive)
yuuji@0 568 (YaTeX-make-fontsize t)
yuuji@0 569 )
yuuji@0 570
yuuji@0 571 (defun YaTeX-make-singlecmd (single)
yuuji@0 572 (interactive
yuuji@0 573 (list (completing-read
yuuji@0 574 (format "\\??? (default %s): " single-command)
yuuji@0 575 (append user-singlecmd-table singlecmd-table)
yuuji@0 576 nil nil )))
yuuji@0 577 (if (string= single "")
yuuji@0 578 (setq single single-command))
yuuji@0 579 (setq single-command single)
yuuji@4 580 (if (not (assoc single-command
yuuji@4 581 (append user-singlecmd-table singlecmd-table)))
yuuji@0 582 (setq user-singlecmd-table
yuuji@4 583 (cons (list single-command) user-singlecmd-table)
yuuji@4 584 YaTeX-user-table-modified t))
yuuji@0 585 (insert "\\" single-command " ")
yuuji@5 586 (if YaTeX-current-position-register
yuuji@5 587 (point-to-register YaTeX-current-position-register))
yuuji@0 588 )
yuuji@0 589
yuuji@0 590 (defvar YaTeX-completion-begin-regexp "[{\\]"
yuuji@0 591 "Regular expression of limit where LaTeX command's
yuuji@0 592 completion begins.")
yuuji@0 593
yuuji@0 594 (defun YaTeX-do-completion ()
yuuji@0 595 "Try completion on LaTeX command preceding point."
yuuji@0 596 (interactive)
yuuji@0 597 (if
yuuji@0 598 (or (eq (preceding-char) ? )
yuuji@0 599 (eq (preceding-char) ?\t)
yuuji@0 600 (eq (preceding-char) ?\n)
yuuji@0 601 (bobp))
yuuji@0 602 (message "Nothing to complete.") ;Do not complete
yuuji@0 603 (let* ((end (point))
yuuji@0 604 (limit (save-excursion (beginning-of-line) (point)))
yuuji@0 605 (completion-begin
yuuji@0 606 (progn (re-search-backward "[ \t\n]" limit 1)
yuuji@0 607 (point)))
yuuji@0 608 (begin (progn
yuuji@0 609 (goto-char end)
yuuji@0 610 (if (re-search-backward YaTeX-completion-begin-regexp
yuuji@0 611 completion-begin t)
yuuji@0 612 (1+ (point))
yuuji@0 613 nil))))
yuuji@0 614 (goto-char end)
yuuji@0 615 (cond
yuuji@0 616 ((null begin)
yuuji@0 617 (message "I think it is not LaTeX sequence."))
yuuji@0 618 (t
yuuji@0 619 (let* ((pattern (buffer-substring begin end))
yuuji@0 620 (all-table (append section-table user-section-table
yuuji@0 621 article-table user-article-table
yuuji@0 622 env-table user-env-table
yuuji@0 623 singlecmd-table user-singlecmd-table))
yuuji@0 624 ;; First,
yuuji@0 625 ;; search completion without backslash.
yuuji@0 626 (completion (try-completion pattern all-table nil)))
yuuji@0 627 (if
yuuji@0 628 (eq completion nil)
yuuji@0 629 ;; Next,
yuuji@0 630 ;; search completion with backslash
yuuji@0 631 (setq completion
yuuji@0 632 (try-completion (buffer-substring (1- begin) end)
yuuji@0 633 all-table nil)
yuuji@0 634 begin (1- begin)))
yuuji@0 635 (cond
yuuji@0 636 ((null completion)
yuuji@0 637 (message (concat "Can't find completion for '" pattern "'"))
yuuji@0 638 (ding))
yuuji@0 639 ((eq completion t) (message "Sole completion."))
yuuji@0 640 ((not (string= completion pattern))
yuuji@0 641 (kill-region begin end)
yuuji@0 642 (insert completion)
yuuji@0 643 )
yuuji@0 644 (t
yuuji@0 645 (message "Making completion list...")
yuuji@0 646 (with-output-to-temp-buffer "*Help*"
yuuji@0 647 (display-completion-list
yuuji@0 648 (all-completions pattern all-table))) )
yuuji@0 649 ))))))
yuuji@0 650 )
yuuji@0 651
yuuji@0 652 (defun YaTeX-insert-quote ()
yuuji@0 653 (interactive)
yuuji@0 654 (insert
yuuji@0 655 (cond
yuuji@5 656 ((YaTeX-quick-in-environment-p "verbatim") ?\")
yuuji@0 657 ((= (preceding-char) ?\\ ) ?\")
yuuji@0 658 ((= (preceding-char) ?\( ) ?\")
yuuji@0 659 ((= (preceding-char) 32) "``")
yuuji@0 660 ((= (preceding-char) 9) "``")
yuuji@0 661 ((= (preceding-char) ?\n) "``")
yuuji@0 662 ((bobp) "``")
yuuji@0 663 (t "''")
yuuji@0 664 )))
yuuji@0 665
yuuji@5 666 (defun YaTeX-insert-braces-region (beg end &optional open close)
yuuji@0 667 (interactive "r")
yuuji@0 668 (save-excursion
yuuji@0 669 (goto-char end)
yuuji@5 670 (insert (or close "}"))
yuuji@0 671 (goto-char beg)
yuuji@5 672 (insert (or open "{")))
yuuji@0 673 )
yuuji@0 674
yuuji@0 675 (defun YaTeX-insert-braces ()
yuuji@0 676 (interactive)
yuuji@0 677 (insert "{}")
yuuji@0 678 (forward-char -1)
yuuji@0 679 )
yuuji@0 680
yuuji@5 681 (defun YaTeX-insert-brackets-region (beg end)
yuuji@5 682 (interactive "r")
yuuji@5 683 (save-excursion
yuuji@5 684 (YaTeX-insert-braces-region beg end "[" "]"))
yuuji@5 685 )
yuuji@5 686
yuuji@0 687 (defun YaTeX-insert-dollar ()
yuuji@0 688 (interactive)
yuuji@0 689 (insert "$$")
yuuji@0 690 (forward-char -1)
yuuji@0 691 )
yuuji@0 692
yuuji@0 693 (defun YaTeX-insert-string (s)
yuuji@0 694 (insert s)
yuuji@0 695 )
yuuji@0 696
yuuji@0 697 (defun YaTeX-version ()
yuuji@0 698 "Return string of the version of running YaTeX."
yuuji@0 699 (interactive)
yuuji@0 700 (message
yuuji@5 701 (concat "Yet Another tex-mode "
yuuji@5 702 (if YaTeX-japan "u–ì’¹v" "Wild Bird")
yuuji@5 703 "Revision "
yuuji@0 704 YaTeX-revision-number))
yuuji@0 705 )
yuuji@0 706
yuuji@4 707 (defun YaTeX-typeset-sentinel (proc mes)
yuuji@0 708 (cond ((null (buffer-name (process-buffer proc)))
yuuji@0 709 ;; buffer killed
yuuji@0 710 (set-process-buffer proc nil))
yuuji@0 711 ((memq (process-status proc) '(signal exit))
yuuji@0 712 (let* ((obuf (current-buffer)))
yuuji@0 713 ;; save-excursion isn't the right thing if
yuuji@0 714 ;; process-buffer is current-buffer
yuuji@0 715 (unwind-protect
yuuji@0 716 (progn
yuuji@4 717 ;; Write something in *typesetting* and hack its mode line
yuuji@5 718 (if (equal (current-buffer) (process-buffer proc))
yuuji@5 719 nil
yuuji@5 720 (other-window 1)
yuuji@5 721 (switch-to-buffer (process-buffer proc))
yuuji@5 722 (goto-char (point-max))
yuuji@5 723 (recenter -3)
yuuji@5 724 (other-window -1))
yuuji@5 725 (set-buffer (process-buffer proc))
yuuji@0 726 (goto-char (point-max))
yuuji@5 727 (insert ?\n "latex typesetting " mes)
yuuji@0 728 (forward-char -1)
yuuji@0 729 (insert " at "
yuuji@0 730 (substring (current-time-string) 0 -5))
yuuji@0 731 (insert "\n * Hit any key to return * ")
yuuji@0 732 (forward-char 1)
yuuji@0 733 (setq mode-line-process
yuuji@0 734 (concat ": "
yuuji@0 735 (symbol-name (process-status proc))))
yuuji@5 736 (message "latex typesetting done.")
yuuji@0 737 ;; If buffer and mode line will show that the process
yuuji@0 738 ;; is dead, we can delete it now. Otherwise it
yuuji@0 739 ;; will stay around until M-x list-processes.
yuuji@0 740 (delete-process proc)
yuuji@0 741 )
yuuji@4 742 (setq YaTeX-typesetting-process nil)
yuuji@0 743 ;; Force mode line redisplay soon
yuuji@0 744 (set-buffer-modified-p (buffer-modified-p))
yuuji@0 745 )
yuuji@0 746 (set-buffer obuf)
yuuji@0 747 )))
yuuji@0 748 )
yuuji@0 749
yuuji@4 750 (defvar YaTeX-typesetting-process nil
yuuji@0 751 "Process identifier for jlatex"
yuuji@0 752 )
yuuji@5 753 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
yuuji@5 754 "Process buffer for jlatex")
yuuji@0 755
yuuji@5 756 (defun YaTeX-typeset (command)
yuuji@4 757 "Execute jlatex (or other) to LaTeX typeset."
yuuji@0 758 (interactive)
yuuji@4 759 (if YaTeX-typesetting-process
yuuji@4 760 (if (eq (process-status YaTeX-typesetting-process) 'run)
yuuji@4 761 (progn (interrupt-process YaTeX-typesetting-process)
yuuji@5 762 ;(sit-for 1)
yuuji@4 763 (delete-process YaTeX-typesetting-process))
yuuji@0 764 nil) nil)
yuuji@4 765 (setq YaTeX-typesetting-process nil)
yuuji@0 766 (if (eq system-type 'ms-dos) ;if MS-DOS
yuuji@5 767 (with-output-to-temp-buffer YaTeX-typeset-buffer
yuuji@5 768 (message (concat "Typesetting " (buffer-name) "..."))
yuuji@1 769 (YaTeX-put-nonstopmode)
yuuji@1 770 (call-process shell-file-name
yuuji@5 771 nil YaTeX-typeset-buffer nil "/c" command)
yuuji@1 772 (YaTeX-remove-nonstopmode))
yuuji@4 773 (setq YaTeX-typesetting-process ;if UNIX
yuuji@5 774 (with-output-to-temp-buffer YaTeX-typeset-buffer
yuuji@5 775 (start-process "LaTeX" YaTeX-typeset-buffer shell-file-name "-c"
yuuji@5 776 command)
yuuji@0 777 ))
yuuji@4 778 (set-process-sentinel YaTeX-typesetting-process 'YaTeX-typeset-sentinel))
yuuji@0 779 (setq current-TeX-buffer (buffer-name))
yuuji@0 780 (other-window 1)
yuuji@4 781 (use-local-map YaTeX-typesetting-mode-map)
yuuji@5 782 (setq mode-name "typeset")
yuuji@5 783 (if YaTeX-typesetting-process ; if process is running (maybe on UNIX)
yuuji@5 784 (cond ((boundp 'MULE)
yuuji@5 785 (set-current-process-coding-system
yuuji@5 786 YaTeX-latex-message-code YaTeX-coding-system))
yuuji@5 787 ((boundp 'NEMACS)
yuuji@5 788 (set-kanji-process-code YaTeX-latex-message-code))))
yuuji@0 789 (message "Type SPC to continue.")
yuuji@0 790 (goto-char (point-max))
yuuji@5 791 (sit-for 1)
yuuji@5 792 (if (eq system-type 'ms-dos) (message "") (read-char));hit any key
yuuji@5 793 (forward-line -1)
yuuji@5 794 (recenter -1)
yuuji@0 795 (other-window -1)
yuuji@0 796 )
yuuji@0 797
yuuji@5 798 (defun YaTeX-typeset-region ()
yuuji@5 799 "Paste the region to the file `texput.tex' and execute jlatex (or other)
yuuji@5 800 to LaTeX typeset. The region is specified by the rule:
yuuji@5 801 (1)If keyword `%#BEGIN' is found in the upper direction from (point).
yuuji@5 802 (1-1)if the keyword `%#END' is found after `%#BEGIN',
yuuji@5 803 ->Assume the text between `%#BEGIN' and `%#END' as region.
yuuji@5 804 (1-2)if the keyword `%#END' is not found anywhere after `%#BEGIN',
yuuji@5 805 ->Assume the text after `%#BEGIN' as region.
yuuji@5 806 (2)If no `%#BEGIN' usage is found before the (point),
yuuji@5 807 ->Assume the text between current (point) and (mark) as region.
yuuji@5 808 DON'T forget to eliminate the `%#BEGIN/%#END' notation after editing
yuuji@5 809 operation to the region."
yuuji@5 810 (interactive)
yuuji@5 811 (save-excursion
yuuji@5 812 (let*
yuuji@5 813 ((end "") typeout ;Type out message that tells the method of cutting.
yuuji@5 814 (buffer (current-buffer)) opoint preamble
yuuji@5 815 (region
yuuji@5 816 (if (re-search-backward
yuuji@5 817 "%#BEGIN" nil t)
yuuji@5 818 (progn
yuuji@5 819 (setq typeout "--- Region from BEGIN to " end "END ---")
yuuji@5 820 (buffer-substring
yuuji@5 821 (match-end 0)
yuuji@5 822 (if (re-search-forward "%#END" nil t)
yuuji@5 823 (match-beginning 0)
yuuji@5 824 (setq end "end of buffer ---")
yuuji@5 825 (point-max))))
yuuji@5 826 (setq typeout "=== Region from (point) to (mark) ===")
yuuji@5 827 (buffer-substring (point) (mark)))))
yuuji@5 828 (YaTeX-visit-main)
yuuji@5 829 (setq opoint (point))
yuuji@5 830 (goto-char (point-min))
yuuji@5 831 (setq
yuuji@5 832 preamble
yuuji@5 833 (if (re-search-forward "^[ ]*\\\\begin.*{document}" nil t)
yuuji@5 834 (buffer-substring (point-min) (match-end 0))
yuuji@5 835 (concat "\\documentstyle{" YaTeX-default-document-style "}\n"
yuuji@5 836 "\\begin{document}")))
yuuji@5 837 (goto-char opoint)
yuuji@5 838 (switch-to-buffer buffer) ;for clarity
yuuji@5 839 (find-file "texput.tex")
yuuji@5 840 (erase-buffer)
yuuji@5 841 (if YaTeX-need-nonstop
yuuji@5 842 (insert "\\nonstopmode{}\n"))
yuuji@5 843 (insert preamble "\n")
yuuji@5 844 (insert region)
yuuji@5 845 (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
yuuji@5 846 (insert "\n\\end{document}\n")
yuuji@5 847 (basic-save-buffer)
yuuji@5 848 (kill-buffer (current-buffer))
yuuji@5 849 (YaTeX-typeset (concat (YaTeX-get-latex-command nil) " texput.tex"))))
yuuji@5 850 )
yuuji@5 851
yuuji@5 852 (defun YaTeX-typeset-buffer ()
yuuji@5 853 "Typeset whole buffer."
yuuji@5 854 (interactive)
yuuji@5 855 (if (YaTeX-main-file-p) nil
yuuji@5 856 (let*((me (substring (buffer-name) 0 (rindex (buffer-name) ?.))))
yuuji@5 857 (save-excursion ;save excursion of current buffer.
yuuji@5 858 (YaTeX-visit-main)
yuuji@5 859 (save-excursion ;save excursion of main .tex buffer
yuuji@5 860 (push-mark (point) t)
yuuji@5 861 (goto-char (point-min))
yuuji@5 862 (if (and (re-search-forward "^[ ]*\\\\begin{document}" nil t)
yuuji@5 863 (re-search-backward "^[ ]*\\\\includeonly{" nil t))
yuuji@5 864 (let*
yuuji@5 865 ((b (progn (skip-chars-forward "^{") (point)))
yuuji@5 866 (e (progn (skip-chars-forward "^}") (1+ (point))))
yuuji@5 867 (s (buffer-substring b e)) c)
yuuji@5 868 (if (string-match (concat "[{,]" me "[,}]") s)
yuuji@5 869 nil
yuuji@5 870 (ding)
yuuji@5 871 (message
yuuji@5 872 "File:`%s' is not in includeonly list. A)ppend R)eplace %%)comment? " me)
yuuji@5 873 (setq c (read-char))
yuuji@5 874 (cond
yuuji@5 875 ((= c ?a)
yuuji@5 876 (goto-char (1+ b))
yuuji@5 877 (insert me (if (string= s "{}") "" ",")))
yuuji@5 878 ((= c ?r)
yuuji@5 879 (delete-region (1+ b) (1- e)) (insert me))
yuuji@5 880 ((= c ?%)
yuuji@5 881 (beginning-of-line) (insert "%"))
yuuji@5 882 (t nil))
yuuji@5 883 (basic-save-buffer))))
yuuji@5 884 (exchange-point-and-mark))
yuuji@5 885 )))
yuuji@5 886 (YaTeX-save-buffers)
yuuji@5 887 (YaTeX-typeset (YaTeX-get-latex-command t))
yuuji@5 888 )
yuuji@5 889
yuuji@0 890 (defun YaTeX-preview (preview-command preview-file)
yuuji@0 891 "Execute xdvi (or other) to tex-preview."
yuuji@0 892 (interactive
yuuji@0 893 (list (read-string "Preview command: " dvi2-command)
yuuji@0 894 (read-string "Prefiew file[.dvi]: "
yuuji@3 895 ;;(substring (buffer-name) 0 -4)
yuuji@3 896 (YaTeX-get-preview-file-name) ;ver 1.31
yuuji@0 897 )))
yuuji@0 898 (setq dvi2-command preview-command)
yuuji@0 899 (with-output-to-temp-buffer "*dvi-preview*"
yuuji@0 900 (if (eq system-type 'ms-dos)
yuuji@0 901 (progn (send-string-to-terminal "\e[2J") ;if MS-DOS
yuuji@0 902 (call-process shell-file-name "con" "*dvi-preview*" nil
yuuji@0 903 "/c " dvi2-command preview-file)
yuuji@0 904 (redraw-display))
yuuji@0 905 (start-process "xdvi" "*dvi-preview*" shell-file-name "-c"
yuuji@0 906 (concat dvi2-command " " preview-file)) ;if UNIX
yuuji@0 907 (message (concat "Starting " dvi2-command " to preview " preview-file)))
yuuji@0 908 )
yuuji@0 909 )
yuuji@0 910
yuuji@0 911 (defun YaTeX-prev-error ()
yuuji@0 912 "Visit previous error. The reason why not NEXT-error is to
yuuji@0 913 avoid make confliction of line numbers by editing."
yuuji@0 914 (interactive)
yuuji@5 915 (let ((cur-buf (buffer-name))
yuuji@5 916 YaTeX-error-line error-buffer)
yuuji@5 917 (if (null (get-buffer YaTeX-typeset-buffer))
yuuji@5 918 (message "There is no output buffer of typesetting.")
yuuji@5 919 (pop-to-buffer YaTeX-typeset-buffer)
yuuji@5 920 (if (eq system-type 'ms-dos)
yuuji@5 921 (if (search-backward latex-dos-emergency-message nil t)
yuuji@5 922 (progn (goto-char (point-max))
yuuji@5 923 (setq error-regexp latex-error-regexp))
yuuji@5 924 (beginning-of-line)
yuuji@5 925 (forward-char -1)
yuuji@5 926 (setq error-regexp latex-warning-regexp))
yuuji@5 927 (if YaTeX-typesetting-process ; if jlatex on UNIX
yuuji@5 928 (if (eq (process-status YaTeX-typesetting-process) 'run)
yuuji@5 929 (progn
yuuji@5 930 (goto-char (point-max))
yuuji@5 931 (setq error-regexp latex-error-regexp)))
yuuji@0 932 (beginning-of-line)
yuuji@5 933 (setq error-regexp latex-warning-regexp)))
yuuji@5 934 (if (re-search-backward error-regexp nil t)
yuuji@5 935 (save-restriction
yuuji@5 936 (set-mark-command nil)
yuuji@5 937 (end-of-line)
yuuji@5 938 (narrow-to-region (point) (mark))
yuuji@5 939 (goto-char (point-min))
yuuji@5 940 (re-search-forward "[0-9]")
yuuji@5 941 (forward-char -1)
yuuji@5 942 (set-mark (point))
yuuji@5 943 (skip-chars-forward "0-9")
yuuji@5 944 (narrow-to-region (point) (mark))
yuuji@5 945 (goto-char (point-min))
yuuji@5 946 (setq YaTeX-error-line (read (current-buffer))))
yuuji@5 947 (message "No more error on %s" cur-buf)
yuuji@5 948 (ding)
yuuji@5 949 )
yuuji@5 950 (setq error-buffer (YaTeX-get-error-file cur-buf))
yuuji@0 951 (other-window -1)
yuuji@5 952 (switch-to-buffer cur-buf)
yuuji@5 953 (if (null YaTeX-error-line)
yuuji@5 954 nil
yuuji@5 955 ;; if warning or error found
yuuji@5 956 (YaTeX-switch-to-buffer error-buffer)
yuuji@5 957 (goto-line YaTeX-error-line)
yuuji@5 958 (message "latex error or warning in '%s' at line: %d"
yuuji@5 959 error-buffer YaTeX-error-line)
yuuji@5 960 (other-window 1)
yuuji@5 961 (skip-chars-backward "[0-9]")
yuuji@5 962 (recenter (/ (window-height) 2))
yuuji@5 963 (sit-for 3)
yuuji@5 964 (forward-line -1)
yuuji@5 965 (other-window -1)
yuuji@5 966 )))
yuuji@0 967 )
yuuji@0 968
yuuji@0 969 (defun YaTeX-jump-error-line ()
yuuji@0 970 "Jump corresponding line on latex command's error message."
yuuji@0 971 (interactive)
yuuji@0 972 (let ((end (progn (end-of-line) (point)))
yuuji@0 973 (begin (progn (beginning-of-line)(point))))
yuuji@0 974 (if (null (re-search-forward "l[ ines]*\\.*[1-9][0-9]*" end t))
yuuji@0 975 (message "No line number expression")
yuuji@0 976 (goto-char (match-beginning 0))
yuuji@0 977 (re-search-forward "[1-9][0-9]*" end t)
yuuji@0 978 (save-restriction
yuuji@5 979 (let ((error-line
yuuji@5 980 (string-to-int (buffer-substring (match-beginning 0)
yuuji@5 981 (match-end 0))))
yuuji@5 982 (error-file (YaTeX-get-error-file current-TeX-buffer)))
yuuji@5 983 (goto-char (match-beginning 0))
yuuji@0 984 (other-window -1)
yuuji@5 985 (message "errors in %s" error-file)
yuuji@5 986 ;(switch-to-buffer current-TeX-buffer)
yuuji@5 987 (if (not (YaTeX-switch-to-buffer error-file))
yuuji@5 988 (error "%s is not found in this directory."))
yuuji@0 989 (goto-line error-line)))))
yuuji@0 990 )
yuuji@0 991
yuuji@0 992 (defun YaTeX-view-error ()
yuuji@0 993 (interactive)
yuuji@5 994 (if (null (get-buffer YaTeX-typeset-buffer))
yuuji@5 995 (message "No typeset buffer found.")
yuuji@5 996 (pop-to-buffer YaTeX-typeset-buffer)
yuuji@5 997 (goto-char (point-max))
yuuji@5 998 (recenter -1)
yuuji@5 999 (other-window -1))
yuuji@0 1000 )
yuuji@0 1001
yuuji@5 1002 (defun YaTeX-get-error-file (default)
yuuji@5 1003 "Get current processing file by tex message."
yuuji@5 1004 (let (file-name)
yuuji@5 1005 (save-excursion
yuuji@5 1006 (if (re-search-backward "([-A-Z_a-z0-9]+.tex" (point-min) t)
yuuji@5 1007 (buffer-substring (1+ (match-beginning 0)) (match-end 0))
yuuji@5 1008 default)))
yuuji@5 1009 )
yuuji@5 1010
yuuji@1 1011 (defun YaTeX-put-nonstopmode ()
yuuji@5 1012 (if YaTeX-need-nonstop
yuuji@1 1013 (if (re-search-backward "\\nonstopmode{}" (point-min) t)
yuuji@1 1014 nil ;if already written in text then do nothing
yuuji@1 1015 (save-excursion
yuuji@1 1016 (goto-char (point-min))
yuuji@1 1017 (insert "\\nonstopmode{}%_YaTeX_%\n")))
yuuji@1 1018 )
yuuji@1 1019 )
yuuji@1 1020
yuuji@1 1021 (defun YaTeX-remove-nonstopmode ()
yuuji@5 1022 (if YaTeX-need-nonstop ;for speed
yuuji@1 1023 (save-excursion
yuuji@1 1024 (goto-char (point-min))
yuuji@1 1025 (forward-line 1)
yuuji@1 1026 (narrow-to-region (point-min) (point))
yuuji@1 1027 (goto-char (point-min))
yuuji@1 1028 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
yuuji@1 1029 (widen)))
yuuji@1 1030 )
yuuji@1 1031
yuuji@5 1032 (defun YaTeX-typeset-menu (arg)
yuuji@4 1033 "Typeset, preview, visit error and miscellaneous convinient menu."
yuuji@5 1034 (interactive "P")
yuuji@5 1035 (message "J)latex R)egion P)review V)iewerror L)pr")
yuuji@4 1036 (let ((c (read-char)))
yuuji@4 1037 (cond
yuuji@5 1038 ((= c ?j) (YaTeX-typeset-buffer))
yuuji@5 1039 ((= c ?r) (YaTeX-typeset-region))
yuuji@4 1040 ((= c ?p) (call-interactively 'YaTeX-preview))
yuuji@4 1041 ((= c ?v) (YaTeX-view-error))
yuuji@5 1042 ((= c ?l) (YaTeX-lpr arg))
yuuji@4 1043 ((= c ?b) (YaTeX-insert-string "\\"))))
yuuji@4 1044 )
yuuji@4 1045
yuuji@3 1046 (defun YaTeX-get-preview-file-name ()
yuuji@3 1047 "Get file name to preview by inquiring YaTeX-get-latex-command"
yuuji@5 1048 (let* ((latex-cmd (YaTeX-get-latex-command t))
yuuji@3 1049 (fname (substring latex-cmd (1+ (rindex latex-cmd ? ))))
yuuji@3 1050 (period))
yuuji@3 1051 (if (eq fname "")
yuuji@3 1052 (setq fname (substring (buffer-name) 0 -4))
yuuji@3 1053 (setq period (rindex fname ?.))
yuuji@3 1054 (setq fname (substring fname 0 (if (eq -1 period) nil period)))
yuuji@3 1055 ))
yuuji@3 1056 )
yuuji@3 1057
yuuji@5 1058 (defun YaTeX-get-latex-command (switch)
yuuji@1 1059 "Specify the latex-command name and its argument.
yuuji@1 1060 If there is a line which begins by string: \"%#!\", the following
yuuji@1 1061 strings are assumed to be the latex-command and arguments. The
yuuji@1 1062 default value of latex-command is:
yuuji@1 1063 tex-command (buffer-name)
yuuji@1 1064 and if you write \"%#!jlatex\" in the beginning of certain line.
yuuji@1 1065 \"jlatex \" (buffer-name)
yuuji@1 1066 will be the latex-command,
yuuji@5 1067 and you write \"%#!jlatex main.tex\" on some line and argument SWITCH
yuuji@5 1068 is t, then
yuuji@1 1069 \"jlatex main.tex\"
yuuji@1 1070 will be given to the shell."
yuuji@1 1071 (let*
yuuji@1 1072 ((default-command
yuuji@5 1073 (concat tex-command " "
yuuji@5 1074 (if switch (buffer-name) ""))));default value
yuuji@1 1075 (save-excursion
yuuji@1 1076 (goto-char (point-min))
yuuji@1 1077 (if (null (re-search-forward "^%#!" (point-max) t))
yuuji@1 1078 default-command
yuuji@1 1079 (skip-chars-forward "%#! ")
yuuji@5 1080 (if (eolp)
yuuji@1 1081 default-command
yuuji@1 1082 (let ((s (point)))
yuuji@1 1083 (skip-chars-forward "A-z") ;Skip command name
yuuji@1 1084 ;(setq YaTeX-latex-command (buffer-substring s (point)))
yuuji@5 1085 (cond
yuuji@5 1086 ((null switch)
yuuji@5 1087 (buffer-substring s (point)))
yuuji@5 1088 ((eolp) ;Only return command name
yuuji@5 1089 (concat (buffer-substring s (point)) " " (buffer-name)))
yuuji@5 1090 (t(end-of-line) ;Change entire command name
yuuji@5 1091 (buffer-substring s (point))) ;including arguments.
yuuji@1 1092 ))
yuuji@1 1093 ))))
yuuji@1 1094 )
yuuji@1 1095
yuuji@5 1096 (defun YaTeX-get-builtin (key)
yuuji@5 1097 "Read source built-in command of %# usage."
yuuji@5 1098 (save-excursion
yuuji@5 1099 (goto-char (point-min))
yuuji@5 1100 (if (and (search-forward (concat "%#" key) nil t)
yuuji@5 1101 (not (eolp)))
yuuji@5 1102 (buffer-substring
yuuji@5 1103 (progn (skip-chars-forward " " (point-end-of-line))(point))
yuuji@5 1104 (point-end-of-line))
yuuji@5 1105 nil))
yuuji@5 1106 )
yuuji@5 1107
yuuji@3 1108 (defun YaTeX-goto-corresponding-environment ()
yuuji@3 1109 "Go to corresponding begin/end enclosure."
yuuji@3 1110 (interactive)
yuuji@5 1111 (if (not (YaTeX-on-begin-end-p)) nil
yuuji@5 1112 (let ((p (match-end 0)) env (nest 0) regexp re-s
yuuji@5 1113 (m0 (match-beginning 0))
yuuji@5 1114 (m1 (match-beginning 1))
yuuji@5 1115 (m2 (match-beginning 2)))
yuuji@5 1116 (if (not
yuuji@5 1117 (save-excursion
yuuji@5 1118 (goto-char p)
yuuji@5 1119 (search-forward "}" (point-end-of-line) t)))
yuuji@5 1120 (error "Unterminated brackets for begin/end"))
yuuji@5 1121 (setq env (buffer-substring p (match-beginning 0))) ;get current env
yuuji@5 1122 (if (cond
yuuji@5 1123 ((equal m0 m1) ;if begin{xxx}
yuuji@5 1124 (setq regexp (concat "\\(\\\\end{" env "}\\)\\|"
yuuji@5 1125 "\\(\\\\begin{" env "}\\)"))
yuuji@5 1126 (fset re-s 're-search-forward))
yuuji@5 1127 ((equal m0 m2) ;if end{xxx}
yuuji@5 1128 (setq regexp (concat "\\(\\\\begin{" env "}\\)\\|"
yuuji@5 1129 "\\(\\\\end{" env "}\\)"))
yuuji@5 1130 (fset re-s 're-search-backward))
yuuji@5 1131 (error "Corresponding environment not found."))
yuuji@5 1132 (while (and (>= nest 0) (funcall re-s regexp nil t))
yuuji@5 1133 (if (eq (match-beginning 0) m0) nil
yuuji@5 1134 (setq nest (if (eq (match-beginning 0) (match-beginning 1))
yuuji@5 1135 (1- nest) (1+ nest))))))
yuuji@5 1136 (beginning-of-line));let
yuuji@5 1137 t); if on begin/end line
yuuji@3 1138 )
yuuji@3 1139
yuuji@5 1140 (defun YaTeX-goto-corresponding-file ()
yuuji@5 1141 "Visit or switch buffer of corresponding file, looking at \\input or
yuuji@5 1142 \\include or \includeonly on current line."
yuuji@5 1143 (if (not (YaTeX-on-includes-p)) nil
yuuji@5 1144 (beginning-of-line)
yuuji@5 1145 (skip-chars-forward "^{")
yuuji@5 1146 (let ((input-file
yuuji@5 1147 (concat
yuuji@5 1148 (buffer-substring (1+ (point))
yuuji@5 1149 (progn (skip-chars-forward "^ ,}") (point)))
yuuji@5 1150 ".tex")))
yuuji@5 1151 (YaTeX-switch-to-buffer input-file)
yuuji@5 1152 )
yuuji@5 1153 t);if on \input or \include line.
yuuji@5 1154 )
yuuji@5 1155
yuuji@5 1156 (defun YaTeX-goto-corresponding-BEGIN-END ()
yuuji@5 1157 (if (not (YaTeX-on-BEGIN-END-p)) nil
yuuji@5 1158 (if (cond
yuuji@5 1159 ((equal (match-beginning 0) (match-beginning 1)) ;if on %#BEGIN
yuuji@5 1160 (not (search-forward "%#END" nil t)))
yuuji@5 1161 (t ; if on %#END
yuuji@5 1162 (not (search-backward "%#BEGIN" nil t))))
yuuji@5 1163 (error "Corresponding %#BEGIN/END not found."))
yuuji@5 1164 (beginning-of-line)
yuuji@5 1165 t)
yuuji@5 1166 )
yuuji@5 1167
yuuji@5 1168 (defun YaTeX-switch-to-buffer (file)
yuuji@5 1169 "Switch to buffer if buffer exists, find file if not."
yuuji@5 1170 (interactive "Fswitch to file: ")
yuuji@5 1171 (if (get-buffer file)
yuuji@5 1172 (progn (switch-to-buffer file) t)
yuuji@5 1173 (if (file-exists-p file)
yuuji@5 1174 (progn (find-file file) t)
yuuji@5 1175 (message "%s was not found in this directory." file)
yuuji@5 1176 nil))
yuuji@5 1177 )
yuuji@5 1178
yuuji@5 1179 (defun YaTeX-switch-to-buffer-other-window (file)
yuuji@5 1180 "Switch to buffer if buffer exists, find file if not."
yuuji@5 1181 (interactive "Fswitch to file: ")
yuuji@5 1182 (if (get-buffer file)
yuuji@5 1183 (progn (switch-to-buffer-other-window file) t)
yuuji@5 1184 (if (file-exists-p file)
yuuji@5 1185 (progn (find-file-other-window file) t)
yuuji@5 1186 (message "%s was not found in this directory." file)
yuuji@5 1187 nil))
yuuji@5 1188 )
yuuji@5 1189
yuuji@5 1190 (defmacro YaTeX-main-file-p ()
yuuji@5 1191 "Return if current buffer is main LaTeX source."
yuuji@5 1192 (string-match (concat "^" (YaTeX-get-preview-file-name) ".tex")(buffer-name))
yuuji@5 1193 )
yuuji@5 1194
yuuji@5 1195 (defun YaTeX-visit-main ()
yuuji@5 1196 "Switch to buffer main LaTeX source."
yuuji@5 1197 (interactive)
yuuji@5 1198 (let ((main-file (YaTeX-get-preview-file-name)))
yuuji@5 1199 (if (string-match (concat "^" main-file ".tex") (buffer-name))
yuuji@5 1200 (message "I think this is main LaTeX source.")
yuuji@5 1201 (YaTeX-switch-to-buffer (concat main-file ".tex"))))
yuuji@5 1202 nil
yuuji@5 1203 )
yuuji@5 1204
yuuji@5 1205 (defun YaTeX-visit-main-other-window ()
yuuji@5 1206 "Switch to buffer main LaTeX source in other window."
yuuji@5 1207 (interactive)
yuuji@5 1208 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
yuuji@5 1209 (YaTeX-switch-to-buffer-other-window
yuuji@5 1210 (concat (YaTeX-get-preview-file-name) ".tex")))
yuuji@5 1211 )
yuuji@5 1212
yuuji@5 1213 (defun YaTeX-on-begin-end-p ()
yuuji@5 1214 (save-excursion
yuuji@5 1215 (beginning-of-line)
yuuji@5 1216 (re-search-forward
yuuji@5 1217 "\\(\\\\begin{\\)\\|\\(\\\\end{\\)" (point-end-of-line) t))
yuuji@5 1218 )
yuuji@5 1219 (defun YaTeX-on-includes-p ()
yuuji@5 1220 (save-excursion
yuuji@5 1221 (beginning-of-line)
yuuji@5 1222 (re-search-forward "\\(\\(include.*\\)\\|\\(input\\)\\){.*}"
yuuji@5 1223 (point-end-of-line) t))
yuuji@5 1224 )
yuuji@5 1225 (defun YaTeX-on-BEGIN-END-p ()
yuuji@5 1226 (save-excursion
yuuji@5 1227 (let ((case-fold-sea nil))
yuuji@5 1228 (beginning-of-line)
yuuji@5 1229 (re-search-forward "\\(%#BEGIN\\)\\|\\(%#END\\)" (point-end-of-line) t)))
yuuji@5 1230 )
yuuji@5 1231 (defun YaTeX-goto-corresponding-* ()
yuuji@5 1232 "Parse current line and call suitable function."
yuuji@5 1233 (interactive)
yuuji@5 1234 (cond
yuuji@5 1235 ((YaTeX-goto-corresponding-environment))
yuuji@5 1236 ((YaTeX-goto-corresponding-file))
yuuji@5 1237 ((YaTeX-goto-corresponding-BEGIN-END))
yuuji@5 1238 (t (message "I don't know where to go.")))
yuuji@5 1239 )
yuuji@5 1240
yuuji@5 1241 (defun YaTeX-comment-region (alt-prefix)
yuuji@4 1242 "Comment out region by '%'. If you call this function on the 'begin{}' or
yuuji@4 1243 'end{}' line, it comments out whole environment"
yuuji@5 1244 (interactive "P")
yuuji@4 1245 (if (not (YaTeX-on-begin-end-p))
yuuji@5 1246 (comment-region
yuuji@5 1247 (if alt-prefix
yuuji@5 1248 (read-string "Insert prefix: ")
yuuji@5 1249 YaTeX-comment-prefix))
yuuji@4 1250 (YaTeX-comment-uncomment-env 'comment-region))
yuuji@4 1251 )
yuuji@4 1252
yuuji@5 1253 (defun YaTeX-uncomment-region (alt-prefix)
yuuji@4 1254 "Uncomment out region by '%'."
yuuji@5 1255 (interactive "P")
yuuji@4 1256 (if (not (YaTeX-on-begin-end-p))
yuuji@5 1257 (uncomment-region
yuuji@5 1258 (if alt-prefix (read-string "Remove prefix: ")
yuuji@5 1259 YaTeX-comment-prefix))
yuuji@4 1260 (YaTeX-comment-uncomment-env 'uncomment-region))
yuuji@4 1261 )
yuuji@4 1262
yuuji@4 1263 (defun YaTeX-comment-uncomment-env (func)
yuuji@4 1264 "Comment or uncomment out one LaTeX environment switching function by FUNC."
yuuji@4 1265 (save-excursion
yuuji@4 1266 (if (eq (match-beginning 0) (match-beginning 2)) ; if on the '\end{}' line
yuuji@4 1267 (YaTeX-goto-corresponding-environment)) ; goto '\begin{}' line
yuuji@4 1268 (beginning-of-line)
yuuji@5 1269 (push-mark (point) t)
yuuji@4 1270 (YaTeX-goto-corresponding-environment)
yuuji@4 1271 (forward-line 1)
yuuji@4 1272 (funcall func YaTeX-comment-prefix t) ; t makes uncomment once
yuuji@4 1273 )
yuuji@4 1274 )
yuuji@4 1275
yuuji@4 1276 (defun YaTeX-mark-environment ()
yuuji@4 1277 "Not implemented yet."
yuuji@4 1278 )
yuuji@4 1279
yuuji@3 1280 (defun YaTeX-comment-paragraph ()
yuuji@3 1281 "Comment out current paragraph."
yuuji@3 1282 (interactive)
yuuji@3 1283 (save-excursion
yuuji@4 1284 (if (YaTeX-on-begin-end-p)
yuuji@4 1285 (progn
yuuji@4 1286 (beginning-of-line)
yuuji@4 1287 (insert YaTeX-comment-prefix)
yuuji@4 1288 (YaTeX-goto-corresponding-environment)
yuuji@4 1289 (beginning-of-line)
yuuji@4 1290 (insert YaTeX-comment-prefix))
yuuji@4 1291 (mark-paragraph)
yuuji@4 1292 (if (not (bobp)) (forward-line 1))
yuuji@4 1293 (comment-region "%")))
yuuji@3 1294 )
yuuji@3 1295
yuuji@3 1296 (defun YaTeX-uncomment-paragraph ()
yuuji@3 1297 "Uncomment current paragraph."
yuuji@3 1298 (interactive)
yuuji@3 1299 (save-excursion
yuuji@4 1300 (if (YaTeX-on-begin-end-p)
yuuji@4 1301 (progn
yuuji@4 1302 (YaTeX-remove-prefix YaTeX-comment-prefix t)
yuuji@4 1303 (YaTeX-goto-corresponding-environment)
yuuji@4 1304 (YaTeX-remove-prefix YaTeX-comment-prefix t))
yuuji@4 1305 (let ((prefix fill-prefix))
yuuji@4 1306 (setq fill-prefix "")
yuuji@4 1307 (mark-paragraph)
yuuji@4 1308 (if (not (bobp)) (forward-line 1))
yuuji@4 1309 (uncomment-region "%")
yuuji@4 1310 (setq fill-prefix prefix))))
yuuji@4 1311 )
yuuji@4 1312
yuuji@4 1313 (defun YaTeX-remove-prefix (prefix &optional once)
yuuji@4 1314 "Remove prefix on current line so far as prefix detected. But
yuuji@4 1315 optional argument ONCE makes deletion once."
yuuji@4 1316 (interactive "sPrefix:")
yuuji@4 1317 (beginning-of-line)
yuuji@4 1318 (while (re-search-forward (concat "^" prefix) (point-end-of-line) t)
yuuji@4 1319 (replace-match "")
yuuji@4 1320 (if once (end-of-line)))
yuuji@3 1321 )
yuuji@3 1322
yuuji@5 1323 (defun YaTeX-kill-some-pairs (predicate gofunc)
yuuji@5 1324 "Kill some matching pair."
yuuji@5 1325 (interactive)
yuuji@5 1326 (if ;(not (YaTeX-on-begin-end-p)) nil
yuuji@5 1327 (not (funcall predicate)) nil
yuuji@5 1328 (save-excursion
yuuji@5 1329 (push-mark (point) t)
yuuji@5 1330 ;(YaTeX-goto-corresponding-environment)
yuuji@5 1331 (funcall gofunc)
yuuji@5 1332 (beginning-of-line)
yuuji@5 1333 (kill-line 1)
yuuji@5 1334 (exchange-point-and-mark)
yuuji@5 1335 (beginning-of-line)
yuuji@5 1336 (kill-line 1)
yuuji@5 1337 t))
yuuji@5 1338 )
yuuji@5 1339
yuuji@5 1340 (defun YaTeX-read-environment (prompt)
yuuji@5 1341 "Read the LaTeX environment name with completion."
yuuji@5 1342 (let ((env
yuuji@5 1343 (completing-read prompt (append user-env-table env-table) nil nil)))
yuuji@5 1344 (if (not (assoc env (append user-env-table env-table)))
yuuji@5 1345 (setq user-env-table (cons (list env) user-env-table)
yuuji@5 1346 YaTeX-user-table-modified t))
yuuji@5 1347 env)
yuuji@5 1348 )
yuuji@5 1349
yuuji@5 1350 (defun YaTeX-change-environment ()
yuuji@5 1351 "Change the name of environment."
yuuji@5 1352 (interactive)
yuuji@5 1353 (if (not (YaTeX-on-begin-end-p)) nil
yuuji@5 1354 (save-excursion
yuuji@5 1355 (let (p env)
yuuji@5 1356 (beginning-of-line)
yuuji@5 1357 (skip-chars-forward "^{")
yuuji@5 1358 (forward-char 1)
yuuji@5 1359 (setq p (point))
yuuji@5 1360 (skip-chars-forward "^}")
yuuji@5 1361 (setq env (buffer-substring p (point)))
yuuji@5 1362 (beginning-of-line)
yuuji@5 1363 (set-mark-command nil)
yuuji@5 1364 (YaTeX-goto-corresponding-environment)
yuuji@5 1365 (setq newenv (YaTeX-read-environment
yuuji@5 1366 (format "Change environment `%s' to: " env)))
yuuji@5 1367 (if (string= newenv "")
yuuji@5 1368 (message "Change environment cancelled.")
yuuji@5 1369 (search-forward (concat "{" env) (point-end-of-line) t)
yuuji@5 1370 (replace-match (concat "{" newenv))
yuuji@5 1371 (exchange-point-and-mark)
yuuji@5 1372 (search-forward (concat "{" env) (point-end-of-line) t)
yuuji@5 1373 (replace-match (concat "{" newenv)))
yuuji@5 1374 t)))
yuuji@5 1375 )
yuuji@5 1376
yuuji@5 1377 (defun YaTeX-kill-* ()
yuuji@5 1378 "Parse current line and call suitable function."
yuuji@5 1379 (interactive)
yuuji@5 1380 (cond
yuuji@5 1381 ((YaTeX-kill-some-pairs 'YaTeX-on-begin-end-p
yuuji@5 1382 'YaTeX-goto-corresponding-environment))
yuuji@5 1383 ((YaTeX-kill-some-pairs 'YaTeX-on-BEGIN-END-p
yuuji@5 1384 'YaTeX-goto-corresponding-BEGIN-END))
yuuji@5 1385 (t (message "I don't know what to kill.")))
yuuji@5 1386 )
yuuji@5 1387
yuuji@5 1388 (defun YaTeX-change-* ()
yuuji@5 1389 "Parse current line and call suitable function."
yuuji@5 1390 (interactive)
yuuji@5 1391 (cond
yuuji@5 1392 ((YaTeX-change-environment))
yuuji@5 1393 (t (message "I don't know what to change.")))
yuuji@5 1394 )
yuuji@5 1395
yuuji@5 1396 (defun YaTeX-addin (name)
yuuji@5 1397 "Check availability of addin function and call it if exists."
yuuji@5 1398 (if (fboundp (intern-soft (concat "YaTeX:" name)))
yuuji@5 1399 (funcall (intern (concat "YaTeX:" name))))
yuuji@5 1400 )
yuuji@5 1401
yuuji@5 1402 (defun YaTeX-in-environment-p (env)
yuuji@5 1403 "Return if current LaTeX environment is ENV."
yuuji@5 1404 (let ((cur-env (YaTeX-inner-environment)) p)
yuuji@5 1405 (cond
yuuji@5 1406 ((atom env) (equal env cur-env))
yuuji@5 1407 ((listp env)
yuuji@5 1408 (while (and env (not p))
yuuji@5 1409 (setq p (equal (car env) cur-env))
yuuji@5 1410 (setq env (cdr env)))
yuuji@5 1411 p)))
yuuji@5 1412 )
yuuji@5 1413
yuuji@5 1414 (defun YaTeX-quick-in-environment-p (env)
yuuji@5 1415 "Check quickly but unsure if current environment is ENV."
yuuji@5 1416 (let ((p (point))q)
yuuji@5 1417 (while (and (not q) (search-backward (concat "\\begin{" env "}")nil t))
yuuji@5 1418 ;;(goto-char (match-beginning 0))
yuuji@5 1419 (if (search-backward "%" (point-beginning-of-line) t) nil
yuuji@5 1420 (setq q t)))
yuuji@5 1421 (if q (setq q (not (re-search-forward
yuuji@5 1422 (concat "^[ ]*\\\\end{" env "}") p t))))
yuuji@5 1423 (goto-char p)
yuuji@5 1424 q)
yuuji@5 1425 )
yuuji@5 1426
yuuji@5 1427 (defun YaTeX-remove-trailing-comment ()
yuuji@5 1428 "Remove trailing comment in current line."
yuuji@5 1429 (if (re-search-forward "[^\\\\]\\(%\\)" (point-end-of-line) t)
yuuji@5 1430 (delete-region (match-beginning 1) (point-end-of-line)))
yuuji@5 1431 )
yuuji@5 1432
yuuji@5 1433 (defun YaTeX-fill-item ()
yuuji@5 1434 "Fill item in itemize environment."
yuuji@5 1435 (interactive)
yuuji@5 1436 (save-excursion
yuuji@5 1437 (let* ((p (point))
yuuji@5 1438 (bndry (prog2 (search-backward "\\begin{" nil t) (point)
yuuji@5 1439 (goto-char p)))
yuuji@5 1440 (item-term "\\(^$\\)\\|\\(\\\\item\\)\\|\\(\\\\end\\)")
yuuji@5 1441 fill-prefix start s2 col)
yuuji@5 1442 (end-of-line)
yuuji@5 1443 (if (not (re-search-backward "\\\\item" bndry t))
yuuji@5 1444 (error "\\item not found."))
yuuji@5 1445 (skip-chars-forward "^ " (point-end-of-line))
yuuji@5 1446 (skip-chars-forward " " (point-end-of-line))
yuuji@5 1447 (if (not (eolp)) nil
yuuji@5 1448 (forward-line 1)
yuuji@5 1449 (skip-chars-forward " "))
yuuji@5 1450 (setq start (point-beginning-of-line))
yuuji@5 1451 (setq col (current-column))
yuuji@5 1452 (YaTeX-remove-trailing-comment) ;should restrict to NTT-jTeX?
yuuji@5 1453 (forward-line 1)
yuuji@5 1454 (skip-chars-forward " ")
yuuji@5 1455 (if (looking-at item-term) nil
yuuji@5 1456 (delete-region (point) (point-beginning-of-line))
yuuji@5 1457 (indent-to col)
yuuji@5 1458 (setq s2 (point))
yuuji@5 1459 (setq fill-prefix
yuuji@5 1460 (buffer-substring (point-beginning-of-line)(point)))
yuuji@5 1461 (YaTeX-remove-trailing-comment);should restrict to NTT-jTeX?
yuuji@5 1462 (re-search-forward item-term nil 1)
yuuji@5 1463 (beginning-of-line)
yuuji@5 1464 (push-mark (point) t)
yuuji@5 1465 (while (> (point) s2)
yuuji@5 1466 (forward-line -1)
yuuji@5 1467 (skip-chars-forward " ")
yuuji@5 1468 (delete-region (point) (point-beginning-of-line))
yuuji@5 1469 (YaTeX-remove-trailing-comment))
yuuji@5 1470 (fill-region-as-paragraph start (mark))
yuuji@5 1471 (if NTT-jTeX
yuuji@5 1472 (while (progn(forward-line -1)(end-of-line) (> (point) start))
yuuji@5 1473 (insert ?%)))
yuuji@5 1474 (pop-mark))
yuuji@5 1475 ))
yuuji@5 1476 )
yuuji@5 1477
yuuji@5 1478 (defun YaTeX-fill-* ()
yuuji@5 1479 "Fill paragraph according to its condition."
yuuji@5 1480 (interactive)
yuuji@5 1481 (cond
yuuji@5 1482 ((YaTeX-fill-item))
yuuji@5 1483 )
yuuji@5 1484 )
yuuji@5 1485
yuuji@5 1486 (defun YaTeX-save-buffers ()
yuuji@5 1487 "Save buffers with `.tex' extension."
yuuji@5 1488 (basic-save-buffer)
yuuji@5 1489 (save-excursion
yuuji@5 1490 (mapcar '(lambda (buf)
yuuji@5 1491 (set-buffer buf)
yuuji@5 1492 (if (and (buffer-file-name buf)
yuuji@5 1493 (string-match "\\.tex$" (buffer-file-name buf))
yuuji@5 1494 (buffer-modified-p buf)
yuuji@5 1495 (y-or-n-p (format "Save %s" (buffer-name buf))))
yuuji@5 1496 (save-buffer buf)))
yuuji@5 1497 (buffer-list)))
yuuji@5 1498 )
yuuji@5 1499
yuuji@5 1500 (defun YaTeX-read-accent-char (x)
yuuji@5 1501 "Read char in accent braces."
yuuji@5 1502 (let ((c (read-char)))
yuuji@5 1503 (concat
yuuji@5 1504 (if (and (or (= c ?i) (= c ?j))
yuuji@5 1505 (not (string-match (regexp-quote x) "cdb")))
yuuji@5 1506 "\\" "")
yuuji@5 1507 (char-to-string c)))
yuuji@5 1508 )
yuuji@5 1509
yuuji@5 1510 (defun YaTeX-make-accent ()
yuuji@5 1511 "Make accent usage."
yuuji@5 1512 (interactive)
yuuji@5 1513 (message "1:` 2:' 3:^ 4:\" 5:~ 6:= 7:. u v H t c d b")
yuuji@5 1514 (let ((c (read-char))(case-fold-search nil))
yuuji@5 1515 (setq c (cond ((and (> c ?0) (< c ?8))
yuuji@5 1516 (substring "`'^\"~=." (1- (- c ?0)) (- c ?0)))
yuuji@5 1517 ((= c ?h) "H")
yuuji@5 1518 (t (char-to-string c))))
yuuji@5 1519 (if (not (string-match c "`'^\"~=.uvHtcdb")) nil
yuuji@5 1520 (insert "\\" c "{}")
yuuji@5 1521 (backward-char 1)
yuuji@5 1522 (insert (YaTeX-read-accent-char c))
yuuji@5 1523 (if (string= c "t") (insert (YaTeX-read-accent-char c)))
yuuji@5 1524 (forward-char 1)))
yuuji@5 1525 )
yuuji@5 1526
yuuji@5 1527 (defun YaTeX-replace-format (string format repl)
yuuji@5 1528 "In STRING, replace first appearance of FORMAT to REPL as if
yuuji@5 1529 function `format' does. FORMAT does not contain `%'"
yuuji@5 1530 (let ((beg (or (string-match (concat "^\\(%" format "\\)") string)
yuuji@5 1531 (string-match (concat "[^%]\\(%" format "\\)") string)))
yuuji@5 1532 (len (length format)))
yuuji@5 1533 (if (null beg) string ;no conversion
yuuji@5 1534 (concat
yuuji@5 1535 (substring string 0 (match-beginning 1)) repl
yuuji@5 1536 (substring string (match-end 1)))))
yuuji@5 1537 )
yuuji@5 1538 (defun YaTeX-lpr (arg)
yuuji@5 1539 "Print out. If prefix arg ARG is non nil, call print driver without
yuuji@5 1540 page range description."
yuuji@5 1541 (interactive "P")
yuuji@5 1542 (let*(from to (cmd (or (YaTeX-get-builtin "LPR") dviprint-command-format)))
yuuji@5 1543 (setq
yuuji@5 1544 cmd (YaTeX-replace-format
yuuji@5 1545 cmd
yuuji@5 1546 "f"
yuuji@5 1547 (if arg
yuuji@5 1548 ""
yuuji@5 1549 (YaTeX-replace-format
yuuji@5 1550 dviprint-from-format
yuuji@5 1551 "b"
yuuji@5 1552 (if (string=
yuuji@5 1553 (setq from (read-string "From page(default 1): ")) "")
yuuji@5 1554 "1" from)))))
yuuji@5 1555 (setq
yuuji@5 1556 cmd (YaTeX-replace-format
yuuji@5 1557 cmd
yuuji@5 1558 "t"
yuuji@5 1559 (if (or arg
yuuji@5 1560 (string=
yuuji@5 1561 (setq to (read-string "To page(default none): ")) ""))
yuuji@5 1562 ""
yuuji@5 1563 (YaTeX-replace-format dviprint-to-format "e" to))))
yuuji@5 1564 (setq cmd (read-string "Edit command line: "
yuuji@5 1565 (format cmd (YaTeX-get-preview-file-name))))
yuuji@5 1566 (with-output-to-temp-buffer "*dvi-printing*"
yuuji@5 1567 (if (eq system-type 'ms-dos)
yuuji@5 1568 (call-process shell-file-name "con" "*dvi-printing*" nil
yuuji@5 1569 "/c " cmd)
yuuji@5 1570 (start-process "print" "*dvi-printing*" shell-file-name "-c" cmd)
yuuji@5 1571 (message (concat "Starting " cmd " to printing "
yuuji@5 1572 (YaTeX-get-preview-file-name))))
yuuji@5 1573 ))
yuuji@5 1574 )
yuuji@5 1575
yuuji@0 1576 (defun YaTeX-read-user-completion-table ()
yuuji@0 1577 "Append user completion table of LaTeX word"
yuuji@0 1578 (message "Loading personal completion table")
yuuji@0 1579 (let ((user-table (expand-file-name YaTeX-user-completion-table)))
yuuji@0 1580 (if (file-exists-p user-table)
yuuji@0 1581 (load-file user-table)
yuuji@0 1582 (message "Personal completion table not found."))
yuuji@0 1583 ))
yuuji@0 1584
yuuji@0 1585 (defun YaTeX-save-table ()
yuuji@0 1586 "Save personal completion table as dictionary."
yuuji@0 1587 (interactive)
yuuji@4 1588 (if (not YaTeX-user-table-modified)
yuuji@4 1589 nil
yuuji@4 1590 (message "Saving user table in %s" YaTeX-user-completion-table)
yuuji@4 1591 (find-file (expand-file-name YaTeX-user-completion-table))
yuuji@4 1592 (erase-buffer)
yuuji@4 1593 ;; (prin1-to-string user-section-table)
yuuji@4 1594 (insert "(setq user-section-table '(\n")
yuuji@4 1595 (mapcar '(lambda (s)
yuuji@4 1596 (insert (prin1-to-string s))
yuuji@4 1597 (insert "\n"))
yuuji@4 1598 user-section-table)
yuuji@4 1599 (insert "))\n\n")
yuuji@4 1600
yuuji@4 1601 (insert "(setq user-article-table '(\n")
yuuji@4 1602 (mapcar '(lambda (s)
yuuji@4 1603 (insert (prin1-to-string s))
yuuji@4 1604 (insert "\n"))
yuuji@4 1605 user-article-table)
yuuji@4 1606 (insert "))\n\n")
yuuji@4 1607
yuuji@4 1608 (insert "(setq user-env-table '(\n")
yuuji@4 1609 (mapcar '(lambda (s)
yuuji@4 1610 (insert (prin1-to-string s))
yuuji@4 1611 (insert "\n"))
yuuji@4 1612 user-env-table)
yuuji@4 1613 (insert "))\n\n")
yuuji@4 1614
yuuji@4 1615 (insert "(setq user-fontsize-table '(\n")
yuuji@4 1616 (mapcar '(lambda (s)
yuuji@4 1617 (insert (prin1-to-string s))
yuuji@4 1618 (insert "\n"))
yuuji@4 1619 user-fontsize-table)
yuuji@4 1620 (insert "))\n\n")
yuuji@4 1621
yuuji@4 1622 (insert "(setq user-singlecmd-table '(\n")
yuuji@4 1623 (mapcar '(lambda (s)
yuuji@4 1624 (insert (prin1-to-string s))
yuuji@4 1625 (insert "\n"))
yuuji@4 1626 user-singlecmd-table)
yuuji@4 1627 (insert "))\n")
yuuji@4 1628
yuuji@4 1629 (basic-save-buffer)
yuuji@4 1630 (kill-buffer (current-buffer))
yuuji@4 1631 (message "")
yuuji@4 1632 (setq YaTeX-user-table-modified nil))
yuuji@0 1633 )
yuuji@0 1634
yuuji@3 1635 ;; --------------- General sub functions ---------------
yuuji@3 1636
yuuji@3 1637 ;(defun index (string char)
yuuji@3 1638 ; (let ((pos 0)(len (1- (length string)))(index -1))
yuuji@3 1639 ; (while (<= pos len)
yuuji@3 1640 ; (cond
yuuji@3 1641 ; ((= (aref string pos) char)
yuuji@3 1642 ; (setq index pos) (setq pos len))
yuuji@3 1643 ; (t (setq pos (1+ pos))))
yuuji@3 1644 ; )
yuuji@3 1645 ; index)
yuuji@3 1646 ;)
yuuji@3 1647
yuuji@3 1648 (defun rindex (string char)
yuuji@3 1649 (let ((pos (1- (length string)))(index -1))
yuuji@3 1650 (while (>= pos 0)
yuuji@3 1651 (cond
yuuji@3 1652 ((= (aref string pos) char)
yuuji@3 1653 (setq index pos) (setq pos -1))
yuuji@3 1654 (t (setq pos (1- pos))))
yuuji@3 1655 )
yuuji@3 1656 index)
yuuji@3 1657 )
yuuji@3 1658
yuuji@0 1659 (defun append-to-hook (hook hook-list)
yuuji@0 1660 "Add hook-list to certain emacs's hook correctly.
yuuji@0 1661 Argument hook-list is the list of function int the form to be called
yuuji@0 1662 Call this function with argument as next example,
yuuji@0 1663 (append-to-hook '((ding))) ;If one function to add.
yuuji@0 1664 (append-to-hook '((func1)(func2 arg)))."
yuuji@5 1665 (if (null (symbol-value hook)) ;Not defined
yuuji@0 1666 (set hook
yuuji@0 1667 (append '(lambda ()) hook-list))
yuuji@5 1668 (if (listp (symbol-value hook))
yuuji@5 1669 (if (eq (car (symbol-value hook)) 'lambda) ;'(lambda () ....)
yuuji@0 1670 (set hook
yuuji@5 1671 (append (symbol-value hook) hook-list))
yuuji@0 1672 (if (eq hook 'kill-emacs-hook) ;'(hook1 hook2 ...)
yuuji@0 1673 (progn ; this format is not
yuuji@0 1674 (ding) ; for kill-emacs-hook
yuuji@0 1675 (message
yuuji@0 1676 "Caution!! you have wrong format of kill-emacs-hook"))
yuuji@0 1677 (while (not (null hook-list))
yuuji@0 1678 (set hook
yuuji@5 1679 (append (symbol-value hook) (car hook-list)))
yuuji@0 1680 (setq hook-list (cdr hook-list))))
yuuji@0 1681 )
yuuji@0 1682 (set hook ;'hook
yuuji@0 1683 (append '(lambda ())
yuuji@5 1684 (cons (list (symbol-value hook)) hook-list)))))
yuuji@0 1685 )
yuuji@0 1686 (append-to-hook 'kill-emacs-hook '((YaTeX-save-table)))
yuuji@0 1687
yuuji@0 1688 ;--------------------------------- History ---------------------------------
yuuji@0 1689 ; Rev. | Date | Contents
yuuji@0 1690 ;------+----------+---------------------------------------------------------
yuuji@0 1691 ; 1.00 | 91/ 6/13 | Initial version.
yuuji@0 1692 ; | | Auto compilation & preview.
yuuji@0 1693 ; | | \section{}-type and \begin{}\end{}-type completion.
yuuji@0 1694 ; 1.01 | 91/ 6/14 | Add {\large ..} type completion (prefix+l).
yuuji@0 1695 ; 1.10 | 6/21 | Add learning feature of completion.
yuuji@0 1696 ; 1.11 | 6/27 | Simplify function begin-document etc. using lambda.
yuuji@0 1697 ; 1.12 | 7/ 6 | Modify YaTeX-make-section, show section-name.
yuuji@0 1698 ; 1.13 | 12/ 4 | Delete blank lines in make begin/end environment.
yuuji@0 1699 ; 1.20 | 12/ 5 | Saving learned completion into user file.
yuuji@0 1700 ; 1.21 | 12/ 6 | Add \maketitle type completion (prefix+m).
yuuji@0 1701 ; 1.22 | 12/30 | Port yatex.el to DOS(Demacs).
yuuji@0 1702 ; 1.23 | 92/ 1/ 8 | Enable latex and preview command on DOS.
yuuji@0 1703 ; 1.24 | 1/ 9 | Add YaTeX-save-table to kill-emacs-hook automatically.
yuuji@0 1704 ; 1.25 | 1/16 | YaTeX-do-completion (prefix+SPC) and argument
yuuji@5 1705 ; | | acceptable YaTeX-make-section work. Put region into
yuuji@0 1706 ; | | \begin...\end by calling YaTeX-make-begin-end with ARG.
yuuji@0 1707 ; | | append-kill-emacs-hook was revised to append-to-hook.
yuuji@0 1708 ; 1.26 | 1/18 | Region mode is added to {\large }. Default fontsize.
yuuji@3 1709 ; 1.27 | 1/21 | Default name on completing-read.
yuuji@1 1710 ; 1.28 | 7/ 2 | Add \nonstopmode{} automatically on DOS.
yuuji@1 1711 ; | 7/20 | %#! usage to specify latex command and its arguments.
yuuji@3 1712 ; | | Change default fill-prefix from TAB to null string.
yuuji@3 1713 ; 1.29 | 7/21 | Add YaTeX-end-environment.
yuuji@3 1714 ; 1.30 | 9/26 | Support project 30 lines(other than 25 lines).
yuuji@3 1715 ; 1.31 | 10/28 | Variable argument for previewer from %#! usage.
yuuji@4 1716 ; 1.32 | 11/16 | YaTeX-goto-corresponding-environment.
yuuji@4 1717 ; | | Comment out region/paragraph added.
yuuji@4 1718 ; 1.33 | 11/29 | Variable default value, on DOS and other OS.
yuuji@5 1719 ; | | Make dvi2-command buffer local. Change the behavior of
yuuji@4 1720 ; | | comment out region/paragraph on the \begin{} or \end{}
yuuji@5 1721 ; | | line. Make YaTeX-end-environment faster. Add YaTeX-
yuuji@4 1722 ; | | define-key, YaTeX-define-begend-(region-)key.
yuuji@5 1723 ; 1.34 | 12/26 | YaTeX-goto-corresponding-* automatically choose its move.
yuuji@5 1724 ; | | YaTeX-prev-error supports separate typesetting.
yuuji@5 1725 ; 1.35 | 93/ 1/25 | YaTeX-kill-environment erases pair of begin/end.
yuuji@5 1726 ; | | YaTeX-change-environment change the environment name.
yuuji@5 1727 ; | | Auto indent at YaTeX-make-begin-end.
yuuji@5 1728 ; 1.36 | 1/27 | YaTeX-typeset-region typesets the region from %#BEGIN to
yuuji@5 1729 ; | | %#END, or simple region between point and mark.
yuuji@5 1730 ; 1.37 | 2/12 | YaTeX-kill-environment turns YaTeX-kill-some-pairs and
yuuji@5 1731 ; | | now it can kill %#BEGIN and %#END pairs.
yuuji@5 1732 ; | | Now YaTeX-goto-corresponding-environment detects nested
yuuji@5 1733 ; | | environment. Put " by " in verbatim. Auto save buffers
yuuji@5 1734 ; | | with quiery. Add current file to includeonly list
yuuji@5 1735 ; | | automatically. Support YaTeX-fill-item, YaTeX-make-
yuuji@5 1736 ; | | accent, YaTeX-visit-main-other-window.
yuuji@5 1737 ; | | [prefix] tl for lpr. Revise YaTeX-view-error.
yuuji@0 1738 ;------+----------+---------------------------------------------------------
yuuji@0 1739 ;
yuuji@0 1740 ;----------------------------- End of yatex.el -----------------------------