tildify.el: Fix end-regex building in `tildify-find-env'
authorMichal Nazarewicz <mina86@mina86.com>
Thu, 5 Jun 2014 14:37:45 +0000 (16:37 +0200)
committerMichal Nazarewicz <mina86@mina86.com>
Thu, 5 Jun 2014 14:37:45 +0000 (16:37 +0200)
commitaf9a3b28c0ca250ed245bd54c8737792916fe4c6
treee6547ebc6b75c57699cde2c3a8e07066ab73d110
parenta1d799c25e4ad96dd2303ef2daa6cb51b5a0fe01
tildify.el: Fix end-regex building in `tildify-find-env'

* lisp/textmodes/tildify.el (tildify-find-env): The
`tildify-ignored-environments-alist' allows the end-regex
to be provided not as a static string but mix of strings and
indexes of groups matched the begin-regex.  For example, the
“\verb!…!” TeX-command (where “!” is an arbitrary character)
is handled using:

    ("\\\\verb\\*?\\(.\\)" . (1))

In the same way, the following should be supported as well:

    ("open-\\(.\\)" . ("end-" 1))

However the tildify-find-env function fails at

    (concat result
            (if (stringp (setq aux (car expression)))
                 expression  ; BUG: expression is a list
               (regexp-quote (match-string aux))))

where the string part is handled incorrectly.

The most trivial fix would be to replace `expression'
in the true-part of the if-statement with `aux', but
instead, this commit optimises `tildify-find-env' by
changing it to use `mapconcat' rather than open-coded
while-loop.

* tests/automated/tildify-tests.el (tildify-test-find-env-end-re-bug):
New test validating fix to the above bug.
lisp/ChangeLog
lisp/textmodes/tildify.el
test/ChangeLog
test/automated/tildify-tests.el