home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / texpp.zoo / texpp.1 next >
Encoding:
Text File  |  1990-04-04  |  41.4 KB  |  1,092 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive.  Remove anything before this line, then unpack
  4. # it by saving it into a file and typing "sh file".  To overwrite existing
  5. # files, type "sh file -c".  You can also feed this as standard input via
  6. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  7. # will see the following message at the end:
  8. #        "End of archive 1 (of 2)."
  9. # Contents:  MANIFEST README macro.pp tex-mode.el
  10. # Wrapped by allbery@uunet on Sun Mar 25 19:31:13 1990
  11. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  12. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  13.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  14. else
  15. echo shar: Extracting \"'MANIFEST'\" \(269 characters\)
  16. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  17. X   File Name        Archive #    Description
  18. X-----------------------------------------------------------
  19. X MANIFEST                   1    This shipping list
  20. X README                     1    
  21. X macro.pp                   1    
  22. X tex-mode.el                1    
  23. X texpp.c                    2    
  24. END_OF_FILE
  25. if test 269 -ne `wc -c <'MANIFEST'`; then
  26.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  27. fi
  28. # end of 'MANIFEST'
  29. fi
  30. if test -f 'README' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'README'\"
  32. else
  33. echo shar: Extracting \"'README'\" \(14110 characters\)
  34. sed "s/^X//" >'README' <<'END_OF_FILE'
  35. X ***************************************************************************
  36. X *                                       *
  37. X *           texpp TeX preprocessor, Version 1.2.               *
  38. X *              Laci Csirmaz, DIMACS - Rutgers               *
  39. X *                   Feb. 25, 1990                   *
  40. X *                                       *
  41. X ***************************************************************************
  42. X *    You are granted to use, modify, copy, redistribute this program any  *
  43. X * way you want. However no warranties are made for this program or the    *
  44. X * accopanying documentation.                           *
  45. X *                                       *
  46. X *    Please send your comments, suggestions, etc. to:               *
  47. X *        csirmaz@cs.rutgers.edu                       *
  48. X *                                       *
  49. X ***************************************************************************
  50. X
  51. X
  52. X                       Tex Preprocessor  M A N U A L
  53. X
  54. X    0. Introduction
  55. X
  56. X    TeX, undoubtedly a very LOGICAL language, does not follow closely enough
  57. Xthe illogical nature of human beings. Using backslashes everywhere to signify
  58. Xa special treatment of a word is logical, but, of course, tedious and a bit
  59. Xboring. Whenever the word "alpha" appears in a text, with higher probability
  60. Xthan 0.9999 the author wishes the corresponding greek letter to appear, and
  61. Xnot this word. In the latter unlikely case, s/he is more willing to do some
  62. Xextra word to make the (now) exception the rule, and save a lot of work.
  63. X    Another drawback is the (also very logical, but unnatural) handling of
  64. Xmacros. If an operator is applied to a word (or a single letter), TeX
  65. Xrequires the operator to precede its argument. While in some cases this
  66. Xis the natural approach, in some cases it is not. As in using a dot, tilde, 
  67. Xor hat on a letter, the natural form is "x tilde", and not what is the
  68. Xobligatory form, "\tilde x".
  69. X    TeX forbids almost all key combinations to use as macro names, only
  70. Xsequences of letters are allowed. Why cannot I write "|==" instead of
  71. X"\model", "/0" for "\empty", or, horribile dictu, "/\" instead of "\wedge"?
  72. XFormulas written in this way are more readable, and easier to type.
  73. X    Finally, while TeX (and LaTeX) allows to redefine its macros, the user
  74. Xis usually not aware of its danger. Both plain TeX and LaTeX have a lot of
  75. Xbuilt-in macros which are absolutely necessary to run them. Redefining any
  76. Xof them the program simply goes crazy. And, in most of the cases, the user
  77. Xdoes not even know why the construct is wrong. What happens, for example, 
  78. Xif "\and" is redefined in LaTeX so that it would produce the sign /\ -- a 
  79. Xquite reasonable assumption. To avoid all the problems arising this way, TeX 
  80. Xshould do these definitions locally, which it doesn't.
  81. X
  82. X    All of the above problems lead to the development of the "texpp" TeX
  83. Xpreprocessor. Since TeX is quite ambivalent about handling the input layout
  84. X(often it says to be independent of whitespaces, but two consecutive newlines
  85. Xsignify a new paragraph, and comments are closed by newlines), I decided to
  86. Xuse layout a bit more significantly than TeX does. All macro definitions
  87. Xshould start at the first column. The preprocessor is not intended to be as
  88. Xgeneral as possible. It has a lot of wired in features (for example, the $ 
  89. Xand $$ to start and end math mode), but the C code is available, and (at 
  90. Xleast I hope) can be modified easily. Also, the preprocessor is absolutely 
  91. XNOT for TeX wizards. It can be fooled quite easily e.g. by redefining the
  92. Xescape character, but as far as it is used as a simple tool it works fine.
  93. X
  94. X
  95. X    1. Shipped files
  96. X
  97. X    Besides the C source code of the program and this manual, you can find
  98. Xa sample macro file which show some extra features of texpp. Also I wrote
  99. Xa tex-mode.el (gnu)emacs template which embeds the 'texpp' preprocessor, and
  100. Xa dvi viewer.
  101. X    The program was written for UNIX(TM) machines, but the code is highly
  102. Xportable (at least I hope so). Therefore it should be easy yo transport to
  103. Xother machines.
  104. X              
  105. X
  106. X    2. Macro names
  107. X
  108. X    Macro name can be any sequence of characters which does not contain
  109. Xbraces `{' and `}', dollar sign `$', percentage sign `%', and embedded
  110. Xwhitespaces. `Character' here means a character with ASCII code >=32 and
  111. X<= 126. Each line of the text is cut at braces and whitespaces, and what
  112. Xis left is compared against the list of macro names. If there is a hit, then
  113. Xthe closing braces or white spaces are erased, and the macro text is replaced.
  114. X
  115. X    3. Parameters
  116. X
  117. X    A macro may have up to nine parameters, which can be either before or
  118. Xafter the macro name. Parameters are parsed starting from the macro name:
  119. Xeach parameter is either enclosed into braces, or contains no braces and is
  120. Xenclosed by whitespaces. A parameter must have balanced braces, if any.
  121. XIn braces, it may have embedded white spaces. Parameters may contain further
  122. Xmacro names, too, but parameter parsing is done BEFORE macro substitution.
  123. XTwo macros cannot share parameters. A parameter is always stripped off its
  124. Xenclosing characters, and then a macro substitution is executed on it. A
  125. Xparameter can be a macro name with further parameters (see the examples).
  126. XIf the macro name is enclosed into braces, all its parameters must also be
  127. Xinside.
  128. X
  129. X
  130. X    4. Macro definition
  131. X
  132. X    Macros can be defined anywhere. A definition always starts at the first 
  133. Xcharacter of the line, and signified by the key words `%define' or `%mdefine'. 
  134. X(Starting with percentage sign, but NO BACKSLASH is here). The form of a
  135. Xdefinition is the following:
  136. X
  137. X    %define <preceeding pars> name <follow up pars>  %text% <any comment>
  138. X
  139. XLocal parameters are of the form #1, #2, ..., #9. No parameters are required,
  140. Xthey can appear in any order and in any place. The REPLACEMENT text is enclosed
  141. Xby `%' characters (thus it cannot contain `%', but of course it may contain
  142. Xthe `\%' pair!), and is used as it is, with the following exeptions:
  143. X
  144. X    a) local parameters #1, ... #9 are replaced by the stripped and 
  145. X       expanded parameters of the invocation;
  146. X    b) the pair ## is replaced by a single # mark.
  147. X    c) macro calls are expanded.
  148. X
  149. XRule b) also applies to the macro name. Thus `#' can also appear in a macro
  150. Xname, but should be written as `##'. (Of course, when looking for a macro name
  151. Xin the text, this corresponds to the single character!)
  152. X    Macro definitions starting by `%mdefine' are applied only when in math
  153. Xor displayed math mode; other definitions are always applicable. The program
  154. Xassumes that the macro body does not switch these modes.
  155. X    Besides defining macros, you can "undefine" them, too. This comes handy
  156. Xwhen a macro is used only as an auxiliary in a more complicated definition, 
  157. Xbut not needed later. A new definition "hides" the old one, undefining
  158. Xrestores the old meaning. This can be done by
  159. X
  160. X    %undefine name
  161. Xor
  162. X    %undefine name % <your comment here>
  163. X
  164. XIt is an error to undefine a macro which was not defined (or mdefined)
  165. Xbefore.
  166. X
  167. X    5. Auxiliary tools
  168. X
  169. X    In certain cases it is essential to suppress macro substitution. This
  170. Xcan be done by applying the `\preserve' keyword to its single parameter:
  171. X
  172. X    \preserve <anything_which_does_not_contain_whitespace_or_brace>
  173. Xor
  174. X    \preserve {<any text with balanced braces>}
  175. X
  176. XIn the parameter to `\preserve' no macro substitution is made. However, 
  177. X`\preserve' cannot be applied to macro parameters in macro definitions, 
  178. Xsince parameter expansion is done BEFORE substitution.
  179. X
  180. X    Different extensions of TeX use different macros to switch to and from 
  181. Xmath mode. To comply with them, the following definitions are recognized:
  182. X
  183. X    %mathmode <string_to_enter_math_mode>  <string_leave_math_mode>
  184. Xand
  185. X    %dispmode <string_to_enter_displayed_math>  <string_leaving>
  186. X
  187. XThe strings cannot contain white spaces, and if only one string is given in
  188. Xa definition, then that is used for both entering and leaving math mode. 
  189. XIn LaTeX the following definitions may come handy:
  190. X
  191. X    %mathmode \( \)            %simple math mode
  192. X    %mathmode \math \endmath
  193. X    %dispmode \[ \]            %displayed formulas
  194. X    %dispmode \equation \endequation    %for numbered formulas
  195. X
  196. X
  197. X    6. Examples
  198. X
  199. Xo 6.1. The first example defines the `*16' macro, which repeats its argument
  200. X sixteen times:
  201. X
  202. X %define #1 *2 %#1#1%        %define `*2' as an auxiliary macro
  203. X %define #1 *16 %#1 *2 *2 *2 *2%
  204. X %undefine *2            %undefine `*2', no more needed
  205. X
  206. X Texts `x 1 *16 y' and `x{1}*16 y' expand to `x1111111111111111y'. (Observe
  207. X that the trailing space after `*16' vanished). At the same time `x 1*16 y'
  208. X and `x 1 *16y' remain unchanged since the macro name `*16' cannot be
  209. X extracted.  As another example, `x {a b} *16 y' saves the space between `a'
  210. X and `b', and before the open brace but not after the macro name. So the
  211. X result is
  212. X
  213. X    `x a ba ba ba ba ba ba ba ba ba ba ba ba ba ba ba by'
  214. X
  215. X
  216. Xo 6.2. The next example also shows that macro definitions are expanded when
  217. X defined, and not when invoked. This means, for example, that subsequent
  218. X macro definitions have no influence on an existing macro definition. This
  219. X fact is used here:
  220. X
  221. X %define [[  %[%    define [[ as a macro to be substituted by [
  222. X %define ]]  %]%    define ]] as a macro to be substituted by ]
  223. X %define [   %\{%    now define [ to mean \{
  224. X %define ]   %\}%    and define ] to mean \}
  225. X
  226. X The last two definitions make a text like
  227. X
  228. X    a = [ 0, 1, 2, ..., n ] + [ 2n, ..., 4n ]
  229. X
  230. X to transform to
  231. X
  232. X    a =\{0, 1, 2, ..., n\}+\{2n, ..., 4n\}
  233. X
  234. X while, e.g. a reference can be put into square brackets by using double
  235. X brackets: ` [[ 1 ]] ' which becomes `[1]'. Changing the last two and first 
  236. X two definitions here, the definition of `[[' becomes identical to that of 
  237. X `[', i.e. with `\{'.
  238. X
  239. X
  240. Xo 6.3. Our third example defines some model-theoretical stuff:
  241. X
  242. X %mdefine /\   % \wedge %           and sign
  243. X %mdefine \/   % \vee %             or sign
  244. X %mdefine |--  % \vdash %           syntactically follows
  245. X %mdefine |==  % \models %          semantically follows
  246. X %mdefine -->  % \rightarrow %       implies
  247. X %mdefine phi  % \varphi %
  248. X %mdefine ALL  % \forall %
  249. X %mdefine not  % \neg %             
  250. X %mdefine ...  % \ldots %           ellipsis notation
  251. X
  252. X Since the preprocessor does not treat the backslash as a special symbol,
  253. X `/\' and `\/' will be recognized without any trouble. The spaces at the 
  254. X end of each definition are necessary because before replacing the macro 
  255. X name, its surrounding white spaces (or braces) are deleted. So displayed
  256. X formulas can be written as, e.g.
  257. X
  258. X    $$ |== ALL x ( phi (x) \/ not phi (x) ) $$
  259. X    $$ |-- phi --> ( not phi --> phi ) $$
  260. X
  261. X
  262. Xo 6.4. Sometimes it is convenient to use `**' to denote exponentiation:
  263. X
  264. X %mdefine #1 ** #2 %#1^{#2}%
  265. X
  266. X Here ` e ** { x ** 2 / 2 } ' or ` e **{x ** 2 /2}' becomes `e^{x^{2}/ 2 } '
  267. X (look out for the spaces!). The braces around #2 in the definition are
  268. X necessary to ensure that all the second parameter shows up in the exponent.
  269. X Without those braces the expanded form of the first form would be
  270. X `e^x^2/ 2 ', evidently not what was intended.
  271. X
  272. X
  273. Xo 6.5. The next example shows how to use "before" parameters when they are
  274. X handy:
  275. X
  276. X %mdefine #1 tilde %\wildetilde{#1}%
  277. X %mdefine #1 hat %\wildehat{#1}%
  278. X
  279. X After these definition the following text
  280. X    ...
  281. X    a+b tilde = a tilde + b tilde
  282. X    ...
  283. X expands to
  284. X    ...
  285. X    \wildetilde{a+b}=\wildetilde{a}+\wildetilde{b}
  286. X    ...
  287. X Which one is easier to read?
  288. X
  289. X
  290. Xo 6.6. To overcome the problem corresponding to greek letters, one can define
  291. X
  292. X %define alpha %$\alpha$%
  293. X
  294. X (since greek letters are allowed in math mode only.) With this definition, 
  295. X however, there are certain problems. Using this macro in the text `Let alpha 
  296. X be the ...', the substitution mechanism erases ALL the spaces around the word 
  297. X `alpha', and the result is `Let$\alpha$be the ...'. Evidently no what was 
  298. X wanted. Changing the definition to
  299. X
  300. X %define alpha % $\alpha$ % now with spaces
  301. X
  302. X will put back the spaces both BEFORE and AFTER the word, thus giving 
  303. X    Let $\alpha$ be the ...
  304. X       ^^^^^^^^^^-- substituted text
  305. X Having this latter definition, however, you cannot write alpha's without 
  306. X intervening spaces. Another problem is that this definition cannot be used in 
  307. X math mode! A possible solution is that the macro `alpha' will be used in math 
  308. X mode only, now with the definition
  309. X
  310. X %mdefine alpha %\alpha %
  311. X
  312. X The above sentence can be written as `Let $alpha$ be the ...'. Also, two
  313. X consecutive alpha's can be produced as
  314. X
  315. X    `here are two $alpha$'s: $alpha alpha$'.
  316. X
  317. X The word alpha, if found not in math mode, won't change. And, if you want
  318. X to use the word alpha in math (or displayed) mode, you can use the \preserve
  319. X keyword:
  320. X    I can write $\preserve alpha$ in math mode.
  321. X
  322. X
  323. Xo 6.7. Strings used to switch to and from math mode are also subject to macro
  324. X replacement. Thus using the definitions
  325. X
  326. X \def\mydisplayformula#1#2{ $$ #2 \leqno #1 $$}
  327. X %dispmode .EQ .EN
  328. X %define .EQ #1 % \mydisplayformula{#1}{ %
  329. X %define .EN % } %
  330. X
  331. X an eqn-like construct for display formulas can be used so that the formula
  332. X number (written after .EQ) appears on the left of the displayed formula.
  333. X However, if you don't want this number to appear, you still have to submit
  334. X a parameter, which can be the empty string, i.e. `{}'
  335. X
  336. X
  337. X   7. How to use the preprocessor?
  338. X
  339. XTo compile the program on a UNIX machine, simply invoke cc by typing
  340. X
  341. X        cc texpp.c -o texpp
  342. X
  343. XOn certain systems the 'strdup()' function is missing from the standard C
  344. Xlibrary. In this case, recompile the program by
  345. X
  346. X        cc -DSTRDUP texpp.c -o texpp
  347. X
  348. XThe preprocessor works as a filter. It reads one ore more input files,
  349. Xprocesses them, and then produces a single output which can be the input
  350. Xfor TeX. The program can be invoked by typing
  351. X
  352. X    texpp file1 file2 ... filen -[wa] output_file 
  353. X
  354. X`file1', ..., `filen' are processed in their given order; a file definition
  355. Xconsisting of a single `-' sign means read from stdin. The output goes to 
  356. X`output_file', the file is overwritten if the name is preceded by `-w', and
  357. Xis appended if `-a' is present. Error messages are inserted into the output
  358. Xand are duplicated at stderr. If no input file is given, the program reads
  359. Xfrom stdin; if no output file is given, then the output goes to stdout. When
  360. Xthe program halts, the exit value is 0 if `texpp' run successfully, if any
  361. Xerror occurred (cannot open a file or processing error) then the exit value
  362. Xis 1.
  363. X
  364. END_OF_FILE
  365. if test 14110 -ne `wc -c <'README'`; then
  366.     echo shar: \"'README'\" unpacked with wrong size!
  367. fi
  368. # end of 'README'
  369. fi
  370. if test -f 'macro.pp' -a "${1}" != "-c" ; then 
  371.   echo shar: Will not clobber existing file \"'macro.pp'\"
  372. else
  373. echo shar: Extracting \"'macro.pp'\" \(4392 characters\)
  374. sed "s/^X//" >'macro.pp' <<'END_OF_FILE'
  375. X%% ---- TeXpp macro definitions ----
  376. X%% ----   for plain TeX files   ----
  377. X%%
  378. X%%  A macro definition should fit into a single line. If the definition is 
  379. X%%  too long, we can continue after closing the line with a backslash....
  380. X%%
  381. X%% - 1.   Greek letters  ----
  382. X%mdefine alpha        %\alpha %
  383. X%mdefine beta        %\beta %
  384. X%mdefine gamma        %\gamma %
  385. X%mdefine delta        %\delta %
  386. X%mdefine eps        %\varepsilon %
  387. X%mdefine zeta        %\zeta %
  388. X%mdefine eta        %\eta %
  389. X%mdefine theta        %\vartheta %
  390. X%mdefine iota        %\iota %
  391. X%mdefine kappa        %\kappa %
  392. X%mdefine pi        %\pi %
  393. X%mdefine rho        %\varrho %
  394. X%mdefine chi        %\chi %
  395. X%mdefine phi        %\varphi %
  396. X%mdefine psi        %\psi %
  397. X%mdefine omega        %\omega %
  398. X%mdefine GAMMA        %\Gamma %
  399. X%mdefine DELTA        %\Delta %
  400. X%mdefine LAMBDA        %\Lambda %
  401. X%mdefine PHI        %\Phi %
  402. X%mdefine SIGMA        %\Sigma %
  403. X%%
  404. X%% -2.   Mathematical functions names ----
  405. X%mdefine log        %\log %
  406. X%mdefine sin        %\sin %
  407. X%mdefine cos        %\cos %
  408. X%mdefine mod        %\bmod %        as in "i mod 2"
  409. X%%
  410. X%% -3.   Special symbols ----
  411. X%mdefine aleph        %\aleph %
  412. X%mdefine l        %\ell %            written letter
  413. X%mdefine ||        %\|%            norm sign
  414. X%mdefine oo        %\infty %        infinity
  415. X%mdefine not        %\neg %            negation sign
  416. X%mdefine EMPTY        %\emptyset %        slashed zero
  417. X%mdefine o|o        %\clubsuit %
  418. X%mdefine <>        %\diamondsuit %
  419. X%%
  420. X%%        doubly written C,N,Q and R letters for
  421. X%%        complex, natural, rational and real numbers
  422. X%mdefine IC        %\hbox{\hbox{C\hskip-0.5em\lower-0.1ex\
  423. X           \hbox{\vrule height1.34ex width0.07em }}\hskip0.50em}%
  424. X
  425. X%mdefine IN        %\hbox{I\hskip-0.20em I\hskip-0.35em N}%
  426. X%mdefine IQ        %\hbox{\hbox{Q\hskip-0.525em\lower-0.097ex\
  427. X            \hbox{\vrule height1.47ex width0.07em}}\hskip0.50em}%
  428. X%mdefine IR        %\hbox{I\hskip-0.23em R}%
  429. X%%
  430. X%%        I don't like these thin signs, so I redefined them
  431. X%%mdefine ALL #1    %\forall #1 \>%
  432. X%%mdefine EXISTS #1    %\exists #1 \>%
  433. X%mdefine ALL #1        %{\leavevmode\hbox{\rm V\kern-0.53em\
  434. X\lower-.5ex\hbox{-}}\kern0.1em} #1 \>%
  435. X%mdefine EXISTS #1    %{\Xi\kern-0.37em{\bf I}} #1 \>%
  436. X%%
  437. X%% -4.   Operators ----
  438. X%mdefine /\        %\wedge %        and sign
  439. X%mdefine _/\_         %\bigwedge%        big and sign
  440. X%mdefine \/        %\vee %            or sign
  441. X%mdefine ~\/~        %\bigvee %        big or sign
  442. X%mdefine +-        %\pm %            plusminus
  443. X%mdefine COMP        %\circ %        small circle (composition)
  444. X%mdefine CROSS        %\times %        cross for vectors
  445. X%mdefine BULL        %\bullet %        full small circle
  446. X%mdefine dot        %\cdot %        centered dot (multiplication)
  447. X%mdefine UNION        %\cup %            small union symbol
  448. X%mdefine METS        %\cap %            small intersection symbol
  449. X%%                        +/-/= sign and a dot on it
  450. X%mdefine .+.        %{\mathrel{\> +\hbox{\hskip-0.565em\
  451. X\lower-1.8ex\hbox{.}}\hskip0.4em}}%
  452. X%mdefine .-.        %{\mathrel{\> -\hbox{\hskip-0.55em\
  453. X\lower-1.2ex\hbox{.}}\hskip0.4em}}%
  454. X%mdefine .=.        %\doteq %
  455. X%%
  456. X%% -5.   Relations ----
  457. X%mdefine ==        %\equiv %        equivalence
  458. X%mdefine !==        %\not\equiv %        slashed equivalence
  459. X%mdefine !=        %\not= %        not equal
  460. X%mdefine <=        %\leq %            less than or equal to
  461. X%mdefine >=        %\geq %
  462. X%mdefine SUBS        %\subset %        subset of
  463. X%mdefine EXTS        %\supset %        extension of
  464. X%mdefine in        %\in %            element
  465. X%mdefine !in        %\notin% %        not an element
  466. X%mdefine |--        %\vdash %        proves
  467. X%mdefine !|--        %\not\vdash %        not proves
  468. X%mdefine |==        %\models %        semantically follows
  469. X%mdefine !|==        %\not\models %
  470. X%%
  471. X%% -6.   Arrows ----
  472. X%mdefine -->        %\rightarrow %
  473. X%mdefine <-->        %\leftrightarrow %
  474. X%mdefine <--        %\leftarrow %
  475. X%mdefine ==>        %\Rightarrow %
  476. X%mdefine <==>        %\Leftrightarrow %
  477. X%mdefine ==>        %\Rightarrow %
  478. X%mdefine |-->        %\mapsto %
  479. X%%
  480. X%% -7.   Miscellaneous ----
  481. X%mdefine ...        %\ldots %        ellipsis
  482. X%mdefine ...,        %\ldots,%        dots followed by a comma
  483. X%mdefine =def        % \>{\buildrel \rm def \over =}\> %
  484. X%mdefine <:        %\langle %        left angular bracket
  485. X%mdefine :>        %\rangle %        right angular bracket
  486. X%mdefine [[        %[\![%            double open [
  487. X%mdefine ]]        %]\!]%            double closing ]
  488. X%%
  489. X%mdefine #1 tilde    %\widetilde{#1}%    put a tilde 
  490. X%mdefine #1 bar        %\overline{#1}%        put a line over
  491. X%mdefine #1 hat        %\wildehat{#1}%        put a hat (^)
  492. X%mdefine #1 vec        %\overrightarrow{#1}%    put a --> at the top
  493. X%mdefine sub #1        %_{#1}%            for a subscript
  494. X%mdefine sup #1        %^{#1}%            for a superscript
  495. X%%
  496. X\def\mydisplayformula#1#2{ $$ #2 \leqno #1 $$}
  497. X%define .EQ #1        %\mydisplayformula{#1}{%
  498. X%define .EN        %}%
  499. X%dispmode .EQ .EN
  500. X%%
  501. X%define LEMMA #1    %\proclaim Lemma #1 %
  502. X%define PROOF.        %\noindent{\bf Proof.} %
  503. X%define THEOREM #1    %\proclaim Theorem #1 %
  504. X%define QED        % {\vrule height 7pt depth 1pt width 7pt} % back box
  505. X%mdefine iff        %{\ \ \rm iff \ \ }%
  506. X
  507. X
  508. END_OF_FILE
  509. if test 4392 -ne `wc -c <'macro.pp'`; then
  510.     echo shar: \"'macro.pp'\" unpacked with wrong size!
  511. fi
  512. # end of 'macro.pp'
  513. fi
  514. if test -f 'tex-mode.el' -a "${1}" != "-c" ; then 
  515.   echo shar: Will not clobber existing file \"'tex-mode.el'\"
  516. else
  517. echo shar: Extracting \"'tex-mode.el'\" \(20255 characters\)
  518. sed "s/^X//" >'tex-mode.el' <<'END_OF_FILE'
  519. X;; TeX mode commands.
  520. X;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  521. X;; Rewritten following contributions by William F. Schelter
  522. X;; and Dick King (king@kestrel).
  523. X;; Modified August 1986 by Stephen Gildea <mit-erl!gildea> and
  524. X;; Michael Prange <mit-erl!prange> to add LaTeX support and enhance
  525. X;; TeX-region.
  526. X;; Added TeX-directory and reorganized somewhat  gildea 21 Nov 86
  527. X;; Modified to handle TeX preprocessors by csirmaz@cs.rutgers.edu 21 Nov 89
  528. X
  529. X;; This file is part of GNU Emacs.
  530. X
  531. X;; GNU Emacs is distributed in the hope that it will be useful,
  532. X;; but WITHOUT ANY WARRANTY.  No author or distributor
  533. X;; accepts responsibility to anyone for the consequences of using it
  534. X;; or for whether it serves any particular purpose or works at all,
  535. X;; unless he says so in writing.  Refer to the GNU Emacs General Public
  536. X;; License for full details.
  537. X
  538. X;; Everyone is granted permission to copy, modify and redistribute
  539. X;; GNU Emacs, but only under the conditions described in the
  540. X;; GNU Emacs General Public License.   A copy of this license is
  541. X;; supposed to have been given to you along with GNU Emacs so you
  542. X;; can know your rights and responsibilities.  It should be in a
  543. X;; file named COPYING.  Among other things, the copyright notice
  544. X;; and this notice must be preserved on all copies.
  545. X
  546. X;; Still to do:
  547. X;;  Make TAB indent correctly for TeX code.  Then we can make linefeed
  548. X;;  do something more useful.
  549. X;;
  550. X;;  Have spell understand TeX instead of assuming the entire world
  551. X;;  uses nroff.
  552. X;;
  553. X;;  The code for finding matching $ needs to be fixed.
  554. X
  555. X;;;
  556. X;;; To costumize TeX preprocessing, you can put the following lines
  557. X;;; into the .emacs init file:
  558. X;;;    (defun set-my-TeX-filter-default ()
  559. X;;;      (setq TeX-show-dvi-command "your favorite DVI view program")
  560. X;;;      (setq TeX-filter "...here the filter with full path...")
  561. X;;;      (setq TeX-filter-args '("...first macro file with full path..." 
  562. X;;;                              "...second macro file with full path..."
  563. X;;;                              "-"     ;;;for the buffer
  564. X;;;                              "-a"))  ;;;append the output
  565. X;;;    )
  566. X;;;    (setq TeX-mode-hook (if (boundp 'TeX-mode-hook)
  567. X;;;       (append TeX-mode-hook 'set-my-TeX-filter-default)
  568. X;;;       'set-my-TeX-filter-default)
  569. X;;;    )
  570. X;;; If you want to use 'ispell' to check TeX text, use the following in
  571. X;;; your .emacs init file:
  572. X;;;    (require 'ispell)
  573. X;;;    (set-default 'ispell-filter-hook shell-file-name)
  574. X;;;    (set-default 'ispell-filter-hook-args 
  575. X;;;                 '("-f" "-c" "(detex -iw | tr -cs A-Za-z \\\\012)"))
  576. X
  577. X
  578. X;;;
  579. X
  580. X(provide 'tex-mode)
  581. X
  582. X(defvar TeX-directory "/tmp/"
  583. X  "*Directory in which to run TeX subjob.  Temporary files are
  584. Xcreated in this directory.")
  585. X(defvar TeX-dvi-print-command "lpr -d"
  586. X  "*Command string used by \\[TeX-print] to print a .dvi file.")
  587. X(defvar TeX-show-dvi-command "texx"
  588. X  "*Command used by \\[TeX-view-dvi] for screen view the dvi file")
  589. X(defvar TeX-show-queue-command "lpq"
  590. X  "*Command string used by \\[TeX-show-print-queue] to show the print queue
  591. Xthat \\[TeX-print] put your job on.")
  592. X(defvar TeX-default-mode 'plain-TeX-mode
  593. X  "*Mode to enter for a new file when it can't be determined whether
  594. Xthe file is plain TeX or LaTeX or what.")
  595. X
  596. X(defvar TeX-command nil
  597. X  "The command to run TeX on a file.  The name of the file will be appended
  598. Xto this string, separated by a space.")
  599. X(defvar TeX-filter ()
  600. X  "*Filter to produce a file by \\[TeX-region] on which TeX is called.")
  601. X(defvar TeX-filter-args '()
  602. X  "*Arguments to the filter TeX-filter")
  603. X(defvar TeX-trailer nil
  604. X  "String appended after the end of a region send to TeX by \\[TeX-region].")
  605. X(defvar TeX-start-of-header nil
  606. X  "String used by \\[TeX-region] to delimit the start of the file's header.")
  607. X(defvar TeX-end-of-header nil
  608. X  "String used by \\[TeX-region] to delimit the end of the file's header.")
  609. X(defvar TeX-shell-cd-command "cd"
  610. X  "Command to give to shell running TeX to change directory.  The value of
  611. XTeX-directory will be appended to this, separated by a space.")
  612. X(defvar TeX-zap-file nil
  613. X  "Temporary file name used for text being sent as input to TeX.
  614. XShould be a simple file name with no extension or directory specification.")
  615. X
  616. X(defvar TeX-mode-syntax-table nil
  617. X  "Syntax table used while in TeX mode.")
  618. X
  619. X(defun TeX-define-common-keys (keymap)
  620. X  "Define the keys that we want defined both in TeX-mode
  621. Xand in the TeX-shell."
  622. X  (define-key keymap "\C-c\C-k" 'TeX-kill-job)
  623. X  (define-key keymap "\C-c\C-l" 'TeX-recenter-output-buffer)
  624. X  (define-key keymap "\C-c\C-q" 'TeX-show-print-queue)
  625. X  (define-key keymap "\C-c\C-p" 'TeX-print)
  626. X  (define-key keymap "\C-c\C-v" 'TeX-view-dvi)
  627. X  )
  628. X
  629. X(defvar TeX-mode-map nil "Keymap for TeX mode")
  630. X
  631. X(if TeX-mode-map 
  632. X    nil
  633. X  (setq TeX-mode-map (make-sparse-keymap))
  634. X  (TeX-define-common-keys TeX-mode-map)
  635. X  (define-key TeX-mode-map "\"" 'TeX-insert-quote)
  636. X  (define-key TeX-mode-map "\n" 'TeX-terminate-paragraph)
  637. X  (define-key TeX-mode-map "\e}" 'up-list)
  638. X  (define-key TeX-mode-map "\e{" 'TeX-insert-braces)
  639. X  (define-key TeX-mode-map "\C-c\C-r" 'TeX-region)
  640. X  (define-key TeX-mode-map "\C-c\C-b" 'TeX-buffer)
  641. X  (define-key TeX-mode-map "\C-c\C-f" 'TeX-close-LaTeX-block)
  642. X  )
  643. X
  644. X(defvar TeX-shell-map nil
  645. X  "Keymap for the TeX shell.  A shell-mode-map with a few additions")
  646. X
  647. X;(fset 'TeX-mode 'tex-mode)         ;in loaddefs.
  648. X
  649. X;;; This would be a lot simpler if we just used a regexp search,
  650. X;;; but then it would be too slow.
  651. X(defun tex-mode ()
  652. X  "Major mode for editing files of input for TeX or LaTeX.
  653. XTrys to intuit whether this file is for plain TeX or LaTeX and
  654. Xcalls plain-tex-mode or latex-mode.  If it cannot be determined
  655. X\(e.g., there are no commands in the file), the value of
  656. XTeX-default-mode is used."
  657. X  (interactive)
  658. X  (let (mode slash comment)
  659. X    (save-excursion
  660. X      (goto-char (point-min))
  661. X      (while (and (setq slash (search-forward "\\" nil t))
  662. X          (setq comment (let ((search-end (point)))
  663. X                  (save-excursion
  664. X                    (beginning-of-line)
  665. X                    (search-forward "%" search-end t))))))
  666. X      (if (and slash (not comment))
  667. X      (setq mode (if (looking-at "documentstyle")
  668. X             'latex-mode
  669. X               'plain-tex-mode))))
  670. X    (if mode (funcall mode)
  671. X      (funcall TeX-default-mode))))
  672. X
  673. X(fset 'plain-TeX-mode 'plain-tex-mode)
  674. X(fset 'LaTeX-mode 'latex-mode)
  675. X
  676. X(defun plain-tex-mode ()
  677. X  "Major mode for editing files of input for plain TeX.
  678. XMakes $ and } display the characters they match.
  679. XMakes \" insert `` when it seems to be the beginning of a quotation,
  680. Xand '' when it appears to be the end; it inserts \" only after a \\.
  681. X
  682. XUse \\[TeX-region] to run TeX on the current region, plus a \"header\"
  683. Xcopied from the top of the file (containing macro definitions, etc.),
  684. Xrunning TeX under a special subshell.  \\[TeX-buffer] does the whole buffer.
  685. X\\[TeX-print] prints the .dvi file made by either of these,
  686. X\\[TeX-view-dvi] shows a dvi view.
  687. X
  688. XUse \\[validate-TeX-buffer] to check buffer for paragraphs containing
  689. Xmismatched $'s or braces.
  690. X
  691. XSpecial commands:
  692. X\\{TeX-mode-map}
  693. X
  694. XMode variables:
  695. XTeX-directory
  696. X    Directory in which to create temporary files for TeX jobs
  697. X    run by \\[TeX-region] or \\[TeX-buffer].
  698. XTeX-filter
  699. X    program (maybe with full path) to filter the region or buffer
  700. X    before calling tex or latex.
  701. XTeX-filter-args
  702. X    list of arguments to TeX-filter.
  703. XTeX-dvi-print-command
  704. X    Command string used by \\[TeX-print] to print a .dvi file.
  705. XTeX-show-queue-command
  706. X    Command string used by \\[TeX-show-print-queue] to show the print
  707. X    queue that \\[TeX-print] put your job on.
  708. X
  709. XEntering plain-TeX mode calls the value of text-mode-hook,
  710. Xthen the value of TeX-mode-hook, and then the value
  711. Xof plain-TeX-mode-hook."
  712. X  (interactive)
  713. X  (TeX-common-initialization)
  714. X  (setq mode-name "TeX")
  715. X  (setq major-mode 'plain-TeX-mode)
  716. X  (setq TeX-command "tex")
  717. X  (setq TeX-start-of-header "%**start of header")
  718. X  (setq TeX-end-of-header "%**end of header")
  719. X  (setq TeX-trailer "\\bye\n")
  720. X  (run-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook))
  721. X
  722. X(defun latex-mode ()
  723. X  "Major mode for editing files of input for LaTeX.
  724. XMakes $ and } display the characters they match.
  725. XMakes \" insert `` when it seems to be the beginning of a quotation,
  726. Xand '' when it appears to be the end; it inserts \" only after a \\.
  727. X
  728. XUse \\[TeX-region] to run LaTeX on the current region, plus the preamble
  729. Xcopied from the top of the file (containing \\documentstyle, etc.),
  730. Xrunning LaTeX under a special subshell.  \\[TeX-buffer] does the whole buffer.
  731. X\\[TeX-print] prints the .dvi file made by either of these.
  732. X
  733. XUse \\[validate-TeX-buffer] to check buffer for paragraphs containing
  734. Xmismatched $'s or braces.
  735. X
  736. XSpecial commands:
  737. X\\{TeX-mode-map}
  738. X
  739. XMode variables:
  740. XTeX-directory
  741. X    Directory in which to create temporary files for TeX jobs
  742. X    run by \\[TeX-region] or \\[TeX-buffer].
  743. XTeX-filter
  744. X    program (maybe with full path) to filter the region or buffer
  745. X    before calling tex or latex.
  746. XTeX-filter-args
  747. X    list of arguments to TeX-filter.
  748. XTeX-dvi-print-command
  749. X    Command string used by \\[TeX-print] to print a .dvi file.
  750. XTeX-show-queue-command
  751. X    Command string used by \\[TeX-show-print-queue] to show the print
  752. X    queue that \\[TeX-print] put your job on.
  753. X
  754. XEntering LaTeX mode calls the value of text-mode-hook,
  755. Xthen the value of TeX-mode-hook, and then the value
  756. Xof LaTeX-mode-hook."
  757. X  (interactive)
  758. X  (TeX-common-initialization)
  759. X  (setq mode-name "LaTeX")
  760. X  (setq major-mode 'LaTeX-mode)
  761. X  (setq TeX-command "latex")
  762. X  (setq TeX-start-of-header "\\documentstyle")
  763. X  (setq TeX-end-of-header "\\begin{document}")
  764. X  (setq TeX-trailer "\\end{document}\n")
  765. X  (run-hooks 'text-mode-hook 'TeX-mode-hook 'LaTeX-mode-hook))
  766. X
  767. X(defun TeX-common-initialization ()
  768. X  (kill-all-local-variables)
  769. X  (use-local-map TeX-mode-map)
  770. X  (setq local-abbrev-table text-mode-abbrev-table)
  771. X  (if (null TeX-mode-syntax-table)
  772. X      (progn
  773. X    (setq TeX-mode-syntax-table (make-syntax-table))
  774. X    (set-syntax-table TeX-mode-syntax-table)
  775. X    (modify-syntax-entry ?\\ ".")
  776. X    (modify-syntax-entry ?\f ">")
  777. X    (modify-syntax-entry ?\n ">")
  778. X    (modify-syntax-entry ?$ "$$")
  779. X    (modify-syntax-entry ?% "<")
  780. X    (modify-syntax-entry ?\" ".")
  781. X    (modify-syntax-entry ?& ".")
  782. X    (modify-syntax-entry ?_ ".")
  783. X    (modify-syntax-entry ?@ "_")
  784. X    (modify-syntax-entry ?~ " ")
  785. X    (modify-syntax-entry ?' "w"))
  786. X    (set-syntax-table TeX-mode-syntax-table))
  787. X  (make-local-variable 'paragraph-start)
  788. X  (setq paragraph-start "^[ \t]*$\\|^[\f\\\\]")
  789. X  (make-local-variable 'paragraph-separate)
  790. X  (setq paragraph-separate paragraph-start)
  791. X  (make-local-variable 'comment-start)
  792. X  (setq comment-start "%")
  793. X  (make-local-variable 'comment-start-skip)
  794. X  (setq comment-start-skip "[^\\]\\(\\(\\\\\\\\\\)*\\)%+ *")
  795. X  (make-local-variable 'comment-indent-hook)
  796. X  (setq comment-indent-hook 'TeX-comment-indent)
  797. X  (make-local-variable 'TeX-command)
  798. X  (make-local-variable 'TeX-trailer))
  799. X
  800. X(defun TeX-comment-indent ()
  801. X  (if (looking-at "%%%")
  802. X      (current-column)
  803. X    (skip-chars-backward " \t")
  804. X    (max (if (bolp) 0 (1+ (current-column)))
  805. X     comment-column)))
  806. X
  807. X(defun TeX-insert-quote (arg)
  808. X  "Insert ``, '' or \" according to preceding character.
  809. XWith prefix argument, always insert \" characters."
  810. X  (interactive "P")
  811. X  (if arg
  812. X      (let ((count (prefix-numeric-value arg)))
  813. X    (if (listp arg)
  814. X        (self-insert-command 1)    ;C-u always inserts just one
  815. X      (self-insert-command count)))
  816. X    (insert
  817. X     (cond
  818. X      ((or (bobp)
  819. X       (save-excursion
  820. X         (forward-char -1)
  821. X         (looking-at "[ \t\n]\\|\\s(")))
  822. X       "``")
  823. X      ((= (preceding-char) ?\\)
  824. X       ?\")
  825. X      (t "''")))))
  826. X
  827. X(defun validate-TeX-buffer ()
  828. X  "Check current buffer for paragraphs containing mismatched $'s.
  829. XAs each such paragraph is found, a mark is pushed at its beginning,
  830. Xand the location is displayed for a few seconds."
  831. X  (interactive)
  832. X  (let ((opoint (point)))
  833. X    (goto-char (point-max))
  834. X    ;; Does not use save-excursion
  835. X    ;; because we do not want to save the mark.
  836. X    (unwind-protect
  837. X    (while (and (not (input-pending-p)) (not (bobp)))
  838. X      (let ((end (point)))
  839. X        (search-backward "\n\n" nil 'move)
  840. X        (or (TeX-validate-paragraph (point) end)
  841. X        (progn
  842. X          (push-mark (point))
  843. X          (message "Mismatch found in pararaph starting here")
  844. X          (sit-for 4)))))
  845. X      (goto-char opoint))))
  846. X
  847. X(defun TeX-validate-paragraph (start end)
  848. X  (condition-case ()
  849. X      (save-excursion
  850. X    (save-restriction
  851. X      (narrow-to-region start end)
  852. X      (goto-char start)
  853. X      (forward-sexp (- end start))
  854. X      t))
  855. X    (error nil)))
  856. X
  857. X(defun TeX-terminate-paragraph (inhibit-validation)
  858. X  "Insert two newlines, breaking a paragraph for TeX.
  859. XCheck for mismatched braces/$'s in paragraph being terminated.
  860. XA prefix arg inhibits the checking."
  861. X  (interactive "P")
  862. X  (or inhibit-validation
  863. X      (TeX-validate-paragraph
  864. X       (save-excursion
  865. X     (search-backward "\n\n" nil 'move)
  866. X     (point))
  867. X       (point))
  868. X      (message "Paragraph being closed appears to contain a mismatch"))
  869. X  (insert "\n\n"))
  870. X
  871. X(defun TeX-insert-braces ()
  872. X  "Make a pair of braces and be poised to type inside of them."
  873. X  (interactive)
  874. X  (insert ?\{)
  875. X  (save-excursion
  876. X    (insert ?})))
  877. X
  878. X;;; Like TeX-insert-braces, but for LaTeX.
  879. X(defun TeX-close-LaTeX-block ()
  880. X  "Creates an \\end{...} to match \\begin{...} on the current line and
  881. Xputs point on the blank line between them."
  882. X  (interactive "*")
  883. X  (let ((fail-point (point)))
  884. X    (end-of-line)
  885. X    (if (re-search-backward "\\\\begin{\\([^}\n]*\\)}"
  886. X                (save-excursion (beginning-of-line) (point)) t)
  887. X    (let ((text (buffer-substring (match-beginning 1) (match-end 1)))
  888. X          (indentation (current-column)))
  889. X      (end-of-line)
  890. X      (delete-horizontal-space)
  891. X      (insert "\n\n")
  892. X      (indent-to indentation)
  893. X      (insert "\\end{" text "}")
  894. X      (forward-line -1))
  895. X      (goto-char fail-point)
  896. X      (ding))))
  897. X
  898. X;;; Invoking TeX in an inferior shell.
  899. X
  900. X;;; Why use a shell instead of running TeX directly?  Because if TeX
  901. X;;; gets stuck, the user can switch to the shell window and type at it.
  902. X
  903. X;;; The utility functions:
  904. X
  905. X(defun TeX-start-shell ()
  906. X  (require 'shell)
  907. X  (if (eq (process-status "TeX-shell") 'run) ()
  908. X  (save-excursion
  909. X    (let ((buffer (make-shell "TeX-shell" shell-file-name nil "-v")))
  910. X      (process-kill-without-query (get-buffer-process buffer))
  911. X      (set-buffer buffer)
  912. X      (setq TeX-shell-map (copy-keymap shell-mode-map))
  913. X      (TeX-define-common-keys TeX-shell-map)
  914. X      (use-local-map TeX-shell-map)))))
  915. X
  916. X(defun set-buffer-directory (buffer directory)
  917. X  "Set BUFFER's default directory to be DIRECTORY."
  918. X  (setq directory (file-name-as-directory (expand-file-name directory)))
  919. X  (if (not (file-directory-p directory))
  920. X      (error "%s is not a directory" directory)
  921. X    (save-excursion
  922. X      (set-buffer buffer)
  923. X      (setq default-directory directory))))
  924. X
  925. X;;; It's a kludge that we have to create a special buffer just 
  926. X;;; to write out the TeX-trailer.  It would nice if there were a
  927. X;;; function like write-region that would write literal strings.
  928. X
  929. X;;; write-region complains if the file is also a buffer. To overcome
  930. X;;; this, here is my version
  931. X(defun my-write-region (beg end file app)
  932. X"The region between BEGIN and END of the current buffer is written or
  933. Xappended to the FILE depending whether the fourth argument is nil or
  934. Xnon-nil (append in the latter case)."
  935. X    (call-process-region beg end shell-file-name nil nil nil
  936. X    "-F" "-c" (concat "cat " (if app ">>" ">") "\"" file "\""))
  937. X)
  938. X
  939. X(defun TeX-region (beg end)
  940. X  "Run TeX on the current region.  The region is filtered through the
  941. Xprogram given in (TeX-filter) to produce the temporary file (TeX-zap-file)
  942. Xin directory (TeX-directory). TeX is run in that directory. If the buffer has
  943. Xa header, it is written to the temporary file before the region. Also, the
  944. Xvalue of the TeX-trailer is appended to the file. They are NOT filtered through
  945. X(TeX-filter). The buffer's header is all lines between the string defined by
  946. XTeX-start-of-header and TeX-end-of-header inclusive."
  947. X  (interactive "r")
  948. X  (or TeX-zap-file (setq TeX-zap-file (make-temp-name "#tz")))
  949. X  (let* ((tex-out-file (concat TeX-zap-file ".tex"))
  950. X     (tex-out-buffer (get-file-buffer tex-out-file))
  951. X     (temp-buffer (get-buffer-create " TeX-Output-Buffer"))
  952. X     (zap-directory (expand-file-name TeX-directory))
  953. X         (local-tex-trailer TeX-trailer))
  954. X    (unwind-protect (save-excursion (save-restriction
  955. X    (widen)
  956. X    (goto-char (point-min))
  957. X    (forward-line 100)
  958. X    (let ((search-end (point))
  959. X          (hbeg (point-min)) (hend (point-min))
  960. X          (default-directory zap-directory))
  961. X      (goto-char (point-min))
  962. X      ;; Initialize the temp file with either the header or nothing
  963. X      (if (search-forward TeX-start-of-header search-end t)
  964. X          (progn
  965. X        (forward-line -1)
  966. X        (setq hbeg (point))    ;mark beginning of header
  967. X        (if (search-forward TeX-end-of-header nil t)
  968. X            (progn (forward-line 1)
  969. X               (setq hend (min beg (point))));mark end of header
  970. X          (setq hbeg (point-min))))) ;no header
  971. X      (my-write-region (min hbeg beg) hend tex-out-file nil))
  972. X         (message "Preprocessing...")
  973. X         (narrow-to-region beg end)
  974. X         (sit-for 0)
  975. X         (save-excursion  (set-buffer temp-buffer)  (erase-buffer))
  976. X         (if TeX-filter
  977. X           (apply 'call-process-region
  978. X             (append (list beg end TeX-filter nil temp-buffer nil)
  979. X                     TeX-filter-args
  980. X                     (list (concat zap-directory tex-out-file))))
  981. X           (my-write-region beg end (concat zap-directory tex-out-file) t))
  982. X         (message "Done...") (sit-for 0)
  983. X    )))
  984. X    (if (save-excursion (set-buffer temp-buffer)
  985. X                (beginning-of-file) (eobp))
  986. X        (progn
  987. X           (save-excursion
  988. X             (set-buffer temp-buffer)
  989. X             (set-buffer-directory temp-buffer zap-directory)
  990. X             (insert-string "\n")
  991. X             (if local-tex-trailer (insert-string local-tex-trailer))
  992. X             (my-write-region (point-min) (point-max) tex-out-file t))
  993. X           (pop-to-TeX-shell zap-directory tex-out-file)
  994. X         )
  995. X;;; error during preprocessing, show the error messages ...
  996. X      (let ((buffer (current-buffer))) 
  997. X        (pop-to-buffer temp-buffer)
  998. X        (pop-to-buffer buffer))
  999. X    )
  1000. X))
  1001. X
  1002. X(defun pop-to-TeX-shell (zap-directory tex-out-file)
  1003. X   (if (get-buffer "*TeX-shell*") (TeX-kill-job))
  1004. X   (TeX-start-shell)
  1005. X   (set-buffer-directory "*TeX-shell*" zap-directory)
  1006. X   (send-string "TeX-shell" (concat TeX-shell-cd-command " "
  1007. X                     zap-directory "\n"))
  1008. X   (send-string "TeX-shell" (concat TeX-command " \""
  1009. X                     tex-out-file "\"\n"))
  1010. X   (TeX-recenter-output-buffer 0)
  1011. X)
  1012. X
  1013. X(defun TeX-buffer ()
  1014. X  "Run TeX on current buffer.  See \\[TeX-region] for more information."
  1015. X  (interactive)
  1016. X  (TeX-region (point-min) (point-max)))
  1017. X
  1018. X(defun TeX-kill-job ()
  1019. X  "Kill the currently running TeX job."
  1020. X  (interactive)
  1021. X  (if (process-status "TeX-shell")      ; not nil if the process exists
  1022. X      (quit-process "TeX-shell" t)))
  1023. X
  1024. X(defun TeX-recenter-output-buffer (linenum)
  1025. X  "Redisplay buffer of TeX job output so that most recent output can be seen.
  1026. XThe last line of the buffer is displayed on
  1027. Xline LINE of the window, or centered if LINE is nil."
  1028. X  (interactive "P")
  1029. X  (let ((tex-shell (get-buffer "*TeX-shell*"))
  1030. X    (old-buffer (current-buffer)))
  1031. X    (if (null tex-shell)
  1032. X    (message "No TeX output buffer")
  1033. X      (pop-to-buffer tex-shell)
  1034. X      (bury-buffer tex-shell)
  1035. X      (goto-char (point-max))
  1036. X      (recenter (if linenum
  1037. X            (prefix-numeric-value linenum)
  1038. X          (/ (window-height) 2)))
  1039. X      (pop-to-buffer old-buffer)
  1040. X      )))
  1041. X
  1042. X(defun TeX-print ()
  1043. X  "Print the .dvi file made by \\[TeX-region] or \\[TeX-buffer].
  1044. XRuns the shell command defined by TeX-dvi-print-command."
  1045. X  (interactive)
  1046. X  (send-string "TeX-shell"
  1047. X           (concat TeX-dvi-print-command " \"" TeX-zap-file ".dvi\"\n"))
  1048. X  (TeX-recenter-output-buffer nil))
  1049. X
  1050. X(defun TeX-view-dvi ()
  1051. X  "Shows the .dvi file on the screen bu the shell command defined 
  1052. Xby TeX-show-dvi-command."
  1053. X  (interactive)
  1054. X  (send-string "TeX-shell"
  1055. X           (concat TeX-show-dvi-command " \"" TeX-zap-file ".dvi\"\n"))
  1056. X  (TeX-recenter-output-buffer nil))
  1057. X
  1058. X(defun TeX-show-print-queue ()
  1059. X  "Show the print queue that \\[TeX-print] put your job on.
  1060. XRuns the shell command defined by TeX-show-queue-command."
  1061. X  (interactive)
  1062. X  (if (not (get-buffer "*TeX-shell*"))
  1063. X      (TeX-start-shell))
  1064. X  (send-string "TeX-shell" (concat TeX-show-queue-command "\n"))
  1065. X  (TeX-recenter-output-buffer nil))
  1066. X
  1067. END_OF_FILE
  1068. if test 20255 -ne `wc -c <'tex-mode.el'`; then
  1069.     echo shar: \"'tex-mode.el'\" unpacked with wrong size!
  1070. fi
  1071. # end of 'tex-mode.el'
  1072. fi
  1073. echo shar: End of archive 1 \(of 2\).
  1074. cp /dev/null ark1isdone
  1075. MISSING=""
  1076. for I in 1 2 ; do
  1077.     if test ! -f ark${I}isdone ; then
  1078.     MISSING="${MISSING} ${I}"
  1079.     fi
  1080. done
  1081. if test "${MISSING}" = "" ; then
  1082.     echo You have unpacked both archives.
  1083.     rm -f ark[1-9]isdone
  1084. else
  1085.     echo You still need to unpack the following archives:
  1086.     echo "        " ${MISSING}
  1087. fi
  1088. ##  End of shell archive.
  1089. exit 0
  1090.  
  1091.  
  1092.