branch: master commit 2f68d9c43add3ef43c088e8cc7afd5a04caa5723 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Allow empty separator though e.g. "mm10" * tiny.el (tiny-mapconcat): Update. * tiny-test.el (tiny-mapconcat): Add test. * Makefile: Simplify. Fixes #4. --- Makefile | 15 +++++---------- tiny-test.el | 2 ++ tiny.el | 14 ++++++++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 6332238..33f8666 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,13 @@ -EMACS ?= emacs -CASK_EXEC ?= cask exec - +emacs ?= emacs all: test -test: clean-elc - ${MAKE} unit - -unit: - ${CASK_EXEC} ${EMACS} -Q -batch -l tiny-test.el -l tiny.el --eval "(ert t)" +test: clean + $(emacs) -Q -batch -l tiny-test.el -l tiny.el --eval "(ert t)" compile: - ${CASK_EXEC} ${EMACS} -Q -batch -f batch-byte-compile tiny.el + $(emacs) -Q -batch -f batch-byte-compile tiny.el -clean-elc: +clean: rm -f f.elc .PHONY: all test diff --git a/tiny-test.el b/tiny-test.el index dc9c3b9..3d9ec54 100644 --- a/tiny-test.el +++ b/tiny-test.el @@ -74,6 +74,8 @@ with point at the end of TXT." (ert-deftest tiny-mapconcat () (should (equal (with-text-value "m10" (lambda()(eval (read (tiny-mapconcat))))) "0 1 2 3 4 5 6 7 8 9 10")) + (should (equal (with-text-value "mm10" (lambda()(eval (read (tiny-mapconcat))))) + "012345678910")) (should (equal (with-text-value "m5 10" (lambda()(eval (read (tiny-mapconcat))))) "5 6 7 8 9 10")) (should (equal (with-text-value "m5 10*xx" (lambda()(eval (read (tiny-mapconcat))))) diff --git a/tiny.el b/tiny.el index 78d44bb..eeebebe 100644 --- a/tiny.el +++ b/tiny.el @@ -169,8 +169,14 @@ Must throw an error when can't go up further." Defaults are used in place of null values." (let ((parsed (tiny-mapconcat-parse))) (when parsed - (let* ((n1 (or (nth 0 parsed) "0")) - (s1 (or (nth 1 parsed) " ")) + (let* ((n0 (or (nth 0 parsed) "0")) + (n1 (nth 1 parsed)) + (s1 (cond ((null n1) + " ") + ((equal n1 "m") + "") + (t + n1))) (n2 (nth 2 parsed)) (expr (or (nth 3 parsed) "x")) (lexpr (read expr)) @@ -193,12 +199,12 @@ Defaults are used in place of null values." (cdr tes) " ") ")))(number-sequence %s %s) \"%s\")"))) - (unless (>= (read n1) (read n2)) + (unless (>= (read n0) (read n2)) (format format-expression expr (replace-regexp-in-string "\\\\n" "\n" fmt) - n1 + n0 n2 s1))))))