Manuel Paccagnella about blog search Subscribe to RSS Feed

Warning! This blog's new home now is here.

Wiki Creole mode for Emacs

03 Nov 2009

I needed a syntax highlighting support for the wiki Creole syntax in Emacs, but I couldn't find it anywhere... until I found the dot.emacs configuration file of Alex Schroeder of emacswiki fame, which contains a little wonderful elisp snippet that I show you (a little bit modified) here:

;; WikiCreole mode (wiki-mode)
;; Thanks to Alex Schroeder of 
;; And Jason Blevins for his inspiring Markdown Mode
(define-generic-mode 'wiki-mode 
  nil ; comments 
  nil; keywords 
  '(("^\\(= \\)\\(.*?\\)\\($\\| =$\\)" . 'info-title-1)
    ("^\\(== \\)\\(.*?\\)\\($\\| ==$\\)" . 'info-title-2)
    ("^\\(=== \\)\\(.*?\\)\\($\\| ===$\\)" . 'info-title-3)
    ("^\\(====+ \\)\\(.*?\\)\\($\\| ====+$\\)" . 'info-title-4) 
    ("\\[\\[.*?\\]\\]" . 'link)
    ("\\[.*\\]" . 'link)
    ("\\[b\\].*?\\[/b\\]" . 'bold)
    ("\\[i\\].*?\\[/i\\]" . 'italic)
    ("\\*\\*.*?\\*\\*" . 'bold)
    ("\\*.*?\\*" . 'bold)
    ("\\_<//.*?//" . 'italic)
    ("\\_</.*?/" . 'italic)
    ("__.*?__" . 'italic)
    ("_.*?_" . 'underline)
    ("|+=?" . font-lock-string-face)
    ("\\\\\\\\[ \t]+" . font-lock-warning-face)) ; font-lock list
  '(".wiki\\'"); auto-mode-alist
  '((lambda () (require 'info) (require 'goto-addr))); function-list
  "Wiki stuff including Creole Markup and BBCode.")

Just copy this snippet in your .emacs and any file "*.wiki" will be highlighted correctly. You can also enable this mode from within emacs by: M-x wiki-mode.

I've adapted it a little bit and stealed some regexps from Jason's markdown-mode for highligthing titles. But there is still something missing:

Further versions of this mode will be updated here.

Enjoy :)

blog comments powered by Disqus