OSDN Git Service

add option to change default for incomplete dates
authorHIRAOKA Kazuyuki <khi@users.osdn.me>
Wed, 28 Sep 2016 11:39:53 +0000 (20:39 +0900)
committerHIRAOKA Kazuyuki <khi@users.osdn.me>
Wed, 28 Sep 2016 11:39:53 +0000 (20:39 +0900)
ChangeLog
doc/README-j.html
doc/README.ja.rd
howm-common.el
howm-date.el

index 1a808cb..ecf4149 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2016-09-28  HIRAOKA Kazuyuki  <khi@users.sourceforge.jp>
+
+       * howm-date.el: extend the option howm-insert-date-future.
+       thx > Albert-san (areiner at tph.tuwien.ac.at)
+       https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html
+       (howm-action-lock-date-future): new option
+       (howm-action-lock-date): support howm-action-lock-date-future
+       (howm-datestr-expand): new value 'closer for FUTURE-P
+
+       * howm-common.el (howm-time-difference-second):
+       support (HIGH LOW) without milliseconds for howm-datestr-expand
+
 2016-04-05  HIRAOKA Kazuyuki  <khi@users.sourceforge.jp>
 
        * howm.el: modify header comments for MELPA
index 890bcf1..ab01e20 100644 (file)
@@ -1287,6 +1287,24 @@ make test</pre></li>
 <h3><a name="label-18" id="label-18">¹¹¿·µ­Ï¿</a></h3><!-- RDLabel: "¹¹¿·µ­Ï¿" -->
 <p>thx &gt; patch¡¦²þÎÉ°Æ¡¦»ØŦ¤ò¤¯¤À¤µ¤Ã¤¿³§ÍÍ</p>
 <ul>
