diff options
author | Michal Nazarewicz <[email protected]> | 2014-06-05 16:42:07 +0200 |
---|---|---|
committer | Michal Nazarewicz <[email protected]> | 2014-06-05 16:42:07 +0200 |
commit | 03d7d160c3c7f31f1fee84b1bdcd252a8cec7b99 (patch) | |
tree | a173a51f3eee0e4ab48b6770961819a95ebb9af1 /test | |
parent | df344ab435c04aea5bb9261e6d2c349ab8f4fcea (diff) |
tildify.el: Rewrite `tildify-region' and co., add foreach function.
* lisp/textmodes/tildify.el (tildify-foreach-region-outside-env): New
function which calls a callback on portions of the buffer that are
outside of ignored environments.
(tildify-build-regexp): Remove function since it is now
incorporated in `tildify-foreach-region-outside-env' where it is
optimised and simplified by the use of `mapconcat'.
(tildify-tildify): Return number of substitutions made so that…
(tildify-count): …can be removed.
(tildify-find-env): Accept a new PAIRS argument which was
previously looked up in `tildify-ignored-environments-alist' each
time the function was called. With this change, the lookup is
performed only once in `tildify-foreach-region-outside-env'.
(tildify-region): Greatly simplify the function since now most of
the work is done by `tildify-foreach-region-outside-env'.
(tildify-mode-alist): Simplify slightly by avoiding if and setq
and instead using or.
* tests/automated/tildify-tests.el (tildify-test-find-env-end-re-bug)
(tildify-test-find-env-group-index-bug): Update to support new
signature of the `tildify-foreach-region-outside-env' function.
Namely, it now takes pairs as an argument instead of looking it up in
`tildify-ignored-environments-alist'.
Diffstat (limited to 'test')
-rw-r--r-- | test/ChangeLog | 6 | ||||
-rw-r--r-- | test/automated/tildify-tests.el | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 38a4feb528..6248d6cb9a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,5 +1,11 @@ 2014-06-05 Michal Nazarewicz <[email protected]> + * automated/tildify-tests.el (tildify-test-find-env-end-re-bug) + (tildify-test-find-env-group-index-bug): Update to support new + signature of the `tildify-foreach-region-outside-env' function. + Namely, it now takes pairs as an argument instead of looking it up in + `tildify-ignored-environments-alist'. + * automated/tildify-tests.el (tildify-test--example-html): Add support for generating XML code, so that… (tildify-test-xml) …test can be added to check handling of XML diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index dd404fcac2..cf18320030 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -114,23 +114,22 @@ latter is missing, SENTENCE will be used in all placeholder positions." (ert-deftest tildify-test-find-env-end-re-bug () "Tests generation of end-regex using mix of indexes and strings" (with-temp-buffer - (let ((tildify-ignored-environments-alist - `((,major-mode ("foo\\|bar" . ("end-" 0)))))) - (insert "foo whatever end-foo") - (goto-char (point-min)) - (should (string-equal "end-foo" (tildify-find-env "foo\\|bar")))))) + (insert "foo whatever end-foo") + (goto-char (point-min)) + (should (string-equal "end-foo" + (tildify-find-env "foo\\|bar" + '(("foo\\|bar" . ("end-" 0)))))))) (ert-deftest tildify-test-find-env-group-index-bug () "Tests generation of match-string indexes" (with-temp-buffer - (let ((tildify-ignored-environments-alist - `((,major-mode ("start-\\(foo\\|bar\\)" . ("end-" 1)) - ("open-\\(foo\\|bar\\)" . ("close-" 1))))) + (let ((pairs '(("start-\\(foo\\|bar\\)" . ("end-" 1)) + ("open-\\(foo\\|bar\\)" . ("close-" 1)))) (beg-re "start-\\(foo\\|bar\\)\\|open-\\(foo\\|bar\\)")) (insert "open-foo whatever close-foo") (goto-char (point-min)) - (should (string-equal "close-foo" (tildify-find-env beg-re)))))) + (should (string-equal "close-foo" (tildify-find-env beg-re pairs)))))) (provide 'tildify-tests) |