* doc/syntax/patch.nanorc: Show trailing whitespace on added lines.
* doc/syntax/debian.nanorc: Make the component colouring simpler,
and the URI colouring completer, and improve the comments.
+ * doc/syntax/*.nanorc: Harmonize (partially) the syntax files.
2014-05-16 David Lawrence Ramsey <pooka109@gmail.com>
* src/color.c, src/cut.c, src/text.c: Tweak some whitespace.
## Here is an example for assembler.
-##
+
syntax "asm" "\.(S|s|asm)$"
magic "[Aa]ssembl(y|er)"
+
color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
-## Highlight strings (note: VERY resource intensive)
+
+# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
+# Multiline strings (note: VERY resource intensive).
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
-## Highlight comments
+
+# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
-## Highlight trailing whitespace
+
+# Trailing whitespace.
color ,green "[[:space:]]+$"
## Here is an example for awk.
-##
+
syntax "awk" "\.awk$"
magic "awk.*script text"
-## records
+
+# Records.
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
-## awk-set variables
+# Awk-set variables.
color red "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
color red "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>"
color red "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>"
-## function declarations and special patterns
+# Function declarations and special patterns.
color brightgreen "\<(function|extension|BEGIN|END)\>"
-## operators
+# Operators.
color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
-## flow control
+# Flow control.
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"
-## I/O statements
+# I/O statements.
color brightgreen "\<(close|getline|next|nextfile|print|printf)\>"
color brightgreen "\<(system|fflush)\>"
-## standard functions
+# Standard functions.
color magenta "\<(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\>"
color magenta "\<(asort|asorti|gensub|gsub|index|length|match)\>"
color magenta "\<(split|sprintf|strtonum|sub|substr|tolower|toupper)\>"
color magenta "\<(and|compl|lshift|or|rshift|xor)\>"
color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
-## String highlighting. You will in general want your comments and
-## strings to come last, because syntax highlighting rules will be
-## applied in the order they are read in.
+# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
-
-## Comment highlighting
+# Comments.
color brightblue "(^|[[:space:]])#.*$"
-## Trailing whitespace
+# Trailing whitespace.
color ,green "[[:space:]]+$"
syntax "c" "\.(c(c|pp|xx|\+\+)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
magic "(ASCII|UTF-8 Unicode) C(\+\+)? program text"
-color brightred "\<[A-Z_][0-9A-Z_]+\>"
+color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
## Colouring for Changelogs.
-##
+
syntax "changelog" "Change[Ll]og.*"
# Author lines.
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
-
# Bug numbers.
color cyan "bug #[0-9]{5}"
-
# Probable variables, for variety.
-color brightred "\<[A-Z_][0-9A-Z_]+\>"
-
+color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences.
color brightblue "\^[A-Z]" "\<M-." "\<F1?[0-9]" "(\^|M-)Space"
## Syntax highlighting for CMake files.
-##
+
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
icolor green "^[[:space:]]*[A-Z0-9_]+"
## Here is an example for CSS files.
-##
+
syntax "css" "\.css$"
+
color brightred "."
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="([;^\{]|$)"
## Here is an example for Gentoo ebuilds/eclasses.
-##
+
syntax "ebuild" "\.e(build|class)$"
+
## All the standard portage functions
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
## Here is an example for Go.
-##
+
syntax "go" "\.go$"
# Types.
## Here is an example for groff.
-##
+
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
-## The argument of .ds or .nr
+
+# The argument of .ds or .nr
color cyan "^\.(ds|nr) [^[[:space:]]]*"
-## Single character escapes
+# Single-character escapes
color brightmagenta "\\."
-## Highlight the argument of \f or \s in the same color
+# The argument of \f or \s in the same color
color brightmagenta "\\f." "\\f\(.." "\\s(\+|\-)?[0-9]"
-## Newlines
+# Newlines
color cyan "(\\|\\\\)n(.|\(..)"
color cyan start="(\\|\\\\)n\[" end="]"
-## Requests
+# Requests
color brightgreen "^\.[[:space:]]*[^[[:space:]]]*"
-## Comments
+# Comments
color yellow "^\.\\".*$"
-## Strings
+# Strings
color green "(\\|\\\\)\*(.|\(..)"
color green start="(\\|\\\\)\*\[" end="]"
-## Characters
+# Characters
color brightred "\\\(.."
color brightred start="\\\[" end="]"
-## Macro arguments
+# Macro arguments
color brightcyan "\\\\\$[1-9]"
## Here is a short example for HTML.
-##
+
syntax "html" "\.html?$"
magic "HTML document text"
+
color cyan start="<" end=">"
color red "&[^;[:space:]]*;"
color green ""(\\.|[^"])*""
## Here is an example for Java.
-##
+
syntax "java" "\.java$"
magic "Java "
+
color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
## Here is an example for Javascript.
-##
+
syntax "javascript" "\.js$"
+
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(const|function|let|this|typeof|var|void)\>"
color brightyellow "\<(for|if|while|with|do|else|case|default|switch)\>"
color magenta "\<(continue|break|return|yield)\>"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
-## String highlighting. You will in general want your comments and
-## strings to come last, because syntax highlighting rules will be
-## applied in the order they are read in.
+# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*"" "'(\\.|[^'])*'"
-
-## Comment highlighting
+# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
-## Trailing whitespace
+# Trailing whitespace.
color ,green "[[:space:]]+$"
-##############################################################################
+## Syntax highlighting for Lua.
#
-# Lua syntax highlighting for Nano.
-#
-# Author: Matthew Wild <mwild1 (at) gmail.com>
-# License: GPL 3 or later
-#
-# Version: 2011-05-05
-#
-# Notes: Originally based on Ruby syntax rc by Josef 'Jupp' Schugt
-##############################################################################
-
+## Author: Matthew Wild <mwild1 (at) gmail.com>
+## License: GPL 3 or later
+## Version: 2011-05-05
-# Automatically use for '.lua' files
syntax "lua" "\.lua$"
color brightwhite "\[\[.*\]\]"
-## Syntax highlighting for Makefiles.
-## (unattributed example from http://wiki.linuxhelp.net/)
+## Here is an example for Makefiles.
syntax "makefile" "Makefile[^/]*$"
+
color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
color green "#.*$"
+
## Trailing whitespace.
color ,green "[[:space:]]+$"
## Here is an example for manpages.
-##
+
syntax "man" "\.[1-9]x?$"
magic "troff or preprocessor input text"
+
color green "\.(SH|SS|TH) .*$"
color brightgreen "\.(SH|SS|TH) " "\.([HIT]P)"
color brightred "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*$"
color brightblue "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "\.([LP]?P)$"
color magenta "\\f[BIPR]"
color yellow "\.(br|DT|RS|RE|PD)"
+
# Comments.
color cyan "\.?\\\".*$"
+
# Trailing whitespace.
color ,green "[[:space:]]+$"
## Here is an example for Magicpoint presentations.
-##
+
syntax "mgp" "\.mgp$"
header "^%include.*"
+
icolor green "^%[a-z].*$"
color cyan "(^|[[:space:]])#.*$"
color cyan "(^|[[:space:]])%%.*$"
## Here is an example for quoted emails (under e.g. mutt).
-##
+
syntax "mutt"
+
color green "^>.*"
## Here is an example for C/C++/Obj-C.
-##
+
syntax "m" "\.m$"
-## Stuffs
-color brightwhite "\<[A-Z_][0-9A-Z_]+\>"
+# Stuffs,
+color brightwhite "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|BOOL|bool|char|int|short|long|id|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<[[:alpha:]_][[:alnum:]_]*_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
color brightgreen "\<(goto|continue|break|return)\>"
color brightgreen "@\<(en(code|d)|i(mplementation|nterface)|selector)\>"
-## GCC builtins
+# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
-## Selector/method
+# Selector/method.
color brightmagenta "(^|[[:space:]])\[.*[[:space:]].*\]"
color white ":[[:alnum:]]*"
color magenta "[[:alnum:]]*:"
color white "\[[^][:space:]]*\]"
-## String highlighting. You will in general want your comments and
-## strings to come last, because syntax highlighting rules will be
-## applied in the order they are read in.
+# Strings.
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
color brightblack "<[^= ]*>" ""(\\.|[^"])*""
color brightblue "@"(\\.|[^"])*""
-## This string is VERY resource intensive!
+# Multiline strings. This regex is VERY resource intensive!
## color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
+# Preprocessor commands.
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
-## Comment highlighting
+# Comments.
color yellow "//.*"
color yellow start="/\*" end="\*/"
+# Trailing whitespace.
+color ,green "[[:space:]]+$"
## Syntax highlighting for OCaml.
syntax "ocaml" "\.mli?$"
+
#uid
color red "\<[A-Z][0-9a-z_]{2,}\>"
#declarations
#patterns
color blue "\<(fun|function|functor|match|try|with)\>"
#patterns-modifiers
-color yellow "\<(as|when|of)\>"
+color yellow "\<(as|when|of)\>"
#conditions
color cyan "\<(if|then|else)\>"
#blocs
## Here is an example for Perl.
+
syntax "perl" "\.p[lm]$"
header "^#!.*/perl[-0-9._]*"
magic "Perl script text"
## Here is an example for PHP.
-##
+
syntax "php" "\.php[2345s~]?$"
magic "PHP script text"
-## php markings
+# PHP markings.
color brightgreen "(<\?(php)?|\?>)"
-## functions
+# Functions.
color white "\<[a-z_]*\("
-## types
+# Types.
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"
-## structure
+# Structure.
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"
-## control flow
+# Control flow.
color magenta "\<(goto|continue|break|return)\>"
-## strings
+# Strings.
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
-## comments
+# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
-#color blue start="<" end=">"
-#color red "&[^;[[:space:]]]*;"
+##color blue start="<" end=">"
+##color red "&[^;[[:space:]]]*;"
-## trailing whitespace
+# Trailing whitespace.
color ,green "[[:space:]]+$"
## Colouring for PO files.
-##
+
syntax "po" "\.pot?$"
+
# Comments.
color green "^#.*$"
color yellow "Copyright|\(C\)"
## Here is an example for POV-Ray.
-##
+
syntax "pov" "\.(pov|POV|povray|POVRAY)$"
+
color brightcyan "^[[:space:]]*#[[:space:]]*(declare)"
color brightyellow "\<(sphere|cylinder|translate|matrix|rotate|scale)\>"
color brightyellow "\<(orthographic|location|up|right|direction|clipped_by)\>"
color brightred "\<(fog|object|camera)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color brightmagenta "\<(union|group|subgroup)\>"
-## Comment highlighting
+
+# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
## Here is an example for Python.
-##
+
syntax "python" "\.py$"
header "^#!.*/python[-0-9._]*"
## Here is an example for Ruby.
-##
+
syntax "ruby" "\.rb$"
header "^#!.*/ruby[-0-9._]*"
-## Asciibetical list of reserved words
+
+# Asciibetical list of reserved words.
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
-## Constants
+# Constants.
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
-## Ruby "symbols"
+# Ruby "symbols".
icolor magenta "([ ]|^):[0-9A-Z_]+\>"
-## Some unique things we want to stand out
+# Some unique things we want to stand out.
color brightyellow "\<(__FILE__|__LINE__)\>"
-## Regular expressions
+# Regular expressions.
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*"
-## Shell command expansion is in `backticks` or like %x{this}. These are
-## "double-quotish" (to use a perlism).
+# Shell command expansion is in `backticks` or like %x{this}. These are
+# "double-quotish" (to use a perlism).
color brightblue "`[^`]*`" "%x\{[^}]*\}"
-## Strings, double-quoted
+# Strings, double-quoted.
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
-## Expression substitution. These go inside double-quoted strings,
-## "like #{this}".
+# Expression substitution. These go inside double-quoted strings,
+# "like #{this}".
color brightgreen "#\{[^}]*\}"
-## Strings, single-quoted
+# Strings, single-quoted.
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
-## Comments
+# Comments.
color cyan "#[^{].*$" "#$"
color brightcyan "##[^{].*$" "##$"
-## "Here" docs
+# "Here" docs.
color green start="<<-?'?EOT'?" end="^EOT"
-## Some common markers
+# Some common markers.
color brightcyan "(XXX|TODO|FIXME|\?\?\?)"
## Here is an example for Bourne shell scripts.
-##
+
syntax "sh" "\.sh$"
-magic "(POSIX|Bourne.*) shell script text"
header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
+magic "(POSIX|Bourne.*) shell script text"
+
icolor brightgreen "^[0-9A-Z_]+\(\)"
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
color green "\<(declare|eval|exec|export|let|local)\>"
color green "-[Ldefgruwx]\>"
color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|echo|env|grep|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|umask|unset)\>"
+
# Basic variable names (no braces).
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
# More complicated variable names; handles braces and replacements and arrays.
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
+
+# Comments.
color cyan "(^|[[:space:]])#.*$"
+
+# Strings.
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
+
+# Trailing whitespace.
color ,green "[[:space:]]+$"
## Syntax highlighting for RPM spec files.
-## Parts were taken from Kate's (KDE) syntax highlighting.
-## Asterios Dramis
+
syntax "spec" "\.(spec$|spec\.*)"
-# Main tags
+
+# Main tags.
color brightblue "((Icon|ExclusiveOs|ExcludeOs)[[:space:]]*:)"
color brightblue "((BuildArch|BuildArchitectures|ExclusiveArch|ExcludeArch)[[:space:]]*:)"
color brightblue "((Conflicts|Obsoletes|Provides|Requires|Requires\(.*\)|Enhances|Suggests|BuildConflicts|BuildRequires|Recommends|PreReq|Supplements)[[:space:]]*:)"
color brightblue "((Copyright|License|Summary|Summary\(.*\)|Distribution|Vendor|Packager|Group|Source\d*|Patch\d*|BuildRoot|Prefix)[[:space:]]*:)"
color brightblue "((Name|Version|Release|Url|URL)[[:space:]]*:)"
color brightblue start="^Source" end=":" start="^Patch" end=":"
-# Architectures
+# Architectures.
color brightred "(i386|i486|i586|i686|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|ppc|iseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x|s390|noarch)"
-# Architecture conditionals
+# Architecture conditionals.
color brightred "(ifarch|ifnarch)"
-# OS conditionals
+# OS conditionals.
color brightred "(ifos|ifnos)"
-# %* strings
+# %* strings.
color green "%([A-Z_a-z_0-9_]*)"
color magenta "%_([A-Z_a-z_0-9_]*)"
color yellow start="%__" end="\ "
color magenta start="%\{" end="\}"
color yellow start="%\{__" end="\}"
-# Sections
+# Sections.
color red "^%(build$|changelog|check$|clean$|description|files|install$|package|pre|prep$|preun|post|postun)"
color red "^%(trigger|triggerin|triggerpostun|triggerun|verifyscript)"
-# Conditionals and Defines
+# Conditionals and defines.
color brightred "%(if|else|endif|define|global|undefine)"
-# Comments
+
+# Comments.
color cyan "#.*$"
-# "# norootforbuild" is handled as main tag
+# Special case: "# norootforbuild" is handled as main tag.
color brightblue "^# norootforbuild"
-# %changelog date entries
+# %changelog date entries.
color brightyellow "^\* .*\)$"
-# Trailing whitespace
+# Trailing whitespace.
color ,green "[[:space:]]+$"
## Here is a short example for TeX files.
-##
+
syntax "tex" "\.tex$"
+
icolor green "\\.|\\[A-Z]*"
color magenta "[{}]"
color blue "(^|[^\])%.*"
## Here is an example for Texinfo files.
-##
+
syntax "texinfo" "\.texi$"
header "^\\input texinfo"
magic "Texinfo source text"