branch: master commit e6abbc63cca8cd620dac874a2f07f1e2ef097b7c Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
tiny.el (tiny-date): renamed from t-date. In format string it's just "date" test/tiny-test.el (tiny-mapconcat): modified test --- README.md | 2 +- tiny-test.el | 4 ++-- tiny.el | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 48273ab..e0fade8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ The advantages are: You can even schedule and deadline: - m\n8|**** TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(t-date "Oct 7" (* x 7))> DEADLINE: <%(t-date "Oct 14" (* x 7))> + m\n8|**** TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(date "Oct 7" (* x 7))> DEADLINE: <%(date "Oct 14" (* x 7))> **** TODO Learning from Data Week 2 SCHEDULED: <2013-10-07 Mon> DEADLINE: <2013-10-14 Mon> diff --git a/tiny-test.el b/tiny-test.el index e959345..adcd43e 100644 --- a/tiny-test.el +++ b/tiny-test.el @@ -122,7 +122,7 @@ convert img10.jpg -monochrome -resize 50% -rotate 180 img10_mono.pdf")) ;; 2744:196:14 ;; 3375:225:15 ;; 4096:256:16")) - (should (equal (with-text-value "m\\n8|**** TODO Learning from Data Week %(+ x 2)\\nSCHEDULED: <%(t-date \"Oct 7\" (* x 7))> DEADLINE: <%(t-date \"Oct 14\" (* x 7))>" + (should (equal (with-text-value "m\\n8|**** TODO Learning from Data Week %(+ x 2)\\nSCHEDULED: <%(date \"Oct 7\" (* x 7))> DEADLINE: <%(date \"Oct 14\" (* x 7))>" (lambda()(eval (read (tiny-mapconcat))))) "**** TODO Learning from Data Week 2 SCHEDULED: <2013-10-07 Mon> DEADLINE: <2013-10-14 Mon> @@ -142,7 +142,7 @@ SCHEDULED: <2013-11-18 Mon> DEADLINE: <2013-11-25 Mon> SCHEDULED: <2013-11-25 Mon> DEADLINE: <2013-12-02 Mon> **** TODO Learning from Data Week 10 SCHEDULED: <2013-12-02 Mon> DEADLINE: <2013-12-09 Mon>")) - (should (string= (with-text-value "m\\n4|**** TODO Classical Mechanics Week %(+ x 5)\\nSCHEDULED: <%(t-date \"Oct 15\" (* x 7))> DEADLINE: <%(t-date \"Oct 23\" (* x 7))>" + (should (string= (with-text-value "m\\n4|**** TODO Classical Mechanics Week %(+ x 5)\\nSCHEDULED: <%(date \"Oct 15\" (* x 7))> DEADLINE: <%(date \"Oct 23\" (* x 7))>" (lambda()(eval (read (tiny-mapconcat))))) "**** TODO Classical Mechanics Week 5 SCHEDULED: <2013-10-15 Tue> DEADLINE: <2013-10-23 Wed> diff --git a/tiny.el b/tiny.el index 4cd8626..2d163c7 100644 --- a/tiny.el +++ b/tiny.el @@ -64,7 +64,7 @@ ;; m1\n10listx+x96|convert img%s.jpg -monochrome -resize 50%% -rotate 180 img%c_mono.pdf ;; m1\n10listxnthxfoo-list|convert img%s.jpg -monochrome -resize 50%% -rotate 180 img%c_mono.pdf ;; m\n;; 16list*xxx)*xx%s:%s:%s -;; m\n8|**** TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(t-date "Oct 7" (* x 7))> DEADLINE: <%(t-date "Oct 14" (* x 7))> +;; m\n8|**** TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(date "Oct 7" (* x 7))> DEADLINE: <%(date "Oct 14" (* x 7))> ;; ;; As you might have guessed, the syntax is as follows: ;; m[<range start:=0>][<separator:= >]<range end>[lisp expr]|[format expr] @@ -215,7 +215,10 @@ corresponds to a `format'-style % form in STR. (incf beg (length fexp)) (destructuring-bind (sexp . end) (read-from-string str beg) - (push (substring str beg end) forms) + (push + (replace-regexp-in-string "(date" "(tiny-date" + (substring str beg end)) + forms) (setq str (concat (substring str 0 beg) (if (string= fexp "%") "s" "") (substring str end))))) @@ -367,7 +370,7 @@ Return nil if nothing was matched, otherwise (apply #'concat (nreverse out)) (make-string n-paren ?\))))))) -(defun t-date (s &optional shift) +(defun tiny-date (s &optional shift) (let ((time (apply 'encode-time (org-read-date-analyze s nil