% imflatex.sl -*- SLang -*- % % % Support for IMFUFA LaTeX % - an add-on to JL's LaTeX mode. % % By Jørgen Larsen % % Last modified: 2003/1/14 % % % Features: % % - redefines `"' so that it inserts either `\\textqm{' or `}' % % - "knows" the IMFUFA LaTeX document classes % % - templates for the "notat" and "???brev" classes % % How to use it: % add the line `require ("imflatex");' to your `latex_mode_hook ()' function. % static variable LaTeX_User = Assoc_Type [Any_Type, NULL]; public define imflatex_set (name, expr) { LaTeX_User [name] = expr; } static define imflatex_get (name) { variable c = LaTeX_User [name]; if (c == NULL) verror (" %s has not been defined", name); return c; } imflatex_set ("location", get_hostname ()); imflatex_set ("homepage", strcat (get_hostname (), "/~", get_username (), "/")); imflatex_set ("email", get_emailaddress ()); imflatex_set ("phone", ""); imflatex_set ("name", get_realname ()); imflatex_set ("signature", get_realname ()); latex_set_option ("DFLT_CLS_NAME", "notat"); % add the IMFUFA LaTeX document classes: LaTeX_classes += ",notat,artikel,bog,rapport,prvbrev,imfbrev,intbrev,rucbrev"; define insert_notat_cls (opt, cls) { jllatex->ltx_embr_env (sprintf (strcat ("\\documentclass%s{notat}\n\\title{}\n\\author{%s}\n", "\\location{%s}\n\n\\begin{document}\n\\maketitle\n\n"), opt, imflatex_get ("name"), imflatex_get ("location")), sprintf ("\\end{document}\n")); bob (); () = fsearch ("\\title{"); go_right (7); } define insert_instbrev_cls (opt, cls) { vinsert ("\\documentclass%s{%s}\n\n", opt, cls); insert (strcat ("\\name{", imflatex_get ("name"), "}\n", "\\signature{", imflatex_get ("signature"), "}\n", "\\telephone{", imflatex_get ("phone"), "}\n", "%\\fax{}\n", "\\email{", imflatex_get ("email"), "}\n", "\\homepage{", imflatex_get ("homepage"), "}\n", "%\\date{\\today}\n", "%\\journal{}\n", "%\\yourreference{}\n", "\n\\begin{document}\n\\begin{letter}{")); push_spot (); insert ("}\n\\opening{Hello}\n\n\n\\closing{Bye}\n\\end{letter}\n\\end{document}\n"); pop_spot (); } define insert_prvbrev_cls (opt, cls) { vinsert ("\\documentclass%s{%s}\n\n", opt, cls); insert (strcat ("\\name{", imflatex_get ("name"), "}\n", "\\address{", imflatex_get ("location"), "}\n", "\\signature{", imflatex_get ("signature"), "}\n", "\\telephone{", imflatex_get ("phone"), "}\n", "%\\fax{}\n", "\\email{", imflatex_get ("email"), "}\n", "\\homepage{", imflatex_get ("homepage"), "}\n", "\n\\begin{document}\n\\begin{letter}{")); push_spot (); insert ("}\n\\opening{Hello}\n\n\n\\closing{Bye}\n\\end{letter}\n\\end{document}\n"); pop_spot (); } % The user can add document class templates in the way shown here. % The insert_ functions must take two string type arguments: % classoptions and classname. latex_add_cls_templ ("notat", &insert_notat_cls); latex_add_cls_templ ("imfbrev", &insert_instbrev_cls); latex_add_cls_templ ("intbrev", &insert_instbrev_cls); latex_add_cls_templ ("rucbrev", &insert_instbrev_cls); latex_add_cls_templ ("prvbrev", &insert_prvbrev_cls); definekey ("latex_embrace_region_or_word (\"\\\\textqm{\", \"}\")", "\"", "LaTeX-Mode-keymap"); provide ("imflatex");