;;; n3mode.el --- RDF/N3 Syntax highlighting for xemacs ;; by Gunnar Aastrand Grimnes, email: gromgull at the domain of gmail.com ;; this is really crappy and does comment-syntax + highlighting only ;; "english" identifiers only mind you, i.e. a-z ... ;; in theory n3 is utf8 so you can have any identifiers you like, but ;; I doubt this works very often. ;; Improvements are of course welcome at above address! ;; Install: ;; As usual: ;; copy n3mode.el to ~/.xemacs ;; add the lines: ;; (load "~/.xemacs/n3mode.el") ;; (setq auto-mode-alist (cons '("\\.n3$" . n3-mode) auto-mode-alist)) ;; (add-hook 'n3-mode-hook 'turn-on-font-lock) ;; ;; to ~/.xemacs/init.el to enable when openeing n3 files ;; (defvar n3-mode-hook nil "Normal hook run when entering N3 mode.") (defvar n3-font-lock-keywords (list ;; comments '( "#[^>].*$" . font-lock-comment-face) ;; URIs '( "<[:/a-zA-Z_~0-9\\.\\#-]+>" . font-lock-preprocessor-face) ;; keywords '( "@prefix\\| a " . font-lock-keyword-face) ;; prefix: '( "[a-zA-Z][a-zA-Z0-9]*:" . font-lock-type-face) ;; variables '( "\\?[a-zA-Z][a-zA-Z0-9]*" . font-lock-reference-face) ;; numbers '( "[0-9]+\\(\\.[0-9]+\\)?" . font-lock-function-name-face) ;; symbols '( "{\\|}\\|\(\\|\)" . font-lock-function-name-face) ) "Additional expressions to highlight in Python mode." ) (put 'n3-mode 'font-lock-defaults '(n3-font-lock-keywords)) (defun n3-mode () "Major mode for editing RDF/N3 Files." (interactive) (kill-all-local-variables) (make-local-variable 'font-lock-defaults) (setq major-mode 'n3-mode mode-name "N3" font-lock-defaults '(n3-font-lock-keywords)) ;; Comment stuff. (make-local-variable 'comment-start) (setq comment-start "#") (make-local-variable 'comment-end) (setq comment-end "") (make-local-variable 'comment-start-skip) (setq comment-start-skip "#+[ \t]*") (run-hooks 'n3-mode-hook) ) (provide 'n3-mode)