; To use this file, put in your ~/.emacs: ;(load "/path/to/gametex-mode.el") ; ;If you want to use it by default for all .tex files, put this after it: ;(setq auto-mode-alist (cons '("\\.tex$" . gametex-mode) auto-mode-alist)) ; ;Unfortunately, GameTeX files don't have a great magic number, so no ;smart autodetect for you yet. ;(You could check to see if the latex class name is the same as an environment ; variable that points to a tree with a LaTeX/gametex.sty in it...) (load "tex-mode") (defface gametex-error-face '((t :inherit font-lock-warning-face :weight bold)) "Face used to highlight GameTeX errors.") (defvar gametex-error-face 'gametex-error-face) (defface gametex-questionable-whitespace-face '((t :background "blue")) "Face used to highlight questionable whitespace after macros.") (defvar gametex-questionable-whitespace-face 'gametex-questionable-whitespace-face) (defconst gametex-font-lock-keywords (append (eval-when-compile (let* ((pronouns '("he" "she" "his" "her" "him" "He" "She" "His" "Her" "Him" "hers" "himself" "herself" "husband" "wife" "Hers" "Himself" "Herself" "Husband" "Wife" "son" "daughter" "boy" "girl" "brother" "sister" "Son" "Daughter" "Boy" "Girl" "Brother" "Sister" "father" "mother" "uncle" "aunt" "nephew" "niece" "Father" "Mother" "Uncle" "Aunt" "Nephew" "Niece" "man" "woman" "male" "female" "Man" "Woman" "Male" "Female")) (badpunct '(" --- " " -- " "-- " " --" "\"" "...")) (names '("real" "maiden" "code" "nick" "ancient")) (nameparts '("full" "formal" "informal" "first" "middle" "last" "fullplain" "both" "they" "They" "them" "Them" "their" "Their" "theirs" "Theirs" "themself" "Themself" "spouse" "Spouse" "offspring" "Offspring" "kid" "Kid" "sibling" "Sibling" "parent" "Parent" "uncle" "Uncle" "nephew" "Nephew" "aunt" "Aunt" "niece" "Niece" "human" "Human" "sex" "Sex")) (keys '("NEW" "ADD" "MAP" "SURFACEMAP" "REMAP" "DECLARETYPE" "DECLARESUBTYPE" "PRESETS" "POSTSETS" "newinstance" "append" "s" "sd" "F" "FS" "FD" "rs" "newstat" "ambiguous" "male" "female" "neuter" "multi" "note" "unlisted" "pre" "suf" "moneychange" "prop" "unstash" "bulky" "contain" )) (types '("Element" "Owner" "SubOwner" "Char" "GM" "PC" "NPC" "Name" "OnFilfla" "BoxLabel" "Blue" "Group" "Green" "PublicGreen" "White" "Red" "Abil" "Mem" "MemFold" "MemEnvelope" "Item" "ItemPacket" "ItemFold" "ItemEnvelope" "ItemLabel" "Notebook" "IdeaNotebook" "Front" "Region" "Continent" "Code")) (inlines '("memfold" "mempacket" "icard" "specialicard" "itempacket" "itemfold" "itemenvelope" "itemlabel" "ability")) (spacesafe '("item" "vfill" "hline" "bf" "it" "em" "twocolumn" "onecolumn" "tableofcontents" "clearpage" "cleardoublepage" "STATE" "ENDFOR" "ENDIF" "cheatsheet" "endcs" "psi" "endpsi")) (todos '("TODO" "typeout")) ) (list (list "[^\\\\]\\\\NEW{[a-zA-Z]+}{\\(\\\\[a-z]+[A-Z][a-zA-Z]*\\)}" 1 font-lock-variable-name-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt todos t) "\\({[^}{]*\\({[^}{]*}[^}{]*\\)*}\\)?\\)[^a-zA-Z]") 1 gametex-error-face) (list (concat "[^\\\\a-zA-Z]" (regexp-opt pronouns t) "[^a-zA-Z]") 1 gametex-error-face) (list (concat "[^\\\\]" (regexp-opt badpunct t)) 1 font-lock-warning-face) ; error makes punct hard to read (list "[^\\\\]\\(\\\\[a-z]+[A-Z][a-zA-Z]*\\)[^{a-zA-Z]" 1 gametex-error-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt names t) "\\)[^{a-zA-Z]") 1 gametex-error-face) (list "[^\\\\]\\(\\\\[a-z]+[A-Z][a-zA-Z]*\\){" 1 font-lock-variable-name-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt names t) "\\){") 1 font-lock-function-name-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt names t) "name" "\\)[^a-zA-Z]") 1 font-lock-builtin-face) (list "[^\\\\]\\(\\\\MY[a-z]+\\)" 1 font-lock-constant-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt nameparts t) "\\)[^a-zA-Z]") 1 font-lock-constant-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt keys t) "\\)[^a-zA-Z]") 1 font-lock-builtin-face) (list (concat "{" (regexp-opt types t) "}") 1 font-lock-type-face) (list (concat "[^\\\\]\\(\\\\" (regexp-opt inlines t) "\\)[^a-zA-Z]") 1 font-lock-variable-name-face) (list (concat "[^\\\\]\\\\" (regexp-opt spacesafe t) "\\([ \t]*[\n]?\\)") 2 '(quote default)) (list "[^\\\\]\\\\[a-zA-Z]+\\([ \t]*[\n]?\\)" 1 gametex-questionable-whitespace-face) )) ) tex-font-lock-keywords-2 )) (defvar gametex-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map latex-mode-map) (define-key map "\C-c\C-a" 'tex-view-pdf) map) "Keymap for `gametex-mode'. See also `tex-mode-map'.") (define-derived-mode gametex-mode latex-mode "GameTeX" "Major mode for editing GameTeX files." ; From tex-mode.el (set (make-local-variable 'font-lock-defaults) '(gametex-font-lock-keywords nil nil ((?$ . "\"")) nil ;; Who ever uses that anyway ??? (font-lock-mark-block-function . mark-paragraph) (font-lock-syntactic-face-function . tex-font-lock-syntactic-face-function) ) ) ) ;;;###autoload (defcustom tex-pdf-view-command "acroread" "*Command used by \\[tex-view] to display a `.pdf' file. If this string contains an asterisk (`*'), that is replaced by the file name; otherwise, the file name, preceded by blank, is added at the end." :type '(choice (string :tag "Command") (sep :tag "Expression")) :group 'tex-view) (defun tex-view-pdf () "View the .pdf file made by \\[tex-region], \\[tex-buffer] or \\[tex-file]. Runs the shell command defined by `tex-pdf-view-command'." (interactive) (let ((view-file-name-pdf (tex-append tex-print-file ".pdf")) test-name) (if (and (not (equal (current-buffer) tex-last-buffer-texed)) (buffer-file-name) ;; Check that this buffer's viewed file is up to date. (file-newer-than-file-p (setq test-name (tex-append (buffer-file-name) ".pdf")) (buffer-file-name))) (setq view-file-name-pdf test-name)) (if (not (file-exists-p view-file-name-pdf)) (error "No appropriate `.pdf' file could be found") (if (tex-shell-running) (tex-kill-job) (tex-start-shell)) (tex-send-command tex-pdf-view-command view-file-name-pdf t))))