Hitori Otegaru Wiki Modoki
Revision | 364c5be487539b16f4e879b95e27964580c59d36 (tree) |
---|---|
Time | 2016-09-28 20:39:53 |
Author | HIRAOKA Kazuyuki <khi@user...> |
Commiter | HIRAOKA Kazuyuki |
add option to change default for incomplete dates
@@ -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 | + | |
1 | 13 | 2016-04-05 HIRAOKA Kazuyuki <khi@users.sourceforge.jp> |
2 | 14 | |
3 | 15 | * howm.el: modify header comments for MELPA |
@@ -1287,6 +1287,24 @@ make test</pre></li> | ||
1287 | 1287 | <h3><a name="label-18" id="label-18">更新記録</a></h3><!-- RDLabel: "更新記録" --> |
1288 | 1288 | <p>thx > patch・改良案・指摘をくださった皆様</p> |
1289 | 1289 | <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 | + > 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> | |
1290 | 1308 | <li>テスト版 |
1291 | 1309 | <ul> |
1292 | 1310 | <li>[2016-01-01] |
@@ -923,6 +923,20 @@ Emacs | ||
923 | 923 | |
924 | 924 | thx > patch・改良案・指摘をくださった皆様 |
925 | 925 | |
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 | + | |
926 | 940 | * テスト版 |
927 | 941 | * [2016-01-01] |
928 | 942 | * バイトコンパイル時の警告を回避 |
@@ -126,7 +126,7 @@ STRING should be given if the last search was by `string-match' on STRING." | ||
126 | 126 | (defun howm-time-difference-second (ti1 ti0) |
127 | 127 | (let ((h (- (car ti1) (car ti0))) |
128 | 128 | (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))) | |
130 | 130 | ) |
131 | 131 | (+ (* h 65536) l |
132 | 132 | (* m 1e-6) |
@@ -26,6 +26,7 @@ | ||
26 | 26 | ;; insert & action-lock |
27 | 27 | |
28 | 28 | (defvar howm-insert-date-pass-through nil) |
29 | +(defvar howm-action-lock-date-future nil) | |
29 | 30 | |
30 | 31 | (defun howm-insert-date () |
31 | 32 | (interactive) |
@@ -53,7 +54,8 @@ | ||
53 | 54 | ((string-match "^[-+][0-9]+$" c) |
54 | 55 | (howm-action-lock-date-shift (string-to-number c) date)) |
55 | 56 | ((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))) | |
57 | 59 | ((string-match "^~\\([0-9]+\\)$" c) |
58 | 60 | (howm-action-lock-date-repeat (match-string-no-properties 1 c) date)) |
59 | 61 | ((string-match "^[.]$" c) |
@@ -153,16 +155,18 @@ | ||
153 | 155 | (format-time-string "%a" (howm-datestr-to-time date))) |
154 | 156 | |
155 | 157 | (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)) | |
166 | 170 | |
167 | 171 | (defun howm-datestr-expand-general (date base &optional future-p) |
168 | 172 | (let* ((base-ymd (howm-datestr-parse base)) |