;; tinyFugue-fontlock by Azundris 06/24/00.
;; Subject to the Artistic Licence.  No warrantees of any kind given,
;; no responsibilities taken.  Anything bad happening while or because
;; of this mode is your responsibility, and your responsibility only.

;; * The latest version of this lives on http://www.azundris.com/hacks/
;;
;; * I use this mode with xemacs/mule 21.1 -- it probably does not work
;;   on GNU emacs just yet, sorry.
;;
;; * Enjoy!



(defvar tf-mode-syntax-table nil
  "Syntax table used while in tf mode.")
(if tf-mode-syntax-table
    ()
  (setq tf-mode-syntax-table (make-syntax-table (standard-syntax-table)))
  (modify-syntax-entry ?\( "()" tf-mode-syntax-table)
  (modify-syntax-entry ?\) ")(" tf-mode-syntax-table)
  (modify-syntax-entry ?/ "w" tf-mode-syntax-table)
  (modify-syntax-entry ?; "<" tf-mode-syntax-table)
  (modify-syntax-entry ?\n ">" tf-mode-syntax-table)
  (modify-syntax-entry ?\+ " " tf-mode-syntax-table))

(defvar tf-font-lock-keywords (purecopy
      (list
       ;; quoted speech
;       '("\\<\"[^\"]+\"\\>"
;	 . font-lock-string-face)

       ;; comments
       '("\\<^;.*$\\>"
	 1 font-lock-comment-face)

       ;; stuff affecting the *look*, not the structure (boldface, center etc.)
       '("\\<\\(/if\\|/then\\|/else\\|/endif\\)\\>"
	 1 font-lock-keyword-face)

       ;; preprocessor and macro stuff, incl. i18n
;      '("\\<\\(metaCOMMENT\\|metalC\\|metaLC\\|setlanguage\\|figure\\|getfigurestring\\|setfigurestring\\|getdatestring\\|setdatestring\\|gettitlestring\\|settitlestring\\|getdtocstring\\|settocstring\\|getchapterstring\\|setchapterstring\\|getpartstring\\|setpartstring\\|getaffilstring\\|setaffilstring\\|getauthorstring\\|setauthorstring\\|DUMMY\\|STARTDEF\\|ENDDEF\\|IFSTREQUAL\\|IFEMPTY\\|IFSTRSUB\\|IFZERO\\|INCLUDELITERAL\\|NOTRANS\\|NOUSERMACRO\\|PARAGRAPH\\|POPCHARTABLE\\|RENAMEMACRO\\|SUBST\\|PUSHCHARTABLE\\|UPPERCASE\\|WARNING\\|TYPEOUT\\|ERROR\\|UNDEFINEMACRO\\|UNDEFINESYMBOL\\|DEFINESYMBOL\\|IFDEF\\|NOEXPAND\\|ATEXIT\\|CHDIR\\|USECOUNTER\\|ADDCOUNTER\\|SETCOUNTER\\|NEWCOUNTER\\|COUNTERVALUE\\|DEFINECHARTABLE\\|USECHARTABLE\\ARG\\|redefinemacro\\|redef\\|DEFINEMACRO\\|CHAR\\|INCLUDEFILE\\|notableofcontents\\|notitleclearpage\\|notocclearpage\\|titleclearpage\\|tocclearpage\\|def\\|includefile\\|includeverbatim\\|verbinclude\\|clearpage\\|langle\\|rangle\\)\\>"
;	 1 font-lock-preprocessor-face)

       ;; references
;       '("\\<\\(footnote\\|lurl\\|url\\link\\|[cfkptv]index\\|mailto\\|nemail\\|email\\|ref\\|fig\\|label\\|affiliation\\)\\>"
;	 1 font-lock-reference-face)

       ;; definitions that do not affect the structure of the document (like chapter etc. do)
       '("\\<\\(TERM\\|emulation\\)\\>"
	 1 font-lock-variable-name-face)

       ;; mode-specific commands
;       '("\\<\\(setlatexfigureext\\|sethtmlfigureext\\|sethtmlfigurealign\\|htmlbodyopt\\|htmlcommand\\|htmltag\\|mancommand\\mscommand\\|roffcmd\\|sgmlcommand\\|sgmltag\\|txtcommand\\|latexcommand\\|latexdocumentformat\\|latexdocumentclass\\|latexpackage\\|latexoptions\\|latexlayoutcmds\\|nosloppyhfuzz\\|whenlatex\\|whenhtml\\|whenman\\|whenms\\|whentxt\\|whensgml\\|htmlnewfile\\|noxlatin\\|standardlayout\\|manpagename\\|manpagesynopsis\\|manpagedescription\\|manpageoptions\\|manpagefiles\\|manpageseealso\\|manpagediagnostics\\|manpagebugs\\|manpageauthor\\|setlatexverbchar\\|setrofftableoptions\\|makeindex\\|LaTeX\\|TeX\\|mbox\\|nodename\\|nodeprefix\\|texinfocommand\\)\\>"
;	 1 font-lock-doc-string-face)

       ;; misc
;       '("\\<\\(lambda\\|bind\\|ellipsis\\)\\>"
;	 1 font-lock-function-name-face t)

       ;; logical break-down
       '("\\<\\(/test\\|/set\\|/addworld\\|/log\\|/def\\|%;\\)\\>"
	 1 font-lock-type-face)

       ;; security and warnings
;       '("\\<\\(PIPETHROUGH\\|SYSTEM\\|verbpipe\\|gagmacrowarning\\|###\\)\\>"
;	 1 font-lock-warning-face t)
       ))
       "Expressions to font-lock in tf-mode.")
(put 'tf-mode 'font-lock-defaults '(tf-font-lock-keywords))


(provide 'tf)


(defun tf-mode ()
  "Major mode for editing tf setup files."
  (interactive)
  (kill-all-local-variables)
  (setq major-mode 'tf-mode)
  (setq mode-name "tf")
  (set-syntax-table tf-mode-syntax-table)
  (run-hooks 'tf-mode-hook))

;; ends
