From c523a5134c8369cec568e69f3ed3f1dd19ed07aa Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 3 Nov 2008 13:36:18 -0500 Subject: sisu-mode.el, emacs syntax highlighting contributed by Ambrose Kofi Laing based on work by Tong Sun (doc-mode.el) and included with his kind permission --- data/sisu/conf/editor-syntax-etc/emacs/README | 5 + .../sisu/conf/editor-syntax-etc/emacs/sisu-mode.el | 388 +++++++++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 data/sisu/conf/editor-syntax-etc/emacs/README create mode 100644 data/sisu/conf/editor-syntax-etc/emacs/sisu-mode.el diff --git a/data/sisu/conf/editor-syntax-etc/emacs/README b/data/sisu/conf/editor-syntax-etc/emacs/README new file mode 100644 index 00000000..24816c1e --- /dev/null +++ b/data/sisu/conf/editor-syntax-etc/emacs/README @@ -0,0 +1,5 @@ +put this into your .emacs file, then use the mode file: + +(load-file "~/emacs/el/sisu-mode.el") +(add-to-list 'auto-mode-alist '("\\.sst$" . sisu-mode)) + diff --git a/data/sisu/conf/editor-syntax-etc/emacs/sisu-mode.el b/data/sisu/conf/editor-syntax-etc/emacs/sisu-mode.el new file mode 100644 index 00000000..1d05a573 --- /dev/null +++ b/data/sisu/conf/editor-syntax-etc/emacs/sisu-mode.el @@ -0,0 +1,388 @@ +;;; sisu-mode.el --- a major-mode for highlighting a hierarchy structured text. +;; @Author: Ambrose Kofi Laing (& Ralph Amissah) +;; @Keywords: text, processes, tools +;; @Version: 0.96.4 2008-11-02 +;; @License: GPLv3 +;; @Home URL: SiSU: http://www.jus.uio.no/sisu +;; originally looked at (based on) doc-mode, with kind permission of the author +;; Author: SUN, Tong , (c)2001-6, all right reserved +;; Version: $Date: 2006/01/19 03:13:41 $ $Revision: 1.14 $ +;; Home URL: http://xpt.sourceforge.net/ +;; +;; Distribute freely, but please include the author's info & copyright, +;; the file's version & url with the distribution. +;; +; Viva Software Libre! +;; Support the free software movement! +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;{{{ Commentary: + +;; +;; To enter sisu-mode automatically, add (autoload 'sisu-mode "sisu-mode") +;; to your .emacs file and change the first line of your sisu file to: +;; # -*- Sisu -*- +;; if it doesn't have a .sisu extension. +;; +;; To handle .sisu files, e.g., 'filename.sisu', add something like +;; (add-to-list 'auto-mode-alist '("\\.sisu$" . sisu-mode)) +;; to your .emacs file + +;; +;; The documentation for the "Structure Of The Hierarchy Text" can be found in +;; the sisustring for the sisu-mode function. +;; + +;;}}} + +;;{{{ Variables: + +(defgroup sisu-faces nil + "AsciiSisu highlighting" + :group 'sisus) + +;; == Colors +; color n is more prominent than color n+1 + +(defface sisu-title-1-face + `((((class color) + (background dark)) + (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) + (((class color) + (background light)) + (:foreground "brown3" :bold t :height 1.2 :inherit variable-pitch)) + (t (:weight bold :inherit variable-pitch))) + "Face for AsciiSisu titles at level 1." + :group 'sisu-faces) + +(defface sisu-title-2-face + `((((class color) + (background dark)) + (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) + (((class color) + (background light)) + (:foreground "yellow4" :bold t :height 1.1 :inherit variable-pitch)) + (t (:weight bold :inherit variable-pitch))) + "Face for AsciiSisu titles at level 2." + :group 'sisu-faces) + +(defface sisu-title-3-face + `((((class color) + (background dark)) + (:foreground "sienna3" :bold t)) + (((class color) + (background light)) + (:foreground "sienna3" :bold t)) + (t (:weight bold))) + "Face for AsciiSisu titles at level 3." + :group 'sisu-faces) + +(defface sisu-title-4-face + `((((class color) + (background dark)) + (:foreground "burlywood3")) + (((class color) + (background light)) + (:foreground "burlywood3")) + (t ())) + "Face for AsciiSisu titles at level 4." + :group 'sisu-faces) + +(defface info-node + '((((class color) (background light)) (:foreground "brown" :bold t :italic t)) + (((class color) (background dark)) (:foreground "white" :bold t :italic t)) + (t (:bold t :italic t))) + "Face for Info node names." + :group 'sisu-faces) + +(defvar sisu-title-1 'sisu-title-1-face) +(defvar sisu-title-2 'sisu-title-2-face) +(defvar sisu-title-3 'sisu-title-3-face) +(defvar sisu-title-4 'sisu-title-4-face) + +(defvar general-font-lock-red1 font-lock-warning-face) +(defvar general-font-lock-red2 font-lock-comment-face) +(defvar general-font-lock-red3 font-lock-string-face) + +(defvar general-font-lock-green1 font-lock-type-face) +(defvar general-font-lock-green2 font-lock-constant-face) + +(defvar general-font-lock-blue1 font-lock-keyword-face) +(defvar general-font-lock-blue2 font-lock-function-name-face) +(defvar general-font-lock-blue3 font-lock-builtin-face) + +(defvar general-font-lock-yellow1 font-lock-variable-name-face) +(defvar general-font-lock-yellow2 font-lock-comment-face) + +;; == sisu-mode settings + +(defvar sisu-mode-hook nil + "Normal hook run when entering Sisu Text mode.") + +(defvar sisu-mode-abbrev-table nil + "Abbrev table in use in Sisu-mode buffers.") +(define-abbrev-table 'sisu-mode-abbrev-table ()) + +(defconst sisu-font-lock-keywords + (eval-when-compile + (list + + ;;grouped text + (cons "^group\{\\|^\}group" 'general-font-lock-red2) + (cons "^code\{\\|^\}code" 'general-font-lock-red2) + (cons "^poem\{\\|^\}poem" 'general-font-lock-red2) + (cons "^alt\{\\|^\}alt" 'general-font-lock-red2) + (cons "^table\{.+\\|^\}table" 'general-font-lock-red2) + (cons "^\{table[^}]+\}" 'general-font-lock-red2) + + ;; footnote/endnote + ;(cons "\~\{.+?\}\~" 'general-font-lock-green1) + (cons "\~\{\\*\\*\\|\~\{\\*\\|\~\{\\|\}\~" 'general-font-lock-red2) + (cons "\~\\[\\+\\|\~\\[\\*\\|\~\\[\\|\\]\~" 'general-font-lock-red2) + + (cons "\~\\^ \\|^\\^\~ " 'general-font-lock-red2) + + (list (concat + "\\(\*\~\\)" + "\\([^ \r\t\n]+\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-blue2 t)) + + ;; bold + (list (concat + "\\([*]\{\\)" + "\\([^\}]+\\)" + "\\(\}[*]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + (list (concat + "\\([!]\{\\)" + "\\([^\}]+\\)" + "\\(\}[!]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + (cons "\\*[^ ]+\\*" 'general-font-lock-red1) + (cons "^!_ .+" 'general-font-lock-red1) + + + ;;; italics + (list (concat + "\\([/]\{\\)" + "\\([^\}]+\\)" + "\\(\}[/]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-blue1 t) + '(3 general-font-lock-red1 t)) + + + ;; underscore + (list (concat + "\\([_]\{\\)" + "\\([^\}]+\\)" + "\\(\}[_]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;; citation + (list (concat + "\\([\"]\{\\)" + "\\([^\}]+\\)" + "\\(\}[\"]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;; inserted text + (list (concat + "\\([\+]\{\\)" + "\\([^\}]+\\)" + "\\(\}[\+]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;; strike through + (list (concat + "\\(\\-\{\\)" + "\\([^\}]+\\)" + "\\(\}\\-\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;; superscript + (list (concat + "\\(\\^\{\\)" + "\\([^\}]+\\)" + "\\(\}\\^\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;; subscript + (list (concat + "\\([,]\{\\)" + "\\([^\}]+\\)" + "\\(\}[,]\\)") + '(1 general-font-lock-red1 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-red1 t)) + + ;;numbered list + (cons "^# \\|^_# " 'general-font-lock-red1) + + ;;bullet text + (cons "^_\\*[1-9] \\|^_\\* " 'general-font-lock-red1) + + ;;indented text + (cons "^_[1-9] " 'general-font-lock-red1) + + ;;url + (cons "\\(^\\|[ ]\\)http:[/][/][^ \t\n\r<]+" 'general-font-lock-blue2) + +;; \\|\$ + + ;; Comment Lines + (cons "^% .*" 'general-font-lock-blue1) + ;; line break + (cons "
" 'general-font-lock-red1) + + ;; Section titles + (list "^\\(\\([1-8]\\|:?[A-C]\\)\\~\\)\\(.*\\)" + '(1 sisu-title-1 t) + '(3 sisu-title-2 t)) + + ;; hyper-links + (list (concat + "\\(\{~^\\|\{\\)" + "\\([^\}\{]+\\)" + "\\(\}http:[/][/][^ \r\n\t<]+\\)") + '(1 general-font-lock-blue2 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-blue2 t)) + + ;; book index + (cons "^\=\{.+\}" 'general-font-lock-green1) + + ;; numbers + (cons "\\<[.0-9]+\\>" 'general-font-lock-green2) + + ;; bullets sisu_normal (nearly copied regexp) + (cons "^_\\([1-9*]\\|[1-9]\\*\\) " 'general-font-lock-blue2) + + ;; image links + (list (concat + "\\(\{\\)" + "\\([^\}\{]+\\)" + "\\(\}image\\)") + '(1 general-font-lock-blue2 t) + '(2 general-font-lock-red1 t) + '(3 general-font-lock-blue2 t)) + + ;; insert file links + (list (concat + "\\(<< \\)" + "\\([^ \r\t\n]+\\.ss\\)" + "\\(i\\|t\\)") + '(1 general-font-lock-blue2 t) + '(2 general-font-lock-blue2 t) + '(3 general-font-lock-blue2 t)) + + ;; raw keywords + (list (concat + "^\\(\\@\\(" + "title\\|" + "subtitle\\|" + "creator\\|author\\|" + "translator\\|translated_by\\|" + "illustrator\\|illustrated_by\\|" + "prepared_by\\|" + "digitized_by\\|" + "contributor\\|" + "publisher\\|" + "subject\\|" + "description\\|" + "type\\|" + "format\\|" + "source\\|" + "language\.original\\|" + "language\.document\\|" + "language\\|" + "rights\\|" + "relation\\|" + "coverage\\|" + "keywords\\|" + "comments\\|" + "papersize\\|" + "tags\\|" + "catalogue\\|" + "classify_loc\\|" + "classify_dewey\\|" + "classify_isbn\\|" + "date.created\\|" + "date.issued\\|" + "date.available\\|" + "date.modified\\|" + "date\\|" + "prefix\\|" + "suffix\\|" + "contact\\|" + "links\\|" + "structure\\|" + "toc\\|" + "level\\|" + "page\\|" + "markup\\|" + "css\\|stylesheet\\|" + "skin\\|" + "abstract\\|" + "bold\\|" + "italics\\|" + "doc_cont_idx\\|" + "doc_content_index\\|" + "\\):\\)\\(.*\\)") + '(1 sisu-title-2 keep) + '(3 sisu-title-3 keep)) + + )) + "Default expressions to highlight in AsciiSisu mode.") + +;;}}} + +;;{{{ Sisu & Autoload: + +;;###autoload +(define-derived-mode sisu-mode text-mode "SiSU" + "Major mode for editing SiSU files." + (interactive) + (modify-syntax-entry ?\' ".") + ;(flyspell-mode nil) + + (make-local-variable 'paragraph-start) + (setq paragraph-start (concat "$\\|>" page-delimiter)) + (make-local-variable 'paragraph-separate) + (setq paragraph-separate paragraph-start) + (make-local-variable 'paragraph-ignore-fill-prefix) + (setq paragraph-ignore-fill-prefix t) + + (make-local-variable 'require-final-newline) + (setq require-final-newline t) + + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(sisu-font-lock-keywords + nil ; KEYWORDS-ONLY: no + nil ; CASE-FOLD: no + ((?_ . "w")) ; SYNTAX-ALIST + )) + (run-hooks 'sisu-mode-hook)) + +(provide 'sisu-mode) + +;;}}} + +;;; sisu-mode.el ends here -- cgit v1.2.3