;; Hattrick Markup Language major mode for Emacs ;; ;; Copyright © 2009, 2010 Jani Hurskainen (see http://www.jani-hur.net) ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;; ;; The GNU General Public License is available from: ;; http://www.jani-hur.net/sw/hattrick-ml-mode/COPYING ;; ;; The mode just highlights syntax. It is partially inspired by "mega-simple ;; bbcode mode (font-lock only)" by Azundris available in ;; http://www.azundris.com/hacks/lisp/bbcode.el ;; Other starting points: ;; http://lmgtfy.com/?q=howto+write+emacs+major+mode ;; http://www.emacswiki.org/emacs/GenericMode ;; Tested only on GNU Emacs version 22.2.1 ;; The major mode issue should be studied later further, but at the moment ;; syntax highlighting is enough. See: ;; http://xahlee.org/emacs/elisp_syntax_coloring.html ;; http://www.emacswiki.org/emacs/BbCode ;; Known issues: ;; missing td/th attributes (see http://wiki.hattrick.org/Hattrick_Markup_Language) ;; Useful variables, functions: ;; font-lock-builtin-face ;; font-lock-function-name-face ;; font-lock-keyword-face ;; font-lock-variable-name-face ;; font-lock-keywords ;; M-x list-faces-display ;; M-x delete-trailing-whitespace ;; M-x regexp-builder ;; buffer local: (setq show-trailing-whitespace t) ;; define-skeleton (define-generic-mode 'hattrick-ml-mode '() ; no comments '() ; no keywords '( ; this is nice but also too generic as it highlights everything inside [] ;("\\[\\/?\\([^]]+\\)\\]" . font-lock-keyword-face) ; start and end tags (like [b], [/b]) ("\\[\\/?\\(b\\|i\\|u\\|q\\|quote\\|table\\|tr\\|th\\|td\\|spoiler\\)\\]" . font-lock-keyword-face) ; start tags with arguments ([tag=argument]) ("\\[\\(q\\|quote\\|userid\\|playerid\\|youthplayerid\\|teamid\\|youthteamid\\|matchid\\|youthmatchid\\|leagueid\\|youthleagueid\\|federationid\\|link\\|articleid\\|table border\\|post\\)=.+?\\]" 1 font-lock-keyword-face t) ; start tags without end tag (like [br]) ("\\[\\(br\\|hr\\)\\]" . font-lock-keyword-face) ; content of the tags ("\\[b\\]\\(.*?\\)\\[\\/b\\]" 1 'bold) ("\\[i\\]\\(.*?\\)\\[\\/i\\]" 1 'italic) ("\\[u\\]\\(.*?\\)\\[\\/u\\]" 1 'underline) ("\\[\\(quote\\|q\\)\\(=[^]]+\\)?\\]\\(.*?\\)\\[\\/\\(quote\\|q\\)\\]" 3 font-lock-doc-face t) ("\\[th\\]\\(.*?\\)\\[\\/th\\]" 1 'bold) ("\\[spoiler\\]\\(.*?\\)\\[\\/spoiler\\]" 1 'shadow) ; argument part of the tag (like [q=jani-hur]) ("\\[[^\\/]+?\\(=[^]]+\\)" 1 font-lock-variable-name-face t) ; next two should be replaced with (setq show-trailing-whitespace t) as it ; is a bit annoying when one writes new text ("[\t ]+$" 0 'trailing-whitespace t) ("[\t]+" 0 'trailing-whitespace t) ; whitespace in the beginning of the line ("^[\t ]+" 0 'trailing-whitespace t) ) '("\\.ht\\'" "\\.ht-ml\\'") ; file extensions to apply the mode nil "Major mode for Hattrick forum and private messages. The mode provides only syntax highlighting. Hattrick uses BBCode based Hattrick Markup Language (or HT-ML) that is described in http://wiki.hattrick.org/Hattrick_Markup_Language.")