Allow user to specify own escape-chars
authorguns <self@sungpae.com>
Wed, 19 Feb 2014 00:34:08 +0000 (18:34 -0600)
committerguns <self@sungpae.com>
Wed, 19 Feb 2014 01:15:38 +0000 (19:15 -0600)
commitbc77dda48e8ce418aee6b75c85ae5273d3d15e69
tree9d9fbb0f2c1202ae2e5865a554512fd809e0d12c
parent0558b8281c3d0920dfba664656eccdaa5ed7e409
Allow user to specify own escape-chars

The current set of metacharacters that are escaped when rendering are
based on Java's Pattern implementation, which for the purposes of this
library, is basically PCRE.

However, different regular expression implementations sometimes have
different pattern metacharacters. Vim's very-magic mode, for instance,
reserves all [^a-zA-Z0-9_] ASCII characters, while POSIX basic regular
expressions¹ do not use (, ), ?, +, or | (these must be preceeded by a
backslash to attain their now familiar meaning).

This patch adds the :escape-chars option to pattern and string-pattern
to allow the user to specify this set of metacharacters. The value of
:escape-chars may also be a key in the (public) metacharacters map.

The actual implementation is done through a dynamic var, following the
precedent of *capture*.

¹ Note that we must also allow the user to control the characters used
  for capturing/non-capturing groups, alternation, optional matching,
  etc, in order to make frak work for POSIX BREs
src/cljx/frak.cljx
test/frak_test.clj