[OS X TeX] BBAutocomplete script for TeXShop (Working Version)

Ramón M. Figueroa-Centeno ramonf at hawaii.edu
Wed Mar 4 07:37:03 CET 2009


Please disregard my last posting. I posted the wrong version. Sorry!

Here is an AppleScript to use BBAutoComplete
<http://c-command.com/bbautocomplete/> in the front most window of TeXShop.

It adds auto-completion for words already in the document and in the
system's dictionary (check BBAutoComplete's preferences). It fulfills a wish
for TeXShop posted in this list :)

It can be improved in, at least, one way: it could be written to follow
"\input" commands.

If any of you find bugs or have other suggestions please let me know.



--Applescript direct

-- Script to use BBAutoComplete in TeXShop
-- Ramon Figueroa-Centeno (March 3, 2009)
-- http://www2.hawaii.edu/~ramonf

tell application "TeXShop"
    set LaTeX_Keywords to {"abstract", "addtocounter", "addtolength",
"align", "align*", "alignat", "alignat*", "aligned", "alignedat", "alpha",
"appendix", "array", "author", "begin", "beta", "betav", "bfseries",
"bibitem", "bibliography", "bibliographystyle", "bigskip", "bmatrix",
"bottomrule", "boxed", "caption", "cases", "cdots", "center", "centering",
"chapter", "chi", "cite", "citep", "citet", "cline", "cmidrule",
"compactenum", "compactitem", "date", "ddddot", "dddot", "ddot", "ddots",
"delta", "description", "dmath", "dmath*", "documentclass", "dots", "dotsb",
"dotsc", "dotsi", "dotsm", "dotso", "em", "emph", "end", "enumerate",
"epsilon", "eqnarray", "eqnarray*", "eqref", "equation", "equation*", "eta",
"fbox", "fboxrule", "fboxsep", "figure", "flalign", "flalign*", "flushleft",
"flushright", "footnote", "footnotesize", "frac", "framebox", "gamma",
"gather", "gather*", "gathered", "geometry", "headwidth", "hline", "href",
"hskip", "hspace", "hspace*", "include", "includegraphics", "indent",
"input", "intertext", "iota", "item", "itemize", "itshape", "label",
"lambda", "large", "LaTeX", "LaTeXe", "ldots", "letter", "lettrine", "list",
"listoffigures", "listoftables", "makebox", "marginpar", "mathbf",
"mathcal", "mathit", "mathnormal", "mathrm", "mathsf", "mathtt", "mbox",
"mdseries", "medskip", "midrule", "minipage", "mu", "multicolumn",
"multiline", "multiline*", "newcolumntype", "newcommand", "newenvironment",
"newlength", "newline", "newpage", "newtheorem", "nocite", "noindent",
"normalsize", "nu", "omega", "pagebreak", "pageref", "pagestyle", "par",
"paragraph", "paragraph*", "parbox", "part", "partten", "pbox", "phi", "pi",
"picture", "pmatrix", "psi", "question", "questions", "questionten",
"quotation", "quote", "raisebox", "ref", "renewcommand", "rho", "rmfamily",
"rule", "scriptsize", "scshape", "section", "section*", "setlength",
"textwidth", "sffamily", "sigma", "slshape", "smallskip", "solution",
"split", "sqrt", "stepcounter", "subequations", "subparagraph",
"subparagraph*", "subsection", "subsection*", "subsubsection",
"subsubsection*", "tabbing", "table", "table*", "tableofcontents",
"tabular", "tabular*", "tabularx", "tau", "TeX", "text", "textasciitilde",
"textbf", "textemdash", "textendash", "textit", "textrm", "textsc",
"textsf", "textsl", "texttt", "textup", "thanks", "thebibliography",
"theindex", "theorem", "theta", "title", "titlepage", "toprule", "trivlist",
"ttfamily", "upshape", "upsilon", "url", "usepackage", "varepsilon",
"varphi", "varpi", "varrho", "varsigma", "vartheta", "varwidth", "vdots",
"verbatim", "verse", "vskip", "vspace", "vspace*", "wrapfigure", "xi",
    set the front_document to the front document
    -- The whole text of the document
    set whole_document to the text of the front_document
    -- The offset of the selection
    set selection_offset to (offset of the selection of the front_document)
+ 1
    -- make Completion
    tell application "BBAutoComplete"
        set theCompletion to complete word starting at offset
selection_offset in text whole_document also using text LaTeX_Keywords
    end tell
    set {startOffset, endOffset, completionText} to theCompletion
    -- display dialog (startOffset as string) & ":" & (endOffset as string)
& return & completionText
    set the offset of the selection of the front_document to startOffset
    set the length of the selection of the front_document to endOffset -
    set the content of the selection of the front_document to completionText
end tell


Ramón M. Figueroa-Centeno, Ph.D.
Associate Professor

Mathematics Department
University of Hawaii at Hilo
College Hall 4-A
200 W. Kawili St.
Hilo, HI 96720-4091

(808) 974-7387 (office)
(808) 933-3473 (fax)


PGP/GnuPG Public Key at http://www2.hawaii.edu/~ramonf/ramonf.gpgkey

More information about the macostex-archives mailing list