(defgroup asciidoc-faces nil
"AsciiDoc highlighting"
:group 'asciidoc)
(defface asciidoc-document-title-face `((((class color) (background dark))
(:foreground "DarkGoldenrod3" :bold t :underline t :height 1.5 :inherit variable-pitch))
(((class color) (background light))
(:foreground "RoyalBlue3" :bold t :underline t :height 1.5 :inherit variable-pitch))
(t (:weight bold :inherit variable-pitch)))
"Face for AsciiDoc document titles (level 0)."
:group 'asciidoc-faces)
(defface asciidoc-chapter-face `((((class color) (background dark))
(:foreground "DarkGoldenrod3" :bold t :italic t :underline t :height 1.3 :inherit variable-pitch))
(((class color) (background light))
(:foreground "RoyalBlue3" :bold t :italic t :underline t :height 1.3 :inherit variable-pitch))
(t (:weight bold :inherit variable-pitch)))
"Face for AsciiDoc section titles (level 1)."
:group 'asciidoc-faces)
(defface asciidoc-section-face `((((class color) (background dark))
(:foreground "DarkGoldenrod1" :bold t :italic t :underline t :height 1.0 :inherit variable-pitch))
(((class color) (background light))
(:foreground "RoyalBlue2" :bold t :italic t :underline t :height 1.0 :inherit variable-pitch))
(t (:weight bold :inherit variable-pitch)))
"Face for AsciiDoc section titles (level 2)."
:group 'asciidoc-faces)
(defface asciidoc-subsection-face `((((class color) (background dark))
(:foreground "Gold" :bold t :italic t :underline t :height 1.0 :inherit variable-pitch))
(((class color) (background light))
(:foreground "RoyalBlue2" :bold t :italic t :underline t :height 1.0 :inherit variable-pitch))
(t (:weight bold)))
"Face for AsciiDoc section titles (level 3)."
:group 'asciidoc-faces)
(defface asciidoc-subsubsection-face `((((class color) (background dark))
(:foreground "Yellow1" :italic t :underline t :height 1.0 :inherit variable-pitch))
(((class color) (background light))
(:foreground "RoyalBlue1" :italic t :underline t :height 1.0 :inherit variable-pitch))
(t (:weight bold)))
"Face for AsciiDoc section titles (level 4)."
:group 'asciidoc-faces)
(defface asciidoc-paragraph-face
`((((class color) (background dark))
(:foreground "Cornsilk" :italic t))
(((class color) (background light))
(:foreground "RoyalBlue1" :italic t))
(t (:inherit variable-pitch)))
"Face for AsciiDoc paragraph titles and admonition blocks."
:group 'asciidoc-faces)
(defface asciidoc-comment-face
`((((class color) (background dark))
(:bold t :family "Courier" :foreground "LimeGreen" :height .8))
(((class color) (background light))
(:bold t :family "Courier" :foreground "Forestgreen" :height .8)))
"Face for AsciiDoc markup (monospaced text)."
:group 'asciidoc-faces)
(defface asciidoc-upper-face
`((((class color) (background dark))
(:foreground "Cornsilk"))
(((class color) (background light))
(:foreground "DarkGoldenrod1"))
(t (:weight bold :inherit variable-pitch)))
"Face for AsciiDoc paragraphs."
:group 'asciidoc-faces)
(defface asciidoc-mono-face
`((((class color) (background dark))
(:bold t :family "Courier" :height .8))
(((class color) (background light))
(:foreground "DarkMagenta" :bold t :family "Courier" :height .8)))
"Face for AsciiDoc markup (monospaced text)."
:group 'asciidoc-faces)
(defface asciidoc-list-item-face
`((((class color) (background dark))
(:foreground "OrangeRed" :bold t :family "Courier"))
(((class color) (background light))
(:foreground "DeepskyBlue" :bold t :family "Courier")))
"Face for AsciiDoc list items."
:group 'asciidoc-faces)
(defface asciidoc-emph-face
`((((class color) (background dark))
(:foreground "Cornsilk" :slant italic))
(((class color) (background light))
(:foreground "Gray15" :slant italic)))
"Face for AsciiDoc markup (emphasized text)."
:group 'asciidoc-faces)
(defface asciidoc-bold-face
`((((class color) (background dark))
(:foreground "Cornsilk" :bold t :inherit variable-pitch))
(((class color) (background light))
(:foreground "Gray15" :bold t)))
"Face for AsciiDoc markup (bold text)."
:group 'asciidoc-faces)
(defface asciidoc-idiosyncratic-face
`((((class color) (background dark))
(:foreground "IndianRed1" :family "Courier" :height .8))
(((class color) (background light))
(:foreground "MidnightBlue" :family "Courier" :height .8))
(t ()))
"Face for AsciiDoc keywords and gibberish, e.g. <<ref>> and url:names[]."
:group 'asciidoc-faces)
(defface asciidoc-url-face
`((((class color) (background dark))
(:foreground "LightGray" :slant italic))
(((class color) (background light))
(:foreground "MidnightBlue"))
(t ()))
"Face for AsciiDoc URLs."
:group 'asciidoc-faces)
(defface asciidoc-asciimath-face
`((((class color) (background dark))
(:foreground "IndianRed1" :family "Courier"))
(((class color) (background light))
(:foreground "MidnightBlue" :family "Courier"))
(t ()))
"Face for tunneled Asciimath code."
:group 'asciidoc-faces)
(defface asciidoc-escape-face
`((((class color) (background dark))
(:foreground "IndianRed1" :background "Gray10"))
(((class color) (background light))
(:foreground "Yellow" :background "Gray20"))
(t (:weight bold)))
"Face for unquoted AsciiDoc text."
:group 'asciidoc-faces)
(defvar asciidoc-mode-hook nil
"Normal hook run when entering Doc Text mode.")
(defvar asciidoc-mode-abbrev-table nil
"Abbrev table in use in Asciidoc-mode buffers.")
(define-abbrev-table 'asciidoc-mode-abbrev-table ())
(require 'rx) (defmacro asciidoc-rx-markup (&rest term) `(rx ,@term
(minimal-match (zero-or-more (not (any "\r")))) ,@term))
(defmacro asciidoc-rx-markup-nospc (&rest term) `(rx ,@term
(+? (not space))
,@term))
(defconst asciidoc-font-lock-keywords
(eval-when-compile
(list
(cons "^\\s-*//.*$" `'asciidoc-comment-face)
(cons "^=\\s-+.*" `'asciidoc-document-title-face)
(cons "^==\\s-+.*" `'asciidoc-chapter-face)
(cons "^===\\s-+.*" `'asciidoc-section-face)
(cons "^====\\s-+.*" `'asciidoc-subsection-face)
(cons "^=====\\s-+.*" `'asciidoc-subsubsection-face)
(cons "^======\\s-+.*" `'asciidoc-paragraph-face)
(cons "^\\.[A-Za-z0-9ÄÖÜüöäß].*$"`'asciidoc-paragraph-face)
(cons "\\$\\$`.+?`\\$\\$" `'asciidoc-asciimath-face)
(cons "\\$\\$\\$" `'asciidoc-asciimath-face)
(cons "asciimath:\\[.*?\\]" `'asciidoc-asciimath-face)
(cons "\\(?:http\\|ftp\\|email\\)s?://.+?\\[" `'asciidoc-url-face)
(cons "\\(?:wpde\\|wpen\\):.+?\\[" `'asciidoc-url-face)
(cons "\\(?:\\[\\[\\[\\sw+,?\\|\\]\\]\\]\\)" `'asciidoc-idiosyncratic-face) (cons "\\(?:\\[\\[\\sw+,?\\|\\]\\]\\)" `'asciidoc-idiosyncratic-face) (cons "\\(?:<<\\sw+\\|>>\\)" `'asciidoc-idiosyncratic-face) (cons "\\(?:xref\\|anchor\\|link\\):\\sw+\\[" `'asciidoc-idiosyncratic-face)
(cons "\\]" `'asciidoc-idiosyncratic-face)
(cons "\\(?:image\\)::?\\S-+\\[" `'asciidoc-idiosyncratic-face)
(cons "^\\(include\\|sys\\|eval\\|ifn?def\\|endif\\|template\\)[12]?::.*?\\[" `'asciidoc-idiosyncratic-face)
(cons "footnote:\\[" `'asciidoc-idiosyncratic-face)
(cons "^\\s-*\\.\\{1,5\\}\\s-+" `'asciidoc-list-item-face)
(cons "^\\s-*-\\s-+" `'asciidoc-list-item-face)
(cons "^\\s-*\\*\\{1,5\\}\\s-+" `'asciidoc-list-item-face)
(cons "^\\s-*[0-9]+\\.\\s-+" `'asciidoc-list-item-face)
(cons "^\\s-*[a-zA-ZÄÖÜüöäß]\\.\\s-+" `'asciidoc-list-item-face)
(cons "^\\s-*[ixcvmIXCVM]+)\\s-+" `'asciidoc-list-item-face)
(cons "^.*[:;][:;-]\\s-" `'asciidoc-list-item-face)
(cons "^\\(?:\\+\\|--\\)\\s-*$" `'asciidoc-idiosyncratic-face)
(cons "^[_=\\.\\*\\+\\-]\\{6,\\}\\s-*$" `'asciidoc-idiosyncratic-face)
(cons (asciidoc-rx-markup-nospc ?:) `'asciidoc-idiosyncratic-face)
(cons (concat "\\<\\(?:TODO\\|BUG\\|ERROR\\|DISCLAIMER\\|WARNING\\|NOTE"
"\\|ERROR\\|TIP\\|CAUTION\\|IMPORTANT\\|EXAMPLE\\|BEISPIEL\\):") `'asciidoc-paragraph-face)
(cons "\\*[A-ZÄÖÜüöäß]+\\*:" `'asciidoc-paragraph-face)
(cons (asciidoc-rx-markup ?^) `'asciidoc-emph-face)
(cons (asciidoc-rx-markup ?~) `'asciidoc-emph-face)
(cons "\\b[A-ZÄÖÜß]+[A-ZÜÖÄß0-9\\- ]*\\b" `'asciidoc-upper-face)
(cons "&#[xX]?[0-9a-fA-F]+?;" `'font-lock-constant-face)
(cons "#[xX]?[0-9a-fA-F]+?;" `'font-lock-constant-face)
(cons "\\b[0-9]+° *[0-9]+' *[0-9]+\"\\s-*[NSWEO]*\\b" `'font-lock-constant-face) (cons "\\b[0-9,]+°\\s-*[NSWEO]*\\b" `'font-lock-constant-face) (cons "\\b[0-9,]+°\\s-*[NSWEO]*\\b" `'font-lock-constant-face) (cons "\\b[0-9]+[\\.,0-9]*[\%\"]" `'font-lock-constant-face) (cons "\\b[0-9]+[\\.,0-9]+" `'font-lock-constant-face)
(cons "\\b[0-9]+" `'font-lock-constant-face)
(cons "[0-9]+[\\.,0-9]*\\b" `'font-lock-constant-face)
(cons "\\(?:(R)\\|(TM)\\|(C)\\|---\\|--\\|\\.\\.\\.\\|[=-]+[<>]\\)" `'font-lock-builtin-face)
(cons "\\(?:##[^\r]*?##\\)" `'asciidoc-escape-face)
(cons "\\(?:#.*?#\\)" `'asciidoc-escape-face)
(cons "[ \t\v\r]+$" `'asciidoc-escape-face)
(cons (asciidoc-rx-markup ?+) `'asciidoc-mono-face)
(cons (asciidoc-rx-markup ?*) `'asciidoc-bold-face)
(cons (asciidoc-rx-markup ?') `'asciidoc-emph-face)
(cons "\"[^\r]+?\"" `'font-lock-string-face)
(cons "``[^\r]+?''" `'font-lock-string-face)
(cons "`[^\r]+?'" `'font-lock-string-face)
)
)
"Syntax expressions in AsciiDoc editing mode.")
(define-derived-mode asciidoc-mode text-mode "AsciiDoc"
"Major mode for outlined AsciiDoc text files.
Since this mode, derives from `text-mode', and enables `outline-minor-mode', it
runs, in that order, `text-mode-hook', `outline-minor-mode-hook' and finally
`asciidoc-mode-hook'."
(interactive)
(message "asciidoc-mode")
(turn-on-auto-fill)
(not-modified)
(modify-syntax-entry ?\' ".")
(make-local-variable 'paragraph-start)
(make-local-variable 'paragraph-separate)
(make-local-variable 'paragraph-ignore-fill-prefix)
(make-local-variable 'require-final-newline)
(make-local-variable 'font-lock-defaults)
(setq comment-start "// "
paragraph-start (concat "$\\|>" page-delimiter)
paragraph-separate paragraph-start
paragraph-ignore-fill-prefix t
require-final-newline t
case-fold-search t
font-lock-defaults '(asciidoc-font-lock-keywords nil nil ((?_ . "w"))))
(local-set-key [?\C-c ?\\] 'makefile-backslash-region)
(message "loading outline")
(require 'outline)
(message "enabling outline-minor-mode")
(outline-minor-mode)
(set (make-local-variable 'outline-regexp) "^[=]+ ")
(message "running asciidoc-mode-hook")
(run-mode-hooks 'asciidoc-mode-hook)
(message "%s: asciidoc-mode" (buffer-name (current-buffer)))
)
(eval-after-load "asciidoc-mode"
'(progn
(define-skeleton sk-quote "AsciiDoc quote paragraph." nil
\n "[quote,,]" \n
"____________________" \n - \n
"____________________" \n \n)
)
)
(provide 'asciidoc-mode)