+<li>¥¹¥Ê¥Ã¥×¥·¥ç¥Ã¥ÈÈÇ
+<ul>
+<li>[2016-09-28]
+<ul>
+<li><p>ÆüÉÕÆþÎÏ»þ¤ÎÆ°ºî¤ò³ÈÄ¥
+      <a href="https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html">thx</a>
+      &gt; Albert-san (areiner at tph.tuwien.ac.at)</p>
+<pre>;; ¡Ö[2003-12-27]¡×¾å¤Ç RET ¤·¤Æǯ¤ä·î¤òά¤·¤¿¤é¡Ä
+(setq howm-action-lock-date-future t) ;; 2003-12-27 ¤è¤ê̤Íè¤È²ò¼á
+;(setq howm-action-lock-date-future 'closer) ;; 2003-12-27 ¤Ë¶á¤¤Êý¤Ç²ò¼á</pre>
+<ul>
+<li><p>¿·µ¬ÆþÎÏ»þ¤Ë¤À¤±¤½¤¦¤¤¤¦Æ°ºî¤Ë¤·¤¿¤±¤ì¤Ð</p>
+<pre>;; ÆüÉÕÆþÎÏ(C-c , d ¤Þ¤¿¤Ï [Æü¢­])¤Çǯ¤ä·î¤òά¤·¤¿¤é¡Ä
+(setq howm-insert-date-future t) ;; ¡Ö̤Íè¡×¤È²ò¼á
+;(setq howm-insert-date-future 'closer) ;; º£Æü¤Ë¶á¤¤Êý¤Ç²ò¼á</pre></li>
+</ul></li>
+</ul></li>
+</ul></li>
 <li>¥Æ¥¹¥ÈÈÇ
 <ul>
 <li>[2016-01-01]
index df65329..7982ac5 100644 (file)
@@ -923,6 +923,20 @@ Emacs 
 
 thx > patch¡¦²þÎÉ°Æ¡¦»ØŦ¤ò¤¯¤À¤µ¤Ã¤¿³§ÍÍ
 
+
+* ¥¹¥Ê¥Ã¥×¥·¥ç¥Ã¥ÈÈÇ
+  * [2016-09-28]
+    * ÆüÉÕÆþÎÏ»þ¤ÎÆ°ºî¤ò³ÈÄ¥
+      ((<thx|URL:https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html>))
+      > Albert-san (areiner at tph.tuwien.ac.at)
+        ;; ¡Ö[2003-12-27]¡×¾å¤Ç RET ¤·¤Æǯ¤ä·î¤òά¤·¤¿¤é¡Ä
+        (setq howm-action-lock-date-future t) ;; 2003-12-27 ¤è¤ê̤Íè¤È²ò¼á
+        ;(setq howm-action-lock-date-future 'closer) ;; 2003-12-27 ¤Ë¶á¤¤Êý¤Ç²ò¼á
+      * ¿·µ¬ÆþÎÏ»þ¤Ë¤À¤±¤½¤¦¤¤¤¦Æ°ºî¤Ë¤·¤¿¤±¤ì¤Ð
+          ;; ÆüÉÕÆþÎÏ(C-c , d ¤Þ¤¿¤Ï [Æü¢­])¤Çǯ¤ä·î¤òά¤·¤¿¤é¡Ä
+          (setq howm-insert-date-future t) ;; ¡Ö̤Íè¡×¤È²ò¼á
+          ;(setq howm-insert-date-future 'closer) ;; º£Æü¤Ë¶á¤¤Êý¤Ç²ò¼á
+
 * ¥Æ¥¹¥ÈÈÇ
   * [2016-01-01]
     * ¥Ð¥¤¥È¥³¥ó¥Ñ¥¤¥ë»þ¤Î·Ù¹ð¤ò²óÈò
index b842dda..09051c1 100644 (file)
@@ -126,7 +126,7 @@ STRING should be given if the last search was by `string-match' on STRING."
 (defun howm-time-difference-second (ti1 ti0)
   (let ((h (- (car ti1) (car ti0)))
         (l (- (cadr ti1) (cadr ti0)))
-        (m (- (cl-caddr ti1) (cl-caddr ti0)))
+        (m (- (or (cl-caddr ti1) 0) (or (cl-caddr ti0) 0)))
         )
     (+ (* h 65536) l
        (* m 1e-6)
index f7fb5f3..97b7f15 100644 (file)
@@ -26,6 +26,7 @@
 ;; insert & action-lock
 
 (defvar howm-insert-date-pass-through nil)
+(defvar howm-action-lock-date-future nil)
 
 (defun howm-insert-date ()
   (interactive)
@@ -53,7 +54,8 @@
      ((string-match "^[-+][0-9]+$" c)
       (howm-action-lock-date-shift (string-to-number c) date))
      ((string-match "^[0-9]+$" c)
-      (howm-action-lock-date-set c date future-p))
+      (howm-action-lock-date-set c date
+                                 (or future-p howm-action-lock-date-future)))
      ((string-match "^~\\([0-9]+\\)$" c)
       (howm-action-lock-date-repeat (match-string-no-properties 1 c) date))
      ((string-match "^[.]$" c)
   (format-time-string "%a" (howm-datestr-to-time date)))
 
 (defun howm-datestr-expand (date base &optional future-p)
-  (if future-p
-      (howm-datestr-expand-future date base)
-    (howm-datestr-expand-general date base future-p)))
-
-(defun howm-datestr-expand-future (date base)
-  (let ((raw (howm-datestr-expand-general date base nil))
-        (future (howm-datestr-expand-general date base t)))
-    (when (not (string= raw future))
-      (message "Future date"))
-    future))
+  (let* ((raw (howm-datestr-expand-general date base nil))
+         (future (howm-datestr-expand-general date base t))
+         (ret
+          (cond ((eq future-p 'closer)
+                 (cl-labels ((to-f (d) (float-time (howm-datestr-to-time d)))
+                             (delta (d1 d2) (abs (- (to-f d1) (to-f d2)))))
+                   (if (< (delta raw base) (delta future base)) raw future)))
+                (future-p future)
+                (t raw))))
+    (unless (string= raw ret)
+      (message "Assume future date"))
+    ret))
 
 (defun howm-datestr-expand-general (date base &optional future-p)
   (let* ((base-ymd (howm-datestr-parse base))