home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
contrib
/
texmode.mut
(
.txt
)
< prev
next >
Wrap
LaTeX Document
|
1995-01-14
|
23KB
|
925 lines
;; File:
;; texmode.mut - (La)TeX mode
;; Description:
;; Routines to make (La)TeX input more fun.
;; - No attempt has been made to be compatible with GNU emacs or another
;; 'smart' editor.
;; - Based on commands in the "LaTeX User's Guide & Reference Manual" by
;; Leslie Lamport.
;; - Press 'C-\' for a kind of glossary.
;; Example: pressing 'C-\' followed by 'i' inserts '\item '.
;; - Press 'M-\' to invoke command completion for LaTeX commands. The
;; list of commands contains empty commands, this is visually attractive
;; when the full list is being displayed.
;; - All LaTeX commands of the LaTeX manual are known to this program.
;; Comment out those commands that you don't need often to speed up
;; the search or to make commands unique with less characters.
;; History:
;; 940110 M.J. van der Velden
;; - fixed documentation errors
;; Public Domain (Version 3.1)
;; 930702 M.J. van der Velden
;; - added texEnvironments and changed 'tex-expand-backslash'
;; to use it.
;; - less info in modeline (the clock is more interesting)
;; (LaTeX mode is now a minor mode based on docmode)
;; - call command completion for 'M-\' instead of '\'
;; - updated to take advantage of the ME30 features
;; (mainly completion of lists of string)
;; Public Domain (Version 3.0)
;; 930324 M.J. van der Velden
;; - added insert-object now inserts more than one object, this
;; results in a smaller mco file.
;; Public Domain (Version 2.2)
;; 930130 M.J. van der Velden
;; - tex-popup-cmd now uses query-menu instead of menu-box
;; - replaced menu-box by xmenu-box in function tex-error
;; - Removed MAIN from tex-mode
;; - Changed tex-initialize-commands to MAIN.
;; - Commands are added at the end of the texCommands list
;; instead of at the front.
;; (insert-object texCommands 1000 ...)
;; instead of:
;; (insert-object texCommands -1 ...)
;; Now the commands are added in alphabetical order.
;; Public Domain (Version 2.1)
;; 930104 M.J. van der Velden
;; - Added command completion for LaTeX commands.
;; - This mode is now based on docmode.
;; Public Domain (Version 2.0)
;; 920901 M.J. van der Velden
;; Public Domain (Version 1.0)
(include me.mh)
(list
texCommands
texEnvironments
(defun
;; Try to guess what the user wants based on the next keystroke.
tex-expand-backslash
{
(string what)
(int level)
(msg "\\")
(switch (getchar)
"\\" {
(insert-text "\\")
}
"\"" {
(insert-text "``''")
(arg-prefix 2) (previous-character)
}
"b" {
(ask-user)
(what (complete CC_LIST "\\begin What? " texEnvironments))
(if (> (current-column) 1) {
(insert-text "{\\" what " }")
(previous-character)
} {
(insert-text "\\begin{" what "}^J\\end{" what "}")
(previous-line)
(end-of-line)
(newline)
})
}
"c" {
(msg "\\c")
(switch (getchar)
"a" {
(insert-text "\\caption{}")
(previous-character)
}
"h" {
(insert-text "\\chapter{}")
(previous-character)
}
"i" {
(insert-text "\\cite{}")
(previous-character)
}
)
}
"d" {
(insert-text "\\documentstyle{}")
(previous-character)
}
"e" {
(insert-text "{\\em }")
(previous-character)
}
"f" {
(insert-text "\\footnote{}")
(previous-character)
}
"i" {
(insert-text "\\item ")
}
"l" {
(insert-text "\\label{}")
(previous-character)
}
"m" {
(insert-text "\\maketitle^J")
}
"n" {
(insert-text "\\newpage^J")
}
"p" {
(insert-text "\\pagestyle{}")
(previous-character)
}
"r" {
(insert-text "\\ref{}")
(previous-character)
}
"s" {
(ask-user)
(msg "\\section Level? ")
(level (switch (getchar) "1" 1 "2" 2 "3" 3 default 0))
(insert-text "\\")
(while (>= (-= level 1) 0) {
(insert-text "sub")
})
(insert-text "section{}^J")
(arg-prefix 2) (previous-character)
}
"t" {
(insert-text "\\tableofcontents^J")
}
"v" {
(insert-text "\\verb++")
(previous-character)
}
"$" {
(insert-text "$$")
(previous-character)
}
)
}
(defun
MAIN
{
(msg "Loading LaTeX commands... ")
;;
;; Add an empty command after each change in first letter.
;; You are encouraged to comment out commands you don't need.
;;
(insert-object texCommands 10000
"abovedisplayshortskip"
"abovedisplayskip"
"acute"
"addcontentsline"
"address"
"addtocontents"
"addtocounter"
"addtolength"
"addvspace"
; "ae"
; "aleph"
; "alph"
; "Alph"
; "alpha"
; "amalg"
"and"
; "angle"
"appendix"
; "approx"
"arabic"
; "arccos"
; "arcsin"
"arg"
"arraycolsep"
"arrayrulewidth"
"arraystretch"
; "ast"
; "asymp"
"author"
""
)
(insert-object texCommands 10000
"b"
"backslash"
"bar"
"baselineskip"
"baselinestretch"
"batchmode"
"begin{abstract}"
"begin{array}"
"begin{description}"
"begin{displaymath}"
"begin{document}"
"begin{enumerate}"
"begin{equation}"
"begin{eqnarray}"
"begin{figure}"
"begin{itemize}"
"begin{list}"
"begin{math}"
"begin{minipage}"
"begin{picture}"
"begin{quote}"
"begin{sloppypar}"
"begin{tabbing}"
"begin{table}"
"begin{tabular}"
"begin{thebibliography}"
"begin{theindex}"
"begin{titlepage}"
"begin{trivlist}"
"begin{verbatim}"
"begin{verse}"
; "beginsection"
; "belowdisplayshortskip"
; "belowdisplayskip"
; "beta"
"bf"
"bibitem"
"bibliography"
"bibliographystyle"
"bigcap"
; "bigcirc"
; "bigcup"
; "bigodot"
; "bigoplus"
; "bigotimes"
; "bigskip"
; "bigskipamount"
; "bigsqcup"
; "bigtriangledown"
; "bigtriangleup"
; "biguplus"
; "bigvee"
; "bigwedge"
; "blackandwhite"
; "bmod"
"boldmath"
"bot"
"bottomfraction"
; "bowtie"
; "Box"
; "breve"
"bullet"
"bye"
""
)
(insert-object texCommands 10000
"c"
"cal"
"cap"
"caption"
"cc"
"cdot"
"cdots"
"centering"
"chapter"
"check"
; "chi"
"circ"
"circle"
"cite"
"cleardoublepage"
"clearpage"
"cleartabs"
"cline"
"closing"
; "clubsuit"
"colors"
"colorslides"
"columnsep"
"columnseprule"
; "cong"
; "coprod"
"copyright"
; "cos"
; "cosh"
; "cot"
; "coth"
; "csc"
; "cup"
""
)
(insert-object texCommands 10000
; "d"
; "dag"
; "dagger"
; "dashv"
"date"
"dblfloatpagefraction"
"dblfloatsep"
"dbltextfloatsep"
"dbltopfraction"
; "ddag"
; "ddagger"
; "ddot"
; "ddots"
; "def"
; "deg"
; "delta"
; "Delta"
; "det"
; "diamond"
; "Diamond"
; "diamondsuit"
"displaystyle"
; "div"
"documentstyle"
; "dosupereject"
; "dot"
; "doteq"
; "dotfill"
; "doublerulesep"
; "downarrow"
""
)
(insert-object texCommands 10000
; "ell"
; "em"
; "emptyset"
; "encl"
"end{abstract}"
"end{array}"
"end{description}"
"end{displaymath}"
"end{document}"
"end{enumerate}"
"end{equation}"
"end{eqnarray}"
"end{figure}"
"end{itemize}"
"end{list}"
"end{math}"
"end{minipage}"
"end{picture}"
"end{quote}"
"end{sloppypar}"
"end{tabbing}"
"end{table}"
"end{tabular}"
"end{thebibliography}"
"end{theindex}"
; "endinsert"
; "epsilon"
; "eqalignno"
; "eqalign"
; "equiv"
; "eta"
"evensidemargin"
; "exists"
; "exp"
"extracolsep"
""
)
(insert-object texCommands 10000
; "fbox"
; "fboxrule"
; "fboxsep"
"fill"
; "fivebf"
; "fivei"
; "fiverm"
; "fivesy"
; "flat"
"floatpagefraction"
"floatsep"
"flushbottom"
; "fnsymbol"
; "folio"
"footheight"
"footline"
"footnote"
"footnotemark"
"footnoterule"
"footnotesep"
"footnotesize"
"footnotetext"
"footskip"
"footstrut"
; "forall"
; "frac"
"frame"
"framebox"
"frenchspacing"
; "frown"
"fussy"
""
)
(insert-object texCommands 10000
; "gamma"
; "Gamma"
; "gcd"
; "geq"
; "gg"
"glossary"
"glossaryentry"
"grave"
""
)
(insert-object texCommands 10000
; "H"
; "hat"
"hbar"
"hbox"
"headheight"
"headline"
"headsep"
; "heartsuite"
"hfill"
"hline"
; "hom"
; "hookleftarrow"
; "hookrightarrow"
"hrulefill"
"hspace"
"huge"
"Huge"
"hyphenation"
""
)
(insert-object texCommands 10000
; "i"
; "Im"
; "imath"
; "in"
"include"
"includeonly"
"indent"
"index"
"indexentry"
"indexspace"
; "inf"
; "infty"
"input"
; "int"
"intextsep"
"invisible"
; "iota"
; "it"
"item"
"itemindent"
"itemsep"
""
)
(insert-object texCommands 10000
; "j"
; "jmath"
; "Join"
; "jot"
""
)
(insert-object texCommands 10000
; "kappa"
; "ker"
"kill"
""
)
(insert-object texCommands 10000
; "l"
"label"
"labelitemi"
"labelitemii"
"labelitemiii"
"labelitemiv"
"labelitemv"
"labelsep"
"labelwidth"
; "lambda"
; "Lambda"
"langle"
"large"
"Large"
"LARGE"
"LaTeX"
; "lceil"
; "ldots"
; "leadsto"
; "left"
; "leftarrow"
; "lefteqn"
; "leftharpoondown"
; "leftharpoonup"
"leftmargin"
"leftmargini"
"leftmarginii"
"leftmarginiii"
"leftmarginiv"
"leftmarginv"
"leftmarginvi"
; "leftrightarrow"
; "leq"
; "leqaligno"
; "lfloor"
; "lg"
; "lhd"
; "lim"
; "liminf"
; "limsup"
"line"
"linebreak"
"linethickness"
"linewidth"
"listoffigures"
"listoftables"
"listparindent"
; "ll"
; "ln"
"load"
; "log"
; "longleftarrow"
; "longleftrightarrow"
; "longmapsto"
; "longrightarrow"
""
)
(insert-object texCommands 10000
"magnification"
"makebox"
"makefootline"
"makeglossary"
"makeheadline"
"makeindex"
"makelabel"
"makelabels"
"maketitle"
; "mapsto"
"marginpar"
"marginparpush"
"marginparsep"
"marginparwidth"
"markboth"
"markright"
; "mathindent"
; "max"
"mbox"
"medskip"
"medskipamount"
; "mho"
; "mid"
; "midinsert"
; "min"
; "mit"
"models"
; "mp"
; "mu"
"multicolumn"
"multiput"
""
)
(insert-object texCommands 10000
; "nabla"
"natural"
; "nearrow"
; "neg"
; "neq"
"newcommand"
"newcounter"
"newenvironment"
"newfont"
"newlength"
"newline"
"newpage"
"newsavebox"
"newtheorem"
; "ni"
"nocite"
"nofiles"
"noindent"
"nolinebreak"
"nofrenchspacing"
"nonumber"
"nopagebreak"
"nopagenumbers"
"normalbottom"
"normalmarginpar"
"normalsize"
; "not"
; "nu"
"numberline"
; "nwarrow"
""
)
(insert-object texCommands 10000
; "0"
; "O"
"oddsidemargin"
"odot"
; "oe"
; "OE"
; "oint"
"oldstyle"
; "omega"
; "Omega"
; "ominus"
"onecolumn"
"onlynotes"
"onlyslides"
"opening"
; "oplus"
; "oslash"
; "otimes"
"output"
; "oval"
"overbrace"
"overline"
""
)
(insert-object texCommands 10000
; "P"
"pagebody"
"pagebreak"
"pagecontents"
"pageinsert"
"pageno"
"pagenumbering"
"pageref"
"pagestyle"
"par"
"paragraph"
"parallel"
"parbox"
"parindent"
"parsep"
"parskip"
"part"
"partial"
"partopsep"
; "perp"
; "Phi"
; "Pi"
"plainoutput"
; "pm"
; "pmod"
"poptabs"
; "pounds"
; "Pr"
; "prec"
; "preceq"
; "prime"
; "prod"
; "propto"
"protect"
; "ps"
; "psi"
; "Psi"
"pushtabs"
"put"
""
)
(insert-object texCommands 10000
"raggedbottom"
"raggedleft"
"raggedright"
; "raisebox"
; "rangle"
; "rceil"
; "Re"
"ref"
"refstepcounter"
"renewcommand"
"renewenvironment"
"reversemarginpar"
; "rfloor"
; "rhd"
; "rho"
; "right"
; "rightarrow"
; "rightharpoondown"
; "rightharpoonup"
; "rightleftharpoons"
"rightmargin"
"rm"
"roman"
"Roman"
"rule"
""
)
(insert-object texCommands 10000
; "S"
"samepage"
"savebox"
"sbox"
; "sc"
"scriptfont"
"scriptscriptfont"
"scriptscriptstyle"
"scriptsize"
"scriptstyle"
; "searrow"
"sec"
"section"
"setcounter"
"setlength"
"setminus"
"settabs"
"settowidth"
; "sevenbf"
; "seveni"
; "sevensy"
; "sf"
; "sharp"
"shortstack"
; "sigma"
; "Sigma"
"signature"
; "sim"
; "simeq"
; "sin"
; "sinh"
; "sl"
"sloppy"
"small"
"smallskip"
"smallskipamount"
; "smile"
; "space"
; "spadesuit"
; "sqcap"
; "sqcup"
"sqrt"
; "sqsubset"
; "sqsubseteq"
; "sqsupset"
; "sqsupseteq"
; "ss"
"stackrel"
; "star"
"stepcounter"
"stop"
"stretch"
"subitem"
"subparagraph"
"subsection"
; "subset"
; "subseteq"
"subsubitem"
"subsubsection"
; "succ"
; "succeq"
; "sum"
; "sup"
; "supset"
; "supseteq"
"surd"
; "swarrow"
"symbol"
""
)
(insert-object texCommands 10000
; "t"
"tabalign"
"tabbingsep"
"tabcolsep"
"tableofcontents"
"tabsdone"
"tabset"
"tabs"
; "tan"
; "tanh"
; "tau"
; "teni"
"TeX"
"textfloatsep"
"textfont"
"textfraction"
"textheight"
"textstyle"
"textwidth"
"thanks"
"thepage"
; "theta"
; "Theta"
"thicklines"
"thinlines"
"thispagestyle"
; "tilde"
; "times"
"tiny"
"title"
"titlepage"
"today"
"top"
"topfraction"
"topinsert"
"topins"
"topmargin"
"topsep"
"topskip"
; "triangle"
; "triangleleft"
; "triangleright"
"trivlist"
"tt"
"twocolumn"
"typein"
"typeout"
""
)
(insert-object texCommands 10000
; "u"
; "unboldmath"
; "underbrace"
"underline"
"unitlength"
; "unlhd"
; "unrhd"
"uparrow"
"updownarrow"
; "uplus"
; "upsilon"
; "Upsilon"
"usebox"
"usecounter"
""
)
(insert-object texCommands 10000
; "v"
"value"
; "varepsilon"
; "varphi"
; "varpi"
; "varrho"
; "varsigma"
; "vartheta"
; "vbox"
; "vdash"
; "vdots"
; "vec"
; "vector"
; "vee"
"verb"
"verbatim"
"verse"
"vfill"
; "vfootnote"
; "vline"
"vspace"
""
)
(insert-object texCommands 10000
; "wedge"
; "widehat"
; "widetilde"
; "wp"
; "wr"
""
)
(insert-object texCommands 10000
; "xi"
; "Xi"
""
)
(insert-object texCommands 10000
; "zeta"
""
)
(msg "LaTeX commands loaded")
(msg "Loading LaTeX environments... ")
(insert-object texEnvironments 10000
"abstract"
"array"
"description"
"displaymath"
"document"
"enumerate"
"equation"
"eqnarray"
"figure"
"itemize"
"list"
"math"
"minipage"
"picture"
"quote"
"sloppypar"
"tabbing"
"table"
"tabular"
"thebibliography"
"theindex"
"titlepage"
"trivlist"
"verbatim"
"verse"
""
)
(msg "LaTeX environments loaded ")
}
(defun
tex-complete-command
{
(insert-text (concat "\\" (complete CC_LIST "\\" texCommands)))
}
(defun
;; Initialize LaTeX mode as a minor of docmode.
doc-mode-hook
{
(doc-set-left-flush)
(doc-minor-mode "LaTeX")
}
;; Enable LaTeX mode.
tex-mode
{
(doc-mode)
(bind-local-key "tex-expand-backslash" 'C-\')
(bind-local-key "tex-complete-command" 'M-\')
}