(defgroup asciidoc-faces nil
"AsciiDoc highlighting"
:group 'asciidoc)
(defface asciidoc-document-title-face
`((((class color) (background dark))
(:foreground "midnightblue" :bold t :underline t :height 1.3 :inherit variable-pitch))
(((class color) (background light))
(:foreground "midnightblue" :bold t :underline t :height 1.3 :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 "navyblue" :bold t :underline t :height 1.2 :inherit variable-pitch))
(((class color) (background light))
(:foreground "navyblue" :bold t :underline t :height 1.2 :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 "mediumblue" :bold t :underline t :height 1.1 :inherit variable-pitch))
(((class color) (background light))
(:foreground "mediumblue" :bold t :underline t :height 1.1 :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 "royalblue" :bold t :underline t :height 1.0 :inherit variable-pitch))
(((class color) (background light))
(:foreground "royalblue" :bold 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 "cornflowerblue" :underline t :height 1.0 :inherit variable-pitch))
(((class color) (background light))
(:foreground "cornflowerblue" :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 "Gray10" :bold t :inherit variable-pitch))
(((class color) (background light))
(:foreground "DarkRed" :bold t :inherit variable-pitch))
(t (:inherit variable-pitch)))
"Face for AsciiDoc paragraph titles and admonition blocks."
:group 'asciidoc-faces)
(defface asciidoc-block-face
`((((class color) (background dark))
(:foreground "DarkOrchid"))
(((class color) (background light))
(:foreground "DarkOrchid"))
(t (:weight bold :inherit variable-pitch)))
"Face for AsciiDoc paragraphs."
:group 'asciidoc-faces)
(defface asciidoc-mono-face
`((t (:foreground "DarkOrange4" :family "courier new")))
"Face for AsciiDoc markup (monospaced text)."
:group 'asciidoc-faces)
(defface asciidoc-list-number-face
`((t (:foreground "Gray20" :bold t :family "courier new")))
"Face for AsciiDoc list items."
:group 'asciidoc-faces)
(defface asciidoc-emph-face
`((t (:foreground "DarkOrange4" :slant italic :inherit variable-pitch)))
"Face for AsciiDoc markup (emphasized text)."
:group 'asciidoc-faces)
(defface asciidoc-bold-face
`((t (:foreground "DarkOrange4" :weight bold)))
"Face for AsciiDoc markup (bold text)."
:group 'asciidoc-faces)
(defface asciidoc-idiosyncratic-face
`((((class color) (background dark))
(:foreground "Gray30"))
(((class color) (background light))
(:foreground "Gray30"))
(t ()))
"Face for AsciiDoc gibberish."
:group 'asciidoc-faces)
(defface asciidoc-escape-face
`((((class color) (background dark))
(:foreground "Gray20" :background "Yellow"))
(((class color) (background light))
(:foreground "Gray20" :background "Yellow"))
(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 (1+ (not white))
,@term
(any alnum)
(* (not (any "\r"))) ,@term
))
(defconst asciidoc-font-lock-keywords
(eval-when-compile
(list
(cons "&#[xX]?[0-9a-fA-F]+?;" `'font-lock-constant-face)
(cons "#[xX]?[0-9a-fA-F]+?;" `'font-lock-constant-face)
(cons "\\$\\$`.+?`\\$\\$" `'font-lock-constant-face)
(cons "\\(?:##[^\r]*?##\\)" `'asciidoc-escape-face)
(cons "\\(?:#.*?#\\)" `'asciidoc-escape-face)
(cons "[ \t\v\r]+$" `'asciidoc-escape-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-Z].*$" `'asciidoc-paragraph-face)
(cons "^\\[.+?\\]" `'asciidoc-idiosyncratic-face)
(cons "^\\s-*\\.\\{1,5\\}\\s-+" `'asciidoc-list-number-face)
(cons "^\\s-*-\\s-+" `'asciidoc-list-number-face)
(cons "^\\s-*\\*\\{1,5\\}\\s-+" `'asciidoc-list-number-face)
(cons "^\\s-*[1-9]+\\.\\s-+" `'asciidoc-list-number-face)
(cons "^\\s-*[a-zA-Z]\\.\\s-+" `'asciidoc-list-number-face)
(cons "^\\s-*[ixcvmIXCVM]+)\\s-+" `'asciidoc-list-number-face)
(cons "^.*[:;][:;-]\\s-" `'asciidoc-list-number-face)
(cons "^\\(?:\\+\\|--\\)\\s-*$" `'asciidoc-idiosyncratic-face)
(cons "^[_=\\.\\*\\+\\-]\\{6,\\}\\s-*$" `'asciidoc-idiosyncratic-face)
(cons "^\\s-*//.*$" 'font-lock-comment-face)
(cons "^\\(image\\|include\\|sys\\|eval\\|ifn?def\\|endif\\|template\\)[0-9:]+\\S-*"
'font-lock-keyword-face)
(cons "\\(xref\\|anchor\\|link\\|image\\|asciimath\\|indexterm2?\\):+\\S-*"
'font-lock-keyword-face)
(cons "^>>[{}=]+ .*" 'font-lock-type-face)
(cons "^<< +.*" 'font-lock-builtin-face)
(cons "\\(?:(R)\\|(TM)\\|(C)\\|---\\|--\\|\\.\\.\\.\\|[=-]+[<>]\\)"
`'font-lock-builtin-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-mono-face)
(cons (asciidoc-rx-markup ?*) `'asciidoc-bold-face)
(cons (asciidoc-rx-markup ?') `'asciidoc-emph-face)
(cons (asciidoc-rx-markup ?^) `'asciidoc-emph-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)
(cons "\\sw+://[^\\[\\t ]*" `'asciidoc-mono-face)
(cons "\\[.+\\]" `'asciidoc-bold-face)
)
)
"Syntax expressions in AsciiDoc editing mode.")
(define-derived-mode asciidoc-mode text-mode "AsciiDoc"
"Major mode for outlined AsciiDoc text files.
Calls the value of `text-mode-hook', `outline-mode-hook' then
`asciidoc-mode-hook'."
(interactive)
(turn-on-auto-fill)
(set-buffer-file-coding-system 'iso-latin-1-unix) (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)
(require 'outline)
(outline-minor-mode)
(set (make-local-variable 'outline-regexp) "^[=]+ ")
(when nil
(hide-body)
(outline-next-visible-heading 1))
(run-hooks 'asciidoc-mode-hook)
(message "%s: asciidoc-mode" (buffer-name (current-buffer)))
)
(provide 'asciidoc-mode)