• R/O
  • HTTP
  • SSH
  • HTTPS

howm: Commit

Hitori Otegaru Wiki Modoki


Commit MetaInfo

Revision364c5be487539b16f4e879b95e27964580c59d36 (tree)
Time2016-09-28 20:39:53
AuthorHIRAOKA Kazuyuki <khi@user...>
CommiterHIRAOKA Kazuyuki

Log Message

add option to change default for incomplete dates

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
1+2016-09-28 HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
2+
3+ * howm-date.el: extend the option howm-insert-date-future.
4+ thx > Albert-san (areiner at tph.tuwien.ac.at)
5+ https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html
6+ (howm-action-lock-date-future): new option
7+ (howm-action-lock-date): support howm-action-lock-date-future
8+ (howm-datestr-expand): new value 'closer for FUTURE-P
9+
10+ * howm-common.el (howm-time-difference-second):
11+ support (HIGH LOW) without milliseconds for howm-datestr-expand
12+
113 2016-04-05 HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
214
315 * howm.el: modify header comments for MELPA
--- a/doc/README-j.html
+++ b/doc/README-j.html
@@ -1287,6 +1287,24 @@ make test</pre></li>
12871287 <h3><a name="label-18" id="label-18">更新記録</a></h3><!-- RDLabel: "更新記録" -->
12881288 <p>thx &gt; patch・改良案・指摘をくださった皆様</p>
12891289 <ul>
1290+<li>スナップショット版
1291+<ul>
1292+<li>[2016-09-28]
1293+<ul>
1294+<li><p>日付入力時の動作を拡張
1295+ <a href="https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html">thx</a>
1296+ &gt; Albert-san (areiner at tph.tuwien.ac.at)</p>
1297+<pre>;; 「[2003-12-27]」上で RET して年や月を略したら…
1298+(setq howm-action-lock-date-future t) ;; 2003-12-27 より未来と解釈
1299+;(setq howm-action-lock-date-future 'closer) ;; 2003-12-27 に近い方で解釈</pre>
1300+<ul>
1301+<li><p>新規入力時にだけそういう動作にしたければ</p>
1302+<pre>;; 日付入力(C-c , d または [日↓])で年や月を略したら…
1303+(setq howm-insert-date-future t) ;; 「未来」と解釈
1304+;(setq howm-insert-date-future 'closer) ;; 今日に近い方で解釈</pre></li>
1305+</ul></li>
1306+</ul></li>
1307+</ul></li>
12901308 <li>テスト版
12911309 <ul>
12921310 <li>[2016-01-01]
--- a/doc/README.ja.rd
+++ b/doc/README.ja.rd
@@ -923,6 +923,20 @@ Emacs
923923
924924 thx > patch・改良案・指摘をくださった皆様
925925
926+
927+* スナップショット版
928+ * [2016-09-28]
929+ * 日付入力時の動作を拡張
930+ ((<thx|URL:https://osdn.jp/projects/howm/lists/archive/eng/2016/000118.html>))
931+ > Albert-san (areiner at tph.tuwien.ac.at)
932+ ;; 「[2003-12-27]」上で RET して年や月を略したら…
933+ (setq howm-action-lock-date-future t) ;; 2003-12-27 より未来と解釈
934+ ;(setq howm-action-lock-date-future 'closer) ;; 2003-12-27 に近い方で解釈
935+ * 新規入力時にだけそういう動作にしたければ
936+ ;; 日付入力(C-c , d または [日↓])で年や月を略したら…
937+ (setq howm-insert-date-future t) ;; 「未来」と解釈
938+ ;(setq howm-insert-date-future 'closer) ;; 今日に近い方で解釈
939+
926940 * テスト版
927941 * [2016-01-01]
928942 * バイトコンパイル時の警告を回避
--- a/howm-common.el
+++ b/howm-common.el
@@ -126,7 +126,7 @@ STRING should be given if the last search was by `string-match' on STRING."
126126 (defun howm-time-difference-second (ti1 ti0)
127127 (let ((h (- (car ti1) (car ti0)))
128128 (l (- (cadr ti1) (cadr ti0)))
129- (m (- (cl-caddr ti1) (cl-caddr ti0)))
129+ (m (- (or (cl-caddr ti1) 0) (or (cl-caddr ti0) 0)))
130130 )
131131 (+ (* h 65536) l
132132 (* m 1e-6)
--- a/howm-date.el
+++ b/howm-date.el
@@ -26,6 +26,7 @@
2626 ;; insert & action-lock
2727
2828 (defvar howm-insert-date-pass-through nil)
29+(defvar howm-action-lock-date-future nil)
2930
3031 (defun howm-insert-date ()
3132 (interactive)
@@ -53,7 +54,8 @@
5354 ((string-match "^[-+][0-9]+$" c)
5455 (howm-action-lock-date-shift (string-to-number c) date))
5556 ((string-match "^[0-9]+$" c)
56- (howm-action-lock-date-set c date future-p))
57+ (howm-action-lock-date-set c date
58+ (or future-p howm-action-lock-date-future)))
5759 ((string-match "^~\\([0-9]+\\)$" c)
5860 (howm-action-lock-date-repeat (match-string-no-properties 1 c) date))
5961 ((string-match "^[.]$" c)
@@ -153,16 +155,18 @@
153155 (format-time-string "%a" (howm-datestr-to-time date)))
154156
155157 (defun howm-datestr-expand (date base &optional future-p)
156- (if future-p
157- (howm-datestr-expand-future date base)
158- (howm-datestr-expand-general date base future-p)))
159-
160-(defun howm-datestr-expand-future (date base)
161- (let ((raw (howm-datestr-expand-general date base nil))
162- (future (howm-datestr-expand-general date base t)))
163- (when (not (string= raw future))
164- (message "Future date"))
165- future))
158+ (let* ((raw (howm-datestr-expand-general date base nil))
159+ (future (howm-datestr-expand-general date base t))
160+ (ret
161+ (cond ((eq future-p 'closer)
162+ (cl-labels ((to-f (d) (float-time (howm-datestr-to-time d)))
163+ (delta (d1 d2) (abs (- (to-f d1) (to-f d2)))))
164+ (if (< (delta raw base) (delta future base)) raw future)))
165+ (future-p future)
166+ (t raw))))
167+ (unless (string= raw ret)
168+ (message "Assume future date"))
169+ ret))
166170
167171 (defun howm-datestr-expand-general (date base &optional future-p)
168172 (let* ((base-ymd (howm-datestr-parse base))
Show on old repository browser