Commit 6a2032f5 authored by Mike Scalora's avatar Mike Scalora Committed by Benno Schulenberg
Browse files

new feature: comment/uncomment current line or selected lines


This allows for commenting or uncommenting a line or a bunch of lines
with a single keystroke (default binding: M-3).  The characters used
for commenting/uncommenting are specified by the active syntax file.
Reviewed-by: default avatarBenno Schulenberg <bensberg@justemail.net>
Signed-off-by: default avatarMike Scalora <mike@scalora.org>
No related merge requests found
Showing with 52 additions and 1 deletion
+52 -1
......@@ -84,6 +84,22 @@ else
fi
fi
AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
else
# Disabling nanorc silently disables comment support.
enable_comment=no
fi
fi
if test "x$disable_comment" != xyes; then
if test "x$enable_comment" != xno; then
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to disable the comment/uncomment functionality.])
fi
fi
AC_ARG_ENABLE(extra,
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
if test "x$enable_extra" = xno; then
......
......@@ -302,6 +302,16 @@ syntax should be used for that file. This
functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.
.TP
.BI comment " string"
Use the given string for commenting and uncommenting lines. A vertical bar or
pipe character (|) designates bracket-style comments; for example, "/*|*/" for
CSS files. The characters before the pipe are prepended to the line and the
characters after the pipe are appended at the end of the line. If no pipe
character is present, the entire string is prepended; for example, "#" for
Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON. Double quotes or backslashes
may be escaped with a backslash; for example, ".\\"" for man page source.
.TP
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
......@@ -336,7 +346,7 @@ to \fBicolor\fP.
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIstr\fP to include
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBlinter\fP, or \fBformatter\fP directive
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP directive
to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which are normally not writable)
......@@ -455,6 +465,10 @@ Indents (shifts to the right) the currently marked text.
.B unindent
Unindents (shifts to the left) the currently marked text.
.TP
.B comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
.TP
.B left
Goes left one position (in the editor or browser).
.TP
......
......@@ -2,6 +2,7 @@
syntax "asm" "\.(S|s|asm)$"
magic "[Aa]ssembl(y|er)"
comment "//"
color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
......
## Here is an example for Autoconf.
syntax "autoconf" "\.(ac|m4)$"
comment "#"
# Keywords:
color yellow "\<(if|test|then|elif|else|fi|for|in|do|done)\>"
......
......@@ -2,6 +2,7 @@
syntax "awk" "\.awk$"
magic "awk.*script text"
comment "#"
# Records.
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
......
......@@ -2,6 +2,7 @@
syntax "c" "\.(c(c|pp|xx|\+\+)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
magic "(ASCII|UTF-8 Unicode) C(\+\+)? program text"
comment "//"
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)\>"
......
## Syntax highlighting for CMake files.
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
comment "#"
icolor green "^[[:space:]]*[A-Z0-9_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
......
## Here is an example for CSS files.
syntax "css" "\.css$"
comment "/*|*/"
color brightred "."
color brightyellow start="\{" end="\}"
......
## Here is an example for apt's sources.list.
syntax "sources.list" "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
comment "#"
# Coloring the deb lines, working from tail to head. First the
# components -- well, everything, and thus also the components.
......
......@@ -2,6 +2,7 @@
## for files that do not match any other syntax.
syntax "default"
comment "#"
# Spaces in front of tabs.
color ,red " + +"
......
## Here is an example for Emacs Lisp.
syntax "elisp" "\.el$"
comment ";"
# Basic functions/macros
color brightcyan "\<(if|when|unless|cond|and|or|lambda|let|progn|while|dolist|dotimes)\>"
......
## Here is an example for Fortran 90/95.
syntax "fortran" "\.(f|f90|f95)$"
comment "!"
color red "\<[0-9]+\>"
......
## Here is an example for Gentoo ebuilds/eclasses.
syntax "ebuild" "\.e(build|class)$"
comment "#"
## All the standard portage functions
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
......
## Here is an example for Go.
syntax "go" "\.go$"
comment "//"
# Set up a formatter since spelling is probably useless...
formatter gofmt -w
......
## Here is an example for groff.
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
comment ".\""
# The argument of .ds or .nr
color cyan "^\.(ds|nr) [^[:space:]]*"
......
......@@ -3,6 +3,7 @@
syntax "guile" "\.scm$"
header "^#!.*guile"
magic "guile"
comment ";"
# Basic scheme functions
color green "\<(do|if|lambda|let(rec)?|map|unless|when)\>"
......
......@@ -2,7 +2,10 @@
syntax "html" "\.html?$"
magic "HTML document text"
comment "<!--|-->"
color cyan start="<" end=">"
color red "&[^;[:space:]]*;"
color green ""(\\.|[^"])*""
color yellow start="<!--" end="-->"
......@@ -2,6 +2,7 @@
syntax "java" "\.java$"
magic "Java "
comment "//"
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)\>"
......
## Here is an example for Javascript.
syntax "javascript" "\.js$"
comment "//"
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(const|function|let|this|typeof|var|void)\>"
......
......@@ -5,6 +5,8 @@
# License: GPLv3 or newer
syntax "json" "\.json$"
# No comments are permitted in JSON.
comment ""
# Numbers (used as value).
color green ":[[:space:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment