1 ;;; Use raw text to fetch this code, see EmacsForMoinMoin for tutorial and discussion.
   2 
   3 ;;; Download link: http://moinmo.in/EmacsForMoinMoin/MoinMoinMode?action=raw
   4 
   5 ;;; moinmoin-mode.el --- a major mode to edit MoinMoin wiki pages
   6 
   7 ;; Written by ASK, distributed under GPL
   8 
   9 ;; Filename:      moinmoin-mode.el
  10 ;; Keywords:      moinmoin, wiki
  11 ;; Description:   a major mode to edit MoinMoin wiki pages
  12 ;; Compatibility: GNU Emacs 22.0.50.1 (probably others)
  13 ;; Last modified: 2006-04-15
  14 
  15 ;; This file is NOT part of GNU Emacs.
  16 
  17 (require 'screen-lines) ; uses screen-lines.el by Yuji Minejima, tested with 0.55
  18 
  19 
  20 ;;; Definition of font faces
  21 (defgroup moinmoin nil
  22   "Major mode for MoinMoin wiki pages"
  23   :prefix "moinmoin-")
  24 
  25 (defface moinmoin-h5 '((t (:foreground "tan3" :slant italic)))
  26   "Face name to use for 5-level headings in moinmoin"
  27   :group 'moinmoin)
  28 (defface moinmoin-h4 '((t (:inherit moinmoin-h5 :slant normal :foreground "tan4")))
  29   "Face name to use for 4-level headings in moinmoin"
  30   :group 'moinmoin)
  31 (defface moinmoin-h3 '((t (:inherit moinmoin-h4 :weight bold)))
  32   "Face name to use for 3-level headings in moinmoin"
  33   :group 'moinmoin)
  34 (defface moinmoin-h2 '((t (:inherit moinmoin-h3 :height 1.2)))
  35   "Face name to use for 3-level headings in moinmoin"
  36   :group 'moinmoin)
  37 (defface moinmoin-h1 '((t (:inherit moinmoin-h2 :height 1.4)))
  38   "Face name to use for 3-level headings in moinmoin"
  39   :group 'moinmoin)
  40 
  41 (defface moinmoin-smiley '((t (:foreground "green4" :weight bold)))
  42   "Face name to use smileys in moinmoin"
  43   :group 'moinmoin)
  44 
  45 (defface moinmoin-table-separator '((t (:foreground "salmon" :weight bold)))
  46   "Face name to use for separation of columns in tables of moinmoin"
  47   :group 'moinmoin)
  48 (defface moinmoin-table-pi '((t (:foreground "plum3")))
  49   "Face name to use for processing instructions in tables of moinmoin"
  50   :group 'moinmoin)
  51 
  52 (defface moinmoin-anchor '((t (:foreground "tan3" :height 0.8)))
  53   "Face name to use for anchors (targets) in moinmoin"
  54   :group 'moinmoin)
  55 (defface moinmoin-anchor-ref-id '((t (:foreground "blue2" :height 0.8 :underline t)))
  56   "Face name to use for id in anchor reference in moinmoin"
  57   :group 'moinmoin)
  58 (defface moinmoin-anchor-ref-title '((t (:foreground "blue4" :underline t)))
  59   "Face name to use for title in anchors reference in moinmoin"
  60   :group 'moinmoin)
  61 
  62 (defface moinmoin-macro-name '((t (:foreground "plum3")))
  63   "Face name to use for names of macros in moinmoin"
  64   :group 'moinmoin)
  65 (defface moinmoin-macro-parameters '((t (:foreground "plum4")))
  66   "Face name to use for parameters of macros in moinmoin"
  67   :group 'moinmoin)
  68 
  69 (defface moinmoin-item '((t (:foreground "brown" :weight bold)))
  70   "Face name to use for items in lists in moinmoin"
  71   :group 'moinmoin)
  72 (defface moinmoin-item-2 '((t (:foreground "brown")))
  73   "Face name to use for second-level items in moinmoin"
  74   :group 'moinmoin)
  75 (defface moinmoin-blockquote-indent '((t (:background "aquamarine1")))
  76   "Face name to use for blockquote indentation in moinmoin"
  77   :group 'moinmoin)
  78 (defface moinmoin-blockquote-text '((t (:foreground "aquamarine4")))
  79   "Face name to use for blockquote text in moinmoin"
  80   :group 'moinmoin)
  81 
  82 (defface moinmoin-code '((t (:foreground "purple4")))
  83   "Face name to use for code inside braces in moinmoin"
  84   :group 'moinmoin)
  85 (defface moinmoin-code-braces '((t (:foreground "plum3")))
  86   "Face name to use for baces which delimit code inside braces in moinmoin"
  87   :group 'moinmoin)
  88 
  89 (defface moinmoin-pi '((t (:foreground "plum3" :weight bold)))
  90   "Face name to use for processing instructions in moinmoin"
  91   :group 'moinmoin)
  92 (defface moinmoin-comment '((t (:foreground "maroon3")))
  93   "Face name to use for comments in moinmoin"
  94   :group 'moinmoin)
  95 (defface moinmoin-rule '((t (:foreground "tomato2" :weight bold)))
  96   "Face name to use for rules in moinmoin"
  97   :group 'moinmoin)
  98 (defface moinmoin-ss '((t (:foreground "grey" ))) ;; try also :height 0.1
  99   "Face name to use for syntactic sugar in moinmoin"
 100   :group 'moinmoin)
 101 (defface moinmoin-tt '((t (:foreground "cyan4")))
 102   "Face name to use for typewriter text in moinmoin"
 103   :group 'moinmoin)
 104 (defface moinmoin-entity '((t (:foreground "grey")))
 105   "Face name to use for HTML entities in moinmoin"
 106   :group 'moinmoin)
 107 (defface moinmoin-email '((t (:foreground "blue2")))
 108   "Face name to use for emails in moinmoin"
 109   :group 'moinmoin)
 110 (defface moinmoin-url '((t (:foreground "blue2" :height 0.8)))
 111   "Face name to use for URLs in moinmoin"
 112   :group 'moinmoin)
 113 (defface moinmoin-url-title '((t (:foreground "blue4" :underline t)))
 114   "Face name to use for title of URL in moinmoin"
 115   :group 'moinmoin)
 116 (defface moinmoin-wiki-link '((t (:foreground "blue4" :weight bold)))
 117   "Face name to use for CamelCase links in moinmoin"
 118   :group 'moinmoin)
 119 (defface moinmoin-inter-wiki-link '((t (:foreground "blue3" :weight bold)))
 120   "Face name to use for inter wiki links in moinmoin"
 121   :group 'moinmoin)
 122 (defface moinmoin-bold '((t (:weight bold)))
 123   "Face name to use for bold text in moinmoin"
 124   :group 'moinmoin)
 125 (defface moinmoin-italic '((t (:slant italic)))
 126   "Face name to use for italic text in moinmoin"
 127   :group 'moinmoin)
 128 (defface moinmoin-underline '((t (:underline t)))
 129   "Face name to use for underlined text in moinmoin"
 130   :group 'moinmoin)
 131 (defface moinmoin-stroke '((t (:strike-through t)))
 132   "Face name to use for stroked text in moinmoin"
 133   :group 'moinmoin)
 134 (defface moinmoin-subscript '((t (:height 0.8)))
 135   "Face name to use for subscripts in moinmoin"
 136   :group 'moinmoin)
 137 (defface moinmoin-superscript '((t (:height 0.8)))
 138   "Face name to use for superscripts in moinmoin"
 139   :group 'moinmoin)
 140 
 141 
 142 ;;; Font lock setup
 143 (defconst moinmoin-url-prefix
 144   "\\(?:http\\|https\\|ftp\\|nntp\\|news\\|mailto\\|telnet\\|wiki\\|file\\|irc\\|attachment\\|inline\\|drawing\\)"
 145   "Bracketed regexp matching URL prefixes in moinmoin")
 146 (defconst moinmoin-url-punctuation
 147   "]\"'}|:,.)?!"                        ; start with ]
 148   "Punctuation in URLs of moinmoin")
 149 (defconst moinmoin-pi-re
 150   "^#\\(?:format\\|refresh\\|redirect\\|deprecated\\|pragma\\|form\\|acl\\|language\\).*$"
 151   "Regexp for processing instructions in moinmoin")
 152 (defconst moinmoin-smiley-re
 153   "\\(?:<:(\\|X-(\\|:)\\|:-))\\|:(\\|/!\\\\\\|{X}\\|{OK}\\|B-)\\|{2}\\|>:>\\|;-)\\|<!>\\|:o\\||-)\\|;)\\||)\\|(!)\\|:-(\\|:-)\\|{o}\\|:D\\|(./)\\|B)\\|{*}\\|:\\\|:-?\\|{i}\\|{3}\\|{1}\\|:)\\)"
 154   "Regexp for smileys in moinmoin")
 155 
 156 (defun moinmoin-formatted-code-matcher (bound)
 157   "Search for formatted code
 158 This is supposed to be bug-to-bug compatible with moinmoin-1.5.2"
 159   (catch 'match
 160     (while (< (point) bound)
 161       (unless (search-forward-regexp "{{{" bound t)
 162         (throw 'match nil))
 163       (let ((start-brace-begin (match-beginning 0))
 164             (start-brace-end (match-end 0))
 165             pi-begin pi-end
 166             code-begin code-end
 167             end-brace-begin end-brace-end)
 168         (unless (get-text-property start-brace-begin 'moinmoin-verbatim)
 169           (goto-char start-brace-end)
 170           (if (looking-at "#!.*\n")
 171               (setq pi-begin (match-beginning 0)
 172                     pi-end (match-end 0)
 173                     code-begin (match-end 0))
 174             (setq code-begin start-brace-end))
 175           (goto-char code-begin)
 176           (let ((not-first-line))
 177             (while (looking-at
 178                     "\\(?:##.*\\|`.*?`\\|{{{.*?

\\|.\\)*?\\(?:\\(}}}\\)\\|\n\\)")

(defun moinmoin-bracketed-url-matcher (bound)

(defun moinmoin-setup-font-lock ()

;;; Automagic typing helpers (defun moinmoin-insert-quote ()

(defun moinmoin-insert-dash ()

----' and -' stays unchanged --' is converted to –' ---' is converted to —' `)--' is not changed' <-' is converted to ←'"


" t t))

(defun moinmoin-insert-lparen ()

(defun moinmoin-insert-greater-than ()

(defun moinmoin-insert-item ()

If current line starts with item prefix insert newline and the same prefix in front of the rest of line. If it is table then finish the line and add the new one"

;;; Header manipulation helpers (defun moinmoin-is-header ()

If yes the title is in \\1"

(defun moinmoin-increase-header-level ()

(defun moinmoin-decrease-header-level ()

Warns if point in a top-level header or not in a header"

(defun moinmoin-change-header-level (increment)

(defun moinmoin-change-header-levels-in-region (increment start end)

(defun moinmoin-insert-equal (increment)

With active region increase or decrease level of all headers in region. On an empty line starts new header. On a header line increase or decrease level. Otherwise just insert `='"

;;; Anchor insertion and navigation (defun moinmoin-list-anchors ()

(defvar moinmoin-anchor-history "Minibuffer history of anchors") (defun moinmoin-completing-read-anchor (prompt &optional require-match)

(defun moinmoin-insert-number-sign (&optional no-title)

If no argument given also insert the title of the section which contains the anchor."

(defun moinmoin-insert-anchor ()

(defun moinmoin-anchor-read-or-ask (&optional prompt)

(defun moinmoin-goto-anchor (&optional anchor)

If ANCHOR is nil (e.g., if called interactively) read reference to it from the current line or ask user. So if there is an anchor on the current line but you want to jump to something different go to the beginning of the line first."

(defun moinmoin-get-anchored-header (anchor)

(defun moinmoin-insert-anchored-header (&optional to-kill-ring)

;;; Setup (define-derived-mode moinmoin-mode outline-mode "MoinMoin"

(add-to-list 'auto-mode-alist '("\\.wiki$" . moinmoin-mode))

(provide 'moinmoin-mode) }}}

MoinMoin: EmacsForMoinMoin/MoinMoinMode (last edited 2012-02-29 16:33:11 by port814)