home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-18.59-src.tgz / emacs-18.59-src.tar / fsf / emacs18 / lisp / tex-mode.elc < prev    next >
Text File  |  1996-09-28  |  12KB  |  211 lines

  1.  
  2. (provide (quote tex-mode))
  3.  
  4. (defvar TeX-directory "/tmp/" "\
  5. *Directory in which to run TeX subjob.  Temporary files are
  6. created in this directory.")
  7.  
  8. (defvar TeX-dvi-print-command "lpr -d" "\
  9. *Command string used by \\[TeX-print] to print a .dvi file.")
  10.  
  11. (defvar TeX-show-queue-command "lpq" "\
  12. *Command string used by \\[TeX-show-print-queue] to show the print queue
  13. that \\[TeX-print] put your job on.")
  14.  
  15. (defvar TeX-default-mode (quote plain-TeX-mode) "\
  16. *Mode to enter for a new file when it can't be determined whether
  17. the file is plain TeX or LaTeX or what.")
  18.  
  19. (defvar TeX-command nil "\
  20. The command to run TeX on a file.  The name of the file will be appended
  21. to this string, separated by a space.")
  22.  
  23. (defvar TeX-trailer nil "\
  24. String appended after the end of a region sent to TeX by \\[TeX-region].")
  25.  
  26. (defvar TeX-start-of-header nil "\
  27. String used by \\[TeX-region] to delimit the start of the file's header.")
  28.  
  29. (defvar TeX-end-of-header nil "\
  30. String used by \\[TeX-region] to delimit the end of the file's header.")
  31.  
  32. (defvar TeX-shell-cd-command "cd" "\
  33. Command to give to shell running TeX to change directory.  The value of
  34. TeX-directory will be appended to this, separated by a space.")
  35.  
  36. (defvar TeX-zap-file nil "\
  37. Temporary file name used for text being sent as input to TeX.
  38. Should be a simple file name with no extension or directory specification.")
  39.  
  40. (defvar TeX-mode-syntax-table nil "\
  41. Syntax table used while in TeX mode.")
  42.  
  43. (defun TeX-define-common-keys (keymap) "\
  44. Define the keys that we want defined both in TeX-mode
  45. and in the TeX-shell." (byte-code "ÁÂÃ#ˆÁÄÅ#ˆÁÆÇ#ˆÁÈÉ#‡" [keymap define-key " " TeX-kill-job " " TeX-recenter-output-buffer "" TeX-show-print-queue "" TeX-print] 7))
  46.  
  47. (defvar TeX-mode-map nil "\
  48. Keymap for TeX mode")
  49.  
  50. (if TeX-mode-map nil (setq TeX-mode-map (make-sparse-keymap)) (TeX-define-common-keys TeX-mode-map) (define-key TeX-mode-map "\"" (quote TeX-insert-quote)) (define-key TeX-mode-map "
  51. " (quote TeX-terminate-paragraph)) (define-key TeX-mode-map "}" (quote up-list)) (define-key TeX-mode-map "{" (quote TeX-insert-braces)) (define-key TeX-mode-map "" (quote TeX-region)) (define-key TeX-mode-map "" (quote TeX-buffer)) (define-key TeX-mode-map "" (quote TeX-close-LaTeX-block)))
  52.  
  53. (defvar TeX-shell-map nil "\
  54. Keymap for the TeX shell.  A shell-mode-map with a few additions")
  55.  
  56. (defun tex-mode nil "\
  57. Major mode for editing files of input for TeX or LaTeX.
  58. Trys to intuit whether this file is for plain TeX or LaTeX and
  59. calls plain-tex-mode or latex-mode.  If it cannot be determined
  60. (e.g., there are no commands in the file), the value of
  61. TeX-default-mode is used." (interactive) (byte-code "ÈÃÃÊebˆÇÈÃÄ#‰…%`ŠÉ ˆÇÊÄ#))‰…-Ȃ ˆ    …4
  62. ?…DËÌ!ƒA͂BΉ)ˆƒPÏ!‚TÏ!+‡" [mode slash comment nil t search-end TeX-default-mode search-forward "\\" beginning-of-line "%" looking-at "documentstyle" latex-mode plain-tex-mode funcall] 7))
  63.  
  64. (fset (quote plain-TeX-mode) (quote plain-tex-mode))
  65.  
  66. (fset (quote LaTeX-mode) (quote latex-mode))
  67.  
  68. (defun plain-tex-mode nil "\
  69. Major mode for editing files of input for plain TeX.
  70. Makes $ and } display the characters they match.
  71. Makes \" insert `` when it seems to be the beginning of a quotation,
  72. and '' when it appears to be the end; it inserts \" only after a \\.
  73.  
  74. Use \\[TeX-region] to run TeX on the current region, plus a \"header\"
  75. copied from the top of the file (containing macro definitions, etc.),
  76. running TeX under a special subshell.  \\[TeX-buffer] does the whole buffer.
  77. \\[TeX-print] prints the .dvi file made by either of these.
  78.  
  79. Use \\[validate-TeX-buffer] to check buffer for paragraphs containing
  80. mismatched $'s or braces.
  81.  
  82. Special commands:
  83. \\{TeX-mode-map}
  84.  
  85. Mode variables:
  86. TeX-directory
  87.     Directory in which to create temporary files for TeX jobs
  88.     run by \\[TeX-region] or \\[TeX-buffer].
  89. TeX-dvi-print-command
  90.     Command string used by \\[TeX-print] to print a .dvi file.
  91. TeX-show-queue-command
  92.     Command string used by \\[TeX-show-print-queue] to show the print
  93.     queue that \\[TeX-print] put your job on.
  94.  
  95. Entering plain-TeX mode calls the value of text-mode-hook,
  96. then the value of TeX-mode-hook, and then the value
  97. of plain-TeX-mode-hook." (interactive) (byte-code "ƈǠˆÈ‰ˆÉ‰ˆÊ‰ˆË‰ˆÌ‰ˆÍ‰ˆÎÏÐÑ#‡" [mode-name major-mode TeX-command TeX-start-of-header TeX-end-of-header TeX-trailer nil TeX-common-initialization "TeX" plain-TeX-mode "tex" "%**start of header" "%**end of header" "\\bye
  98. " run-hooks text-mode-hook TeX-mode-hook plain-TeX-mode-hook] 5))
  99.  
  100. (defun latex-mode nil "\
  101. Major mode for editing files of input for LaTeX.
  102. Makes $ and } display the characters they match.
  103. Makes \" insert `` when it seems to be the beginning of a quotation,
  104. and '' when it appears to be the end; it inserts \" only after a \\.
  105.  
  106. Use \\[TeX-region] to run LaTeX on the current region, plus the preamble
  107. copied from the top of the file (containing \\documentstyle, etc.),
  108. running LaTeX under a special subshell.  \\[TeX-buffer] does the whole buffer.
  109. \\[TeX-print] prints the .dvi file made by either of these.
  110.  
  111. Use \\[validate-TeX-buffer] to check buffer for paragraphs containing
  112. mismatched $'s or braces.
  113.  
  114. Special commands:
  115. \\{TeX-mode-map}
  116.  
  117. Mode variables:
  118. TeX-directory
  119.     Directory in which to create temporary files for TeX jobs
  120.     run by \\[TeX-region] or \\[TeX-buffer].
  121. TeX-dvi-print-command
  122.     Command string used by \\[TeX-print] to print a .dvi file.
  123. TeX-show-queue-command
  124.     Command string used by \\[TeX-show-print-queue] to show the print
  125.     queue that \\[TeX-print] put your job on.
  126.  
  127. Entering LaTeX mode calls the value of text-mode-hook,
  128. then the value of TeX-mode-hook, and then the value
  129. of LaTeX-mode-hook." (interactive) (byte-code "ƈǠˆÈ‰ˆÉ‰ˆÊ‰ˆË‰ˆÌ‰ˆÍ‰ˆÎÏÐÑ#‡" [mode-name major-mode TeX-command TeX-start-of-header TeX-end-of-header TeX-trailer nil TeX-common-initialization "LaTeX" LaTeX-mode "latex" "\\documentstyle" "\\begin{document}" "\\end{document}
  130. " run-hooks text-mode-hook TeX-mode-hook LaTeX-mode-hook] 5))
  131.  
  132. (defun TeX-common-initialization nil (byte-code "É ˆÊ!ˆ
  133. ‰ˆ ?ƒRË ‰ˆÌ !ˆÍÎÏ\"ˆÍÐÑ\"ˆÍÒÑ\"ˆÍÓÔ\"ˆÍÕÖ\"ˆÍ×Ï\"ˆÍØÏ\"ˆÍÙÏ\"ˆÍÚÛ\"ˆÍÜÝ\"ˆÍÞß\"‚UÌ !ˆàÄ!ˆá‰ˆàÅ!ˆ ‰ˆàÆ!ˆâ‰ˆàÇ!ˆã‰ˆàÈ!ˆä‰ˆàå!ˆàæ!ˆàç!ˆàè!‡" [TeX-mode-map local-abbrev-table text-mode-abbrev-table TeX-mode-syntax-table paragraph-start paragraph-separate comment-start comment-start-skip comment-indent-hook kill-all-local-variables use-local-map make-syntax-table set-syntax-table modify-syntax-entry 92 "." 12 ">" 10 36 "$$" 37 "<" 34 38 95 64 "_" 126 " " 39 "w" make-local-variable "^[     ]*$\\|^[ \\\\%]" "%" "\\(\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)" TeX-comment-indent TeX-command TeX-start-of-header TeX-end-of-header TeX-trailer] 26))
  134.  
  135. (defun TeX-comment-indent nil (byte-code "ÁÂ!ƒ
  136. i‚ÃÄ!ˆnƒłiT]‡" [comment-column looking-at "%%%" skip-chars-backward "     " 0] 4))
  137.  
  138. (defun TeX-insert-quote (arg) "\
  139. Insert ``, '' or \" according to preceding character.
  140. With prefix argument, always insert \" characters." (interactive "P") (byte-code "ȃÄ!<ƒÅÆ!‚Å    !)‚<o†)ŠÇÈ!ˆÉÊ!)ƒ0˂;hÌUƒ:͂;Îc‡" [arg count t nil prefix-numeric-value self-insert-command 1 forward-char -1 looking-at "[     
  141. ]\\|\\s(" "``" 92 34 "''"] 7))
  142.  
  143. (defun validate-TeX-buffer nil "\
  144. Check current buffer for paragraphs containing mismatched $'s.
  145. As each such paragraph is found, a mark is pushed at its beginning,
  146. and the location is displayed for a few seconds." (interactive) (byte-code "ˆ`dbˆÃŽÄ ?…o?…3`ÅÆÂÇ#ˆÈ`    \"†.É`!ˆÊË!ˆÌÍ!)ˆ‚    ))‡" [opoint end nil ((byte-code "b‡" [opoint] 1)) input-pending-p search-backward "
  147.  
  148. " move TeX-validate-paragraph push-mark message "Mismatch found in pararaph starting here" sit-for 4] 8))
  149.  
  150. (defun TeX-validate-paragraph (start end) (byte-code "ÀÁ‡" [nil (byte-code "ŠŒÃ    \"ˆbˆÄ    Z!ˆÂ))‡" [start end t narrow-to-region forward-sexp] 4) ((error (byte-code "À‡" [nil] 1)))] 3))
  151.  
  152. (defun TeX-terminate-paragraph (inhibit-validation) "\
  153. Insert two newlines, breaking a paragraph for TeX.
  154. Check for mismatched braces/$'s in paragraph being terminated.
  155. A prefix arg inhibits the checking." (interactive "P") (byte-code "Áˆ†ŠÃÄÁÅ#ˆ`)`\"†ÆÇ!ˆÄc‡" [inhibit-validation nil TeX-validate-paragraph search-backward "
  156.  
  157. " move message "Paragraph being closed appears to contain a mismatch"] 5))
  158.  
  159. (defun TeX-insert-braces nil "\
  160. Make a pair of braces and be poised to type inside of them." (interactive) (byte-code "ÀˆÁcˆŠÂc)‡" [nil 123 125] 1))
  161.  
  162. (defun TeX-close-LaTeX-block nil "\
  163. Creates an \\end{...} to match \\begin{...} on the current line and
  164. puts point on the blank line between them." (interactive "*") (byte-code "Ĉ`Å ˆÆNJȠˆ`)Á#ƒ8ÉÊË!ÌË!\"iÅ ˆÍ ˆÎcˆ jˆÏÐ
  165. Ñ#ˆÒÓ!*‚=bˆÔ )‡" [fail-point t text indentation nil end-of-line re-search-backward "\\\\begin{\\([^}
  166. ]*\\)}" beginning-of-line buffer-substring match-beginning 1 match-end delete-horizontal-space "
  167.  
  168. " insert "\\end{" "}" forward-line -1 ding] 12))
  169.  
  170. (defun TeX-start-shell nil (byte-code "ÃÄ!ˆŠÅÆÀÀÇ$qˆÈ
  171. !‰ˆÉ    !ˆÊ    !ˆËÌ !…%ÍÎ!)‡" [nil TeX-shell-map shell-mode-map require shell make-shell "TeX-shell" "-v" copy-keymap TeX-define-common-keys use-local-map zerop buffer-size sleep-for 1] 9))
  172.  
  173. (defun set-buffer-directory (buffer directory) "\
  174. Set BUFFER's default directory to be DIRECTORY." (byte-code "ÃÄ!!‰ˆÅ!?ƒÆÇ\"‚Š    qˆ‰)‡" [directory buffer default-directory file-name-as-directory expand-file-name file-directory-p error "%s is not a directory"] 6))
  175.  
  176. (defun TeX-region (beg end) "\
  177. Run TeX on the current region.  A temporary file (TeX-zap-file) is
  178. written in directory TeX-directory, and TeX is run in that directory.
  179. If the buffer has a header, it is written to the temporary file before
  180. the region itself.  The buffer's header is all lines between the
  181. strings defined by TeX-start-of-header and TeX-end-of-header
  182. inclusive.  The header must start in the first 100 lines.  The value
  183. of TeX-trailer is appended to the temporary file after the region." (interactive "r") (byte-code "̈ÓÔ!ƒÕ ‚Ö ˆ†×Ø!‰ˆÙPÚÛ!ÜÝ !!ŠŒÞ ˆebˆßà!ˆ`ee ebˆá    Ê#…k⠈`‰ˆá ÌÊ#ƒgßã!ˆ`‰‚ke‰ˆä^    ÌÌ%ˆä]    ÊÌ%,ˆ
  184. qˆå ˆæç!ˆ…žæ!ˆè
  185. \"ˆäed    ÊÌ%)))ˆèÔ \"ˆéêë çR\"ˆéêì    íR\"+ˆîï!‡" [TeX-zap-file tex-out-file temp-buffer zap-directory TeX-directory search-end hbeg hend default-directory TeX-start-of-header t TeX-end-of-header nil beg end local-tex-trailer TeX-trailer TeX-shell-cd-command TeX-command get-buffer "*TeX-shell*" TeX-kill-job TeX-start-shell make-temp-name "#tz" ".tex" get-buffer-create " TeX-Output-Buffer" file-name-as-directory expand-file-name widen forward-line 100 search-forward beginning-of-line 1 write-region erase-buffer insert-string "
  186. " set-buffer-directory send-string "TeX-shell" " " " \"" "\"
  187. " TeX-recenter-output-buffer 0] 28))
  188.  
  189. (defun TeX-buffer nil "\
  190. Run TeX on current buffer.  See \\[TeX-region] for more information." (interactive) (byte-code "ÀˆÁed\"‡" [nil TeX-region] 3))
  191.  
  192. (defun TeX-kill-job nil "\
  193. Kill the currently running TeX job." (interactive) (byte-code "ÁˆÂÃÀ\"‡" [t nil quit-process "TeX-shell"] 3))
  194.  
  195. (defun TeX-recenter-output-buffer (linenum) "\
  196. Redisplay buffer of TeX job output so that most recent output can be seen.
  197. The last line of the buffer is displayed on
  198. line LINE of the window, or centered if LINE is nil." (interactive "P") (byte-code "ÈÄÅ!p?ƒÆÇ!‚3È!ˆÉ!ˆdbˆÊ
  199. ƒ)Ë
  200. !‚.ÌÍ Î\"!ˆÈ    !*‡" [tex-shell old-buffer linenum nil get-buffer "*TeX-shell*" message "No TeX output buffer" pop-to-buffer bury-buffer recenter prefix-numeric-value / window-height 2] 10))
  201.  
  202. (defun TeX-print nil "\
  203. Print the .dvi file made by \\[TeX-region] or \\[TeX-buffer].
  204. Runs the shell command defined by TeX-dvi-print-command." (interactive) (byte-code "ˆÃÄÅ    ÆR\"ˆÇÂ!‡" [TeX-dvi-print-command TeX-zap-file nil send-string "TeX-shell" " \"" ".dvi\"
  205. " TeX-recenter-output-buffer] 6))
  206.  
  207. (defun TeX-show-print-queue nil "\
  208. Show the print queue that \\[TeX-print] put your job on.
  209. Runs the shell command defined by TeX-show-queue-command." (interactive) (byte-code "ÁˆÂÃ!?… Ä ˆÅÆÇP\"ˆÈÁ!‡" [TeX-show-queue-command nil get-buffer "*TeX-shell*" TeX-start-shell send-string "TeX-shell" "
  210. " TeX-recenter-output-buffer] 6))
  211.