]> code.delx.au - gnu-emacs-elpa/commitdiff
tiny.el (tiny-date): renamed from t-date. In format string it's just "date"
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 28 Oct 2013 11:59:00 +0000 (12:59 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 28 Oct 2013 11:59:00 +0000 (12:59 +0100)
test/tiny-test.el (tiny-mapconcat): modified test

README.md
tiny-test.el
tiny.el

index 48273ab1395dff6cb9d12b6c0cee02227195aacd..e0fade8438713fd8f123171c37c9583827261544 100644 (file)
--- 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>
index e959345ee529d2e4d612c58f5ae53bc2fb70c8a2..adcd43e27cfc0b2da26759e7ff701d3aace7d74b 100644 (file)
@@ -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 4cd862648ed94374b4022d591212eb063eca26e6..2d163c745e2bdccb023c0510c0eb1087c6578d73 100644 (file)
--- 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