mhc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/COPYRIGHT +28 -0
- data/Gemfile +8 -0
- data/README.org +209 -0
- data/Rakefile +13 -0
- data/bin/mhc +312 -0
- data/emacs/Cask +25 -0
- data/emacs/Makefile +58 -0
- data/emacs/mhc-calendar.el +1723 -0
- data/emacs/mhc-calfw.el +135 -0
- data/emacs/mhc-compat.el +90 -0
- data/emacs/mhc-date.el +642 -0
- data/emacs/mhc-day.el +149 -0
- data/emacs/mhc-db.el +158 -0
- data/emacs/mhc-draft.el +211 -0
- data/emacs/mhc-e21.el +167 -0
- data/emacs/mhc-face.el +236 -0
- data/emacs/mhc-file.el +224 -0
- data/emacs/mhc-guess.el +648 -0
- data/emacs/mhc-header.el +176 -0
- data/emacs/mhc-logic.el +563 -0
- data/emacs/mhc-message.el +130 -0
- data/emacs/mhc-minibuf.el +466 -0
- data/emacs/mhc-misc.el +248 -0
- data/emacs/mhc-mua.el +260 -0
- data/emacs/mhc-parse.el +286 -0
- data/emacs/mhc-process.el +35 -0
- data/emacs/mhc-ps.el +1174 -0
- data/emacs/mhc-record.el +201 -0
- data/emacs/mhc-schedule.el +202 -0
- data/emacs/mhc-summary.el +763 -0
- data/emacs/mhc-sync.el +158 -0
- data/emacs/mhc-vars.el +149 -0
- data/emacs/mhc.el +1114 -0
- data/icons/Anniversary.xbm +6 -0
- data/icons/Anniversary.xpm +27 -0
- data/icons/Birthday.xbm +6 -0
- data/icons/Birthday.xpm +25 -0
- data/icons/Business.xbm +6 -0
- data/icons/Business.xpm +24 -0
- data/icons/CheckBox.xbm +6 -0
- data/icons/CheckBox.xpm +24 -0
- data/icons/CheckedBox.xbm +6 -0
- data/icons/CheckedBox.xpm +25 -0
- data/icons/Conflict.xbm +6 -0
- data/icons/Conflict.xpm +22 -0
- data/icons/Date.xbm +6 -0
- data/icons/Date.xpm +29 -0
- data/icons/Holiday.xbm +6 -0
- data/icons/Holiday.xpm +25 -0
- data/icons/Link.xbm +6 -0
- data/icons/Link.xpm +25 -0
- data/icons/Other.xbm +6 -0
- data/icons/Other.xpm +28 -0
- data/icons/Party.xbm +6 -0
- data/icons/Party.xpm +23 -0
- data/icons/Private.xbm +6 -0
- data/icons/Private.xpm +26 -0
- data/icons/Recurrence.xbm +6 -0
- data/icons/Recurrence.xpm +98 -0
- data/icons/Vacation.xbm +6 -0
- data/icons/Vacation.xpm +26 -0
- data/lib/mhc.rb +45 -0
- data/lib/mhc/builder.rb +64 -0
- data/lib/mhc/caldav.rb +304 -0
- data/lib/mhc/calendar.rb +106 -0
- data/lib/mhc/command.rb +13 -0
- data/lib/mhc/command/cache.rb +14 -0
- data/lib/mhc/command/completions.rb +108 -0
- data/lib/mhc/command/init.rb +133 -0
- data/lib/mhc/command/scan.rb +33 -0
- data/lib/mhc/command/sync.rb +22 -0
- data/lib/mhc/config.rb +229 -0
- data/lib/mhc/converter.rb +330 -0
- data/lib/mhc/datastore.rb +164 -0
- data/lib/mhc/date_enumerator.rb +274 -0
- data/lib/mhc/date_frame.rb +124 -0
- data/lib/mhc/date_helper.rb +49 -0
- data/lib/mhc/etag.rb +68 -0
- data/lib/mhc/event.rb +396 -0
- data/lib/mhc/formatter.rb +312 -0
- data/lib/mhc/logger.rb +94 -0
- data/lib/mhc/modifier.rb +149 -0
- data/lib/mhc/occurrence.rb +94 -0
- data/lib/mhc/occurrence_enumerator.rb +113 -0
- data/lib/mhc/property_value.rb +33 -0
- data/lib/mhc/property_value/date.rb +190 -0
- data/lib/mhc/property_value/integer.rb +15 -0
- data/lib/mhc/property_value/list.rb +41 -0
- data/lib/mhc/property_value/period.rb +49 -0
- data/lib/mhc/property_value/range.rb +100 -0
- data/lib/mhc/property_value/recurrence_condition.rb +272 -0
- data/lib/mhc/property_value/text.rb +11 -0
- data/lib/mhc/property_value/time.rb +45 -0
- data/lib/mhc/query.rb +210 -0
- data/lib/mhc/sync.rb +46 -0
- data/lib/mhc/sync/driver.rb +108 -0
- data/lib/mhc/sync/status.rb +70 -0
- data/lib/mhc/sync/status_manager.rb +142 -0
- data/lib/mhc/sync/strategy.rb +233 -0
- data/lib/mhc/sync/syncinfo.rb +98 -0
- data/lib/mhc/templates/config.yml.erb +142 -0
- data/lib/mhc/version.rb +4 -0
- data/lib/mhc/webdav.rb +319 -0
- data/mhc.gemspec +24 -0
- data/samples/DOT.mhc-config.yml +116 -0
- data/samples/japanese-holidays.mhcc +153 -0
- data/samples/mhc-completions.zsh +11 -0
- data/spec/mhc_spec.rb +682 -0
- data/spec/spec_helper.rb +9 -0
- data/xpm/close.xpm +18 -0
- data/xpm/delete.xpm +19 -0
- data/xpm/exit.xpm +18 -0
- data/xpm/month.xpm +18 -0
- data/xpm/next.xpm +18 -0
- data/xpm/next2.xpm +18 -0
- data/xpm/next_year.xpm +18 -0
- data/xpm/open.xpm +19 -0
- data/xpm/prev.xpm +18 -0
- data/xpm/prev2.xpm +18 -0
- data/xpm/prev_year.xpm +18 -0
- data/xpm/save.xpm +19 -0
- data/xpm/today.xpm +18 -0
- metadata +214 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
;;; mhc-message.el --- Message major mode in MHC.
|
2
|
+
|
3
|
+
;; Copyright (C) 2014 MHC development team.
|
4
|
+
|
5
|
+
;; Author: Yoshinari Nomura <nom@quickhack.net>
|
6
|
+
;; Keywords: calendar
|
7
|
+
|
8
|
+
;; This file is NOT part of GNU Emacs.
|
9
|
+
|
10
|
+
;;; License:
|
11
|
+
|
12
|
+
;; You can redistribute it and/or modify it under the terms of
|
13
|
+
;; The BSD 3-Clause License. You can check the details from:
|
14
|
+
;; https://github.com/yoshinari-nomura/mhc/blob/master/COPYRIGHT
|
15
|
+
|
16
|
+
;;; Commentary:
|
17
|
+
|
18
|
+
;; This file is a part of MHC. mhc-message major mode in MHC.
|
19
|
+
|
20
|
+
;;; Code:
|
21
|
+
|
22
|
+
(defcustom mhc-message-mode-hook nil
|
23
|
+
"*Hook run in mhc message mode buffers."
|
24
|
+
:group 'mhc
|
25
|
+
:type 'hook)
|
26
|
+
|
27
|
+
(defvar mhc-message-mode-map nil)
|
28
|
+
(setq mhc-message-mode-map (make-sparse-keymap))
|
29
|
+
(define-key mhc-message-mode-map " " 'mhc-message-scroll-page-forward)
|
30
|
+
|
31
|
+
(defvar mhc-message-end-of-messge-marker "[End of message]")
|
32
|
+
|
33
|
+
(define-derived-mode mhc-message-mode
|
34
|
+
text-mode
|
35
|
+
"MHC-Msg"
|
36
|
+
"Major mode for viewing schdule files of MHC."
|
37
|
+
(save-excursion
|
38
|
+
(mhc-decode-header)
|
39
|
+
(goto-char (point-max))
|
40
|
+
(unless (re-search-backward
|
41
|
+
(regexp-quote mhc-message-end-of-messge-marker)
|
42
|
+
(- (point) (length mhc-message-end-of-messge-marker))
|
43
|
+
t)
|
44
|
+
(unless (bolp) (insert "\n"))
|
45
|
+
(insert mhc-message-end-of-messge-marker))
|
46
|
+
(mhc-highlight-message))
|
47
|
+
;; (setq mhc-message-mode-called-count (1+ mhc-message-mode-called-count))
|
48
|
+
;; (message "mhc-message-mode-called-count: %d" mhc-message-mode-called-count)
|
49
|
+
;; )
|
50
|
+
;; (set (make-local-variable 'scroll-error-top-bottom) t)
|
51
|
+
;; (run-hooks 'mhc-message-mode-hook)
|
52
|
+
)
|
53
|
+
|
54
|
+
;; user interface
|
55
|
+
|
56
|
+
(defun mhc-message-scroll-page-forward (&optional lines)
|
57
|
+
"Scroll text of selected MHC message window upward LINES.
|
58
|
+
If LINES is omitted or nil, scroll upward by a near full screen."
|
59
|
+
(interactive)
|
60
|
+
(unless (ignore-errors (scroll-up lines) t)
|
61
|
+
(message "End of buffer")))
|
62
|
+
|
63
|
+
(defun mhc-message-scroll-page-backward (&optional lines)
|
64
|
+
"Scroll text of selected MHC message window down LINES.
|
65
|
+
If LINES is omitted or nil, scroll down by a near full screen."
|
66
|
+
(interactive)
|
67
|
+
(unless (ignore-errors (scroll-down lines) t)
|
68
|
+
(message "Beginning of buffer")))
|
69
|
+
|
70
|
+
;; file signature
|
71
|
+
|
72
|
+
(defvar mhc-message-current-signature nil)
|
73
|
+
(make-variable-buffer-local 'mhc-message-cache-signature)
|
74
|
+
|
75
|
+
(defun mhc-message-file-signature (file-name)
|
76
|
+
(let ((file-path (and (stringp file-name)
|
77
|
+
(expand-file-name file-name))))
|
78
|
+
(and file-path
|
79
|
+
(file-exists-p file-path)
|
80
|
+
(cons file-path
|
81
|
+
(nth 5 (file-attributes file-path))))))
|
82
|
+
|
83
|
+
(defun mhc-message-update-signature (file-name)
|
84
|
+
(let ((file-signature (mhc-message-file-signature file-name)))
|
85
|
+
(if (equal mhc-message-current-signature file-signature)
|
86
|
+
nil ;; not updated
|
87
|
+
(setq mhc-message-current-signature file-signature)
|
88
|
+
t ;; updated
|
89
|
+
)))
|
90
|
+
|
91
|
+
;; message setup and update
|
92
|
+
|
93
|
+
(defun mhc-message-create (buffer-or-name &optional file-name)
|
94
|
+
"Create the mhc-message-mode buffer specified by BUFFER-OR-NAME.
|
95
|
+
This is similar to `get-buffer-create'.
|
96
|
+
If FILE-NAME is non-nil, the buffer is filled with the content of FILE-NAME."
|
97
|
+
(let ((buf (get-buffer-create buffer-or-name)))
|
98
|
+
(with-current-buffer buf
|
99
|
+
(mhc-message-clear)
|
100
|
+
(if file-name (mhc-message-update file-name))
|
101
|
+
(mhc-message-mode)
|
102
|
+
(set-buffer-modified-p nil))
|
103
|
+
buf))
|
104
|
+
|
105
|
+
(defun mhc-message-update (file-name &optional buffer-or-name)
|
106
|
+
"Replace buffer content by FILE-NAME in BUFFER-OR-NAME."
|
107
|
+
(let ((buf (or buffer-or-name (current-buffer))))
|
108
|
+
(with-current-buffer buf
|
109
|
+
(when (mhc-message-update-signature file-name)
|
110
|
+
(mhc-message-clear)
|
111
|
+
(mhc-insert-file-contents-as-coding-system
|
112
|
+
mhc-default-coding-system file-name)))
|
113
|
+
buf))
|
114
|
+
|
115
|
+
(defun mhc-message-clear (&optional buffer-or-name)
|
116
|
+
"Clear current buffer content.
|
117
|
+
If BUFFER-OR-NAME is specified, clear the content of BUFFER-OR-NAME.
|
118
|
+
Returns the designated buffer."
|
119
|
+
(let ((buf (or buffer-or-name (current-buffer))))
|
120
|
+
(with-current-buffer buf
|
121
|
+
(setq buffer-read-only nil
|
122
|
+
inhibit-read-only t)
|
123
|
+
(set-visited-file-name nil)
|
124
|
+
(goto-char (point-min))
|
125
|
+
(erase-buffer))
|
126
|
+
buf))
|
127
|
+
|
128
|
+
(provide 'mhc-message)
|
129
|
+
|
130
|
+
;;; mhc-message.el ends here
|
@@ -0,0 +1,466 @@
|
|
1
|
+
;;; mhc-minibuf.el
|
2
|
+
|
3
|
+
;; Author: Yoshinari Nomura <nom@quickhack.net>
|
4
|
+
;;
|
5
|
+
;; Created: 1999/12/10
|
6
|
+
;; Revised: $Date: 2004/09/08 09:12:10 $
|
7
|
+
|
8
|
+
;;;
|
9
|
+
;;; Commentay:
|
10
|
+
;;;
|
11
|
+
|
12
|
+
;;;
|
13
|
+
;;; Code:
|
14
|
+
;;;
|
15
|
+
|
16
|
+
(defvar mhc-minibuf-candidate-to-s-func nil)
|
17
|
+
(defvar mhc-minibuf-candidate-alist nil)
|
18
|
+
(defvar mhc-minibuf-candidate-offset 0)
|
19
|
+
(defvar mhc-minibuf-candidate-overlay nil)
|
20
|
+
(defvar mhc-minibuf-candidate-buffer nil)
|
21
|
+
(defvar mhc-minibuf-candidate-delimiter nil)
|
22
|
+
|
23
|
+
;; (make-variable-buffer-local 'mhc-minibuf-candidate-to-s-func)
|
24
|
+
;; (make-variable-buffer-local 'mhc-minibuf-candidate-alist)
|
25
|
+
;; (make-variable-buffer-local 'mhc-minibuf-candidate-offset)
|
26
|
+
;; (make-variable-buffer-local 'mhc-minibuf-candidate-overlay)
|
27
|
+
;; (make-variable-buffer-local 'mhc-minibuf-candidate-buffer)
|
28
|
+
|
29
|
+
(defun mhc-minibuf-read (&optional prompt default
|
30
|
+
buffer cand offset to-s delimiter)
|
31
|
+
(if mhc-minibuf-candidate-overlay
|
32
|
+
(delete-overlay mhc-minibuf-candidate-overlay))
|
33
|
+
(setq mhc-minibuf-candidate-buffer buffer
|
34
|
+
mhc-minibuf-candidate-alist cand
|
35
|
+
mhc-minibuf-candidate-offset (or offset 0)
|
36
|
+
mhc-minibuf-candidate-to-s-func to-s
|
37
|
+
mhc-minibuf-candidate-delimiter delimiter)
|
38
|
+
(if cand
|
39
|
+
(progn
|
40
|
+
(setq mhc-minibuf-candidate-overlay
|
41
|
+
(make-overlay
|
42
|
+
(mhc-minibuf-candidate-nth-begin)
|
43
|
+
(mhc-minibuf-candidate-nth-end)
|
44
|
+
buffer))
|
45
|
+
(overlay-put mhc-minibuf-candidate-overlay 'face
|
46
|
+
'mhc-minibuf-face-candidate)
|
47
|
+
(mhc-minibuf-move-candidate 0 t t)))
|
48
|
+
(read-from-minibuffer
|
49
|
+
prompt
|
50
|
+
(cond
|
51
|
+
(default default)
|
52
|
+
((and to-s (mhc-minibuf-candidate-nth-obj)
|
53
|
+
(funcall to-s (mhc-minibuf-candidate-nth-obj))))
|
54
|
+
(t ""))
|
55
|
+
mhc-minibuf-map))
|
56
|
+
|
57
|
+
;; access methods to candidate-alist
|
58
|
+
;;
|
59
|
+
;; candidate-alist is like:
|
60
|
+
;; ((score (begin . end) obj) ...)
|
61
|
+
;;
|
62
|
+
|
63
|
+
(defun mhc-minibuf/get-nth-candidate (&optional alist n)
|
64
|
+
(nth (or n mhc-minibuf-candidate-offset)
|
65
|
+
(or alist mhc-minibuf-candidate-alist)))
|
66
|
+
|
67
|
+
(defun mhc-minibuf-candidate-nth-score (&optional alist n)
|
68
|
+
(let ((candidate (mhc-minibuf/get-nth-candidate alist n)))
|
69
|
+
(if candidate (mhc-guess-get-score candidate))))
|
70
|
+
|
71
|
+
(defun mhc-minibuf-candidate-nth-begin (&optional alist n)
|
72
|
+
(let ((candidate (mhc-minibuf/get-nth-candidate alist n)))
|
73
|
+
(if candidate (mhc-guess-get-begin candidate))))
|
74
|
+
|
75
|
+
(defun mhc-minibuf-candidate-nth-end (&optional alist n)
|
76
|
+
(let ((candidate (mhc-minibuf/get-nth-candidate alist n)))
|
77
|
+
(if candidate (mhc-guess-get-end candidate))))
|
78
|
+
|
79
|
+
(defun mhc-minibuf-candidate-nth-obj (&optional alist n)
|
80
|
+
(let ((candidate (mhc-minibuf/get-nth-candidate alist n)))
|
81
|
+
(if candidate (cons
|
82
|
+
(mhc-guess-get-date-or-time candidate)
|
83
|
+
(mhc-guess-get-date-or-time-end candidate)))))
|
84
|
+
|
85
|
+
;;
|
86
|
+
;; move candidate by score.
|
87
|
+
;;
|
88
|
+
(defun mhc-minibuf-candidate-inc-offset2 (&optional n)
|
89
|
+
(let ((len (length mhc-minibuf-candidate-alist)))
|
90
|
+
(if (< 0 len)
|
91
|
+
(setq mhc-minibuf-candidate-offset
|
92
|
+
(%
|
93
|
+
(+ len (% (+ mhc-minibuf-candidate-offset (or n 1)) len))
|
94
|
+
len)))))
|
95
|
+
|
96
|
+
;;
|
97
|
+
;; move candidate by position.
|
98
|
+
;; xxx: offset is 1 or -1 only.
|
99
|
+
;;
|
100
|
+
(defun mhc-minibuf-candidate-inc-offset (&optional n)
|
101
|
+
(let* ((len (length mhc-minibuf-candidate-alist))
|
102
|
+
(cur (mhc-minibuf-candidate-nth-begin))
|
103
|
+
(max cur)
|
104
|
+
(min cur)
|
105
|
+
(max-i mhc-minibuf-candidate-offset)
|
106
|
+
(min-i mhc-minibuf-candidate-offset)
|
107
|
+
(i 0)
|
108
|
+
nxt prv ptr prv-i nxt-i)
|
109
|
+
(while (< i len)
|
110
|
+
(setq ptr (mhc-minibuf-candidate-nth-begin
|
111
|
+
mhc-minibuf-candidate-alist i))
|
112
|
+
(if (< max ptr) (setq max ptr max-i i))
|
113
|
+
(if (< ptr min) (setq min ptr min-i i))
|
114
|
+
(if (and (< cur ptr) (or (null nxt) (< ptr nxt)))
|
115
|
+
(setq nxt ptr nxt-i i))
|
116
|
+
(if (and (< ptr cur) (or (null prv) (< prv ptr)))
|
117
|
+
(setq prv ptr prv-i i))
|
118
|
+
(setq i (1+ i)))
|
119
|
+
(if (< 0 n)
|
120
|
+
(setq mhc-minibuf-candidate-offset (if nxt-i nxt-i min-i))
|
121
|
+
(setq mhc-minibuf-candidate-offset (if prv-i prv-i max-i)))))
|
122
|
+
|
123
|
+
|
124
|
+
(defun mhc-minibuf-candidate-set-offset (n)
|
125
|
+
(setq mhc-minibuf-candidate-offset n))
|
126
|
+
|
127
|
+
;;
|
128
|
+
;; keybind
|
129
|
+
;;
|
130
|
+
|
131
|
+
(defvar mhc-minibuf-map nil)
|
132
|
+
;; (setq mhc-minibuf-map nil)
|
133
|
+
|
134
|
+
(if mhc-minibuf-map
|
135
|
+
()
|
136
|
+
(setq mhc-minibuf-map (copy-keymap minibuffer-local-map))
|
137
|
+
(define-key mhc-minibuf-map "\C-c?" 'mhc-minibuf-insert-calendar)
|
138
|
+
(define-key mhc-minibuf-map "\C-n" 'mhc-minibuf-next-candidate)
|
139
|
+
(define-key mhc-minibuf-map "\C-p" 'mhc-minibuf-prev-candidate)
|
140
|
+
(define-key mhc-minibuf-map "\C-v" 'scroll-other-window)
|
141
|
+
(define-key mhc-minibuf-map "\M-v" 'scroll-other-window-down))
|
142
|
+
|
143
|
+
;;
|
144
|
+
;; minibuffer functions
|
145
|
+
;;
|
146
|
+
|
147
|
+
;; (defun mhc-minibuf-delete-word ()
|
148
|
+
;; (delete-region
|
149
|
+
;; (save-excursion
|
150
|
+
;; (while (and (not (bobp))
|
151
|
+
;; (string-match "[0-9:/-]"
|
152
|
+
;; (buffer-substring
|
153
|
+
;; (1- (point)) (point))))
|
154
|
+
;; (forward-char -1))
|
155
|
+
;; (point))
|
156
|
+
;; (point)))
|
157
|
+
|
158
|
+
(defun mhc-minibuf-delete-word (&optional delimiter)
|
159
|
+
(delete-region
|
160
|
+
(save-excursion
|
161
|
+
(while (and (not (bobp))
|
162
|
+
(string-match (or delimiter "[0-9:/-]")
|
163
|
+
(buffer-substring
|
164
|
+
(1- (point)) (point))))
|
165
|
+
(forward-char -1))
|
166
|
+
(point))
|
167
|
+
(point)))
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
(defun mhc-minibuf-move-candidate (offset &optional absolute non-minibuf)
|
172
|
+
(if (not mhc-minibuf-candidate-alist)
|
173
|
+
()
|
174
|
+
(if absolute
|
175
|
+
(mhc-minibuf-candidate-set-offset offset)
|
176
|
+
(mhc-minibuf-candidate-inc-offset offset))
|
177
|
+
;; (y-or-n-p (format "%d" mhc-minibuf-candidate-offset))
|
178
|
+
(let* ((b (mhc-minibuf-candidate-nth-begin))
|
179
|
+
(e (mhc-minibuf-candidate-nth-end))
|
180
|
+
(obj (mhc-minibuf-candidate-nth-obj))
|
181
|
+
(str (if (and mhc-minibuf-candidate-to-s-func obj)
|
182
|
+
(funcall mhc-minibuf-candidate-to-s-func obj) "")))
|
183
|
+
(if (not (and mhc-minibuf-candidate-overlay b))
|
184
|
+
()
|
185
|
+
(move-overlay mhc-minibuf-candidate-overlay b e)
|
186
|
+
(if (not non-minibuf)
|
187
|
+
(pop-to-buffer mhc-minibuf-candidate-buffer))
|
188
|
+
(goto-char b)
|
189
|
+
(if (not (pos-visible-in-window-p b))
|
190
|
+
(recenter))
|
191
|
+
(if (not non-minibuf)
|
192
|
+
(pop-to-buffer (window-buffer (minibuffer-window))))
|
193
|
+
;; in minibuffer
|
194
|
+
(if non-minibuf
|
195
|
+
()
|
196
|
+
;; (if (string-match "-" str)
|
197
|
+
;; (delete-region (point-min) (point-max))
|
198
|
+
;; (mhc-minibuf-delete-word))
|
199
|
+
(mhc-minibuf-delete-word
|
200
|
+
mhc-minibuf-candidate-delimiter)
|
201
|
+
(insert str))))))
|
202
|
+
|
203
|
+
(defun mhc-minibuf-next-candidate ()
|
204
|
+
(interactive)
|
205
|
+
(mhc-minibuf-move-candidate 1))
|
206
|
+
|
207
|
+
(defun mhc-minibuf-prev-candidate ()
|
208
|
+
(interactive)
|
209
|
+
(mhc-minibuf-move-candidate -1))
|
210
|
+
|
211
|
+
;;
|
212
|
+
;; input functions for mhc.
|
213
|
+
;;
|
214
|
+
|
215
|
+
(defun mhc-minibuf/date-to-string (date-cons)
|
216
|
+
(let ((date (car date-cons))
|
217
|
+
(date2 (cdr date-cons)))
|
218
|
+
(concat
|
219
|
+
(mhc-date-format date "%04d/%02d/%02d" yy mm dd)
|
220
|
+
(if date2
|
221
|
+
(mhc-date-format date2 "-%04d/%02d/%02d" yy mm dd)
|
222
|
+
""))))
|
223
|
+
|
224
|
+
(defun mhc-minibuf/time-to-string (time-cons)
|
225
|
+
(let ((time (car time-cons))
|
226
|
+
(time2 (cdr time-cons)))
|
227
|
+
(if time2
|
228
|
+
(concat
|
229
|
+
(mhc-time-to-string time) "-" (mhc-time-to-string time2))
|
230
|
+
(mhc-time-to-string time))))
|
231
|
+
|
232
|
+
(defun mhc-minibuf/location-to-string (location-cons)
|
233
|
+
(let ((loc (car location-cons))
|
234
|
+
(loc2 (cdr location-cons)))
|
235
|
+
(if loc2
|
236
|
+
(concat
|
237
|
+
(format "%s" loc) "-" (format "%s" loc2))
|
238
|
+
(format "%s" loc))))
|
239
|
+
|
240
|
+
(defun mhc-input-day (&optional prompt default candidate)
|
241
|
+
(interactive)
|
242
|
+
(let (str-list date ret (error t) str)
|
243
|
+
(while error
|
244
|
+
(setq str
|
245
|
+
(mhc-minibuf-read
|
246
|
+
(concat (or prompt "") "(yyyy/mm/dd): ")
|
247
|
+
(if candidate
|
248
|
+
nil
|
249
|
+
(cond
|
250
|
+
((and (stringp default)
|
251
|
+
(mhc-date-new-from-string default t))
|
252
|
+
default)
|
253
|
+
((mhc-date-p default)
|
254
|
+
(mhc-date-format default
|
255
|
+
"%04d/%02d/%02d" yy mm dd))
|
256
|
+
((listp default)
|
257
|
+
(mapconcat
|
258
|
+
(lambda (date)
|
259
|
+
(mhc-date-format date
|
260
|
+
"%04d/%02d/%02d" yy mm dd))
|
261
|
+
default
|
262
|
+
" "))
|
263
|
+
(t
|
264
|
+
nil)))
|
265
|
+
(current-buffer)
|
266
|
+
candidate
|
267
|
+
0
|
268
|
+
(function mhc-minibuf/date-to-string))
|
269
|
+
str-list (mhc-misc-split str)
|
270
|
+
ret nil
|
271
|
+
error nil)
|
272
|
+
(while (car str-list)
|
273
|
+
(cond
|
274
|
+
((= 2 (length (mhc-misc-split (car str-list) "-")))
|
275
|
+
(let* ((duration (mhc-misc-split (car str-list) "-"))
|
276
|
+
(b (mhc-date-new-from-string2 (nth 0 duration) nil t))
|
277
|
+
(e (mhc-date-new-from-string2 (nth 1 duration) b t)))
|
278
|
+
(if (and b e (mhc-date< b e))
|
279
|
+
(progn
|
280
|
+
(setq date b)
|
281
|
+
(while (mhc-date<= date e)
|
282
|
+
(if (not (member date ret))
|
283
|
+
(setq ret (cons date ret))
|
284
|
+
(setq error t))
|
285
|
+
(setq date (mhc-date++ date))))
|
286
|
+
(setq error t))))
|
287
|
+
((string= (car str-list) "")
|
288
|
+
())
|
289
|
+
((setq date (mhc-date-new-from-string2 (car str-list) date t))
|
290
|
+
(if (not (member date ret))
|
291
|
+
(setq ret (cons date ret))
|
292
|
+
(setq error t)))
|
293
|
+
((string= (car str-list) "none")
|
294
|
+
())
|
295
|
+
(t
|
296
|
+
(setq error t)))
|
297
|
+
(setq str-list (cdr str-list)))
|
298
|
+
(if error (beep)))
|
299
|
+
(mhc-calendar-input-exit)
|
300
|
+
(mhc-date-sort ret)))
|
301
|
+
|
302
|
+
(defun mhc-input-time (&optional prompt default candidate)
|
303
|
+
(interactive)
|
304
|
+
(let (str time-b time-e)
|
305
|
+
(catch 'ok
|
306
|
+
(while t
|
307
|
+
(setq str (mhc-minibuf-read
|
308
|
+
(concat (or prompt "") "(HH:MM-HH:MM or none) ")
|
309
|
+
(if candidate
|
310
|
+
nil
|
311
|
+
(if default
|
312
|
+
(if (stringp default) default
|
313
|
+
(mhc-minibuf/time-to-string default) "")))
|
314
|
+
(current-buffer)
|
315
|
+
candidate
|
316
|
+
0
|
317
|
+
(function mhc-minibuf/time-to-string)))
|
318
|
+
(cond
|
319
|
+
((and (string-match
|
320
|
+
"^\\([0-9]+:[0-9]+\\)\\(-\\([0-9]+:[0-9]+\\)\\)?$" str)
|
321
|
+
(setq time-b (mhc-time-new-from-string
|
322
|
+
(substring str (match-beginning 1) (match-end 1))
|
323
|
+
t mhc-input-time-regex)))
|
324
|
+
(if (not (match-beginning 3)) (throw 'ok (list time-b nil)))
|
325
|
+
(if (and (setq time-e
|
326
|
+
(mhc-time-new-from-string
|
327
|
+
(substring str (match-beginning 3) (match-end 3))
|
328
|
+
t mhc-input-time-regex))
|
329
|
+
(mhc-time<= time-b time-e))
|
330
|
+
(throw 'ok (list time-b time-e))))
|
331
|
+
((string= "" str)
|
332
|
+
(throw 'ok (list nil nil))))
|
333
|
+
(beep)))))
|
334
|
+
|
335
|
+
|
336
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
337
|
+
;; input x-sc- schedule data from minibuffer.
|
338
|
+
|
339
|
+
|
340
|
+
(defvar mhc-month-hist nil)
|
341
|
+
|
342
|
+
(defun mhc-input-month (prompt &optional default)
|
343
|
+
(let ((ret nil)
|
344
|
+
(month-str (mhc-date-format (or default (mhc-date-now)) "%04d/%02d" yy mm)))
|
345
|
+
(while (null ret)
|
346
|
+
(setq month-str
|
347
|
+
(read-from-minibuffer
|
348
|
+
(concat prompt "(yyyy/mm) : ") month-str nil nil 'mhc-month-hist))
|
349
|
+
(if (string-match "\\([0-9]+\\)/\\([0-9]+\\)" month-str)
|
350
|
+
(setq ret (mhc-date-new
|
351
|
+
(string-to-number (match-string 1 month-str))
|
352
|
+
(string-to-number (match-string 2 month-str))
|
353
|
+
1 t))))
|
354
|
+
ret))
|
355
|
+
|
356
|
+
(defconst mhc-input-time-regex "^\\([0-9]+\\):\\([0-9]+\\)$")
|
357
|
+
|
358
|
+
(defvar mhc-subject-hist nil)
|
359
|
+
|
360
|
+
(defun mhc-input-subject (&optional prompt default)
|
361
|
+
(interactive)
|
362
|
+
(read-from-minibuffer (or prompt "Subject: ")
|
363
|
+
(or default "")
|
364
|
+
nil nil 'mhc-subject-hist))
|
365
|
+
|
366
|
+
(defvar mhc-location-hist nil)
|
367
|
+
|
368
|
+
;; (defun mhc-input-location (&optional prompt default)
|
369
|
+
;; (interactive)
|
370
|
+
;; (read-from-minibuffer (or prompt "Location: ")
|
371
|
+
;; (or default "")
|
372
|
+
;; nil nil 'mhc-location-hist))
|
373
|
+
|
374
|
+
(defun mhc-input-location (&optional prompt default)
|
375
|
+
(mhc-minibuf-read "Location: "
|
376
|
+
default
|
377
|
+
(current-buffer)
|
378
|
+
(mhc-guess-location)
|
379
|
+
0
|
380
|
+
(function mhc-minibuf/location-to-string)
|
381
|
+
"[^ ]"))
|
382
|
+
|
383
|
+
(defvar mhc-category-hist nil)
|
384
|
+
|
385
|
+
(if (fboundp 'completing-read-multiple)
|
386
|
+
(defun mhc-input-category (&optional prompt default)
|
387
|
+
(interactive)
|
388
|
+
(let ((completion-ignore-case t)
|
389
|
+
(table (nconc (delete '("Todo")
|
390
|
+
(delete '("Done")
|
391
|
+
(mapcar (lambda (x) (list (car x)))
|
392
|
+
mhc-category-face-alist)))
|
393
|
+
(list '("Todo") '("Done")))))
|
394
|
+
(completing-read-multiple (or prompt "Category: ") ;PROMPT
|
395
|
+
table
|
396
|
+
nil ;PREDICATE
|
397
|
+
nil ;REQUIRE-MATCH
|
398
|
+
default ;INITIAL-INPUT
|
399
|
+
'mhc-category-hist ;HIST
|
400
|
+
)))
|
401
|
+
|
402
|
+
(defun mhc-input-category (&optional prompt default)
|
403
|
+
(interactive)
|
404
|
+
(let (in)
|
405
|
+
(and default
|
406
|
+
(listp default)
|
407
|
+
(setq default (mapconcat 'identity default " ")))
|
408
|
+
(if (string= "" (setq in (read-from-minibuffer
|
409
|
+
(or prompt "Category: ")
|
410
|
+
(or default "")
|
411
|
+
nil nil 'mhc-category-hist)))
|
412
|
+
nil
|
413
|
+
(mhc-misc-split in)))))
|
414
|
+
|
415
|
+
|
416
|
+
(defvar mhc-recurrence-tag-hist nil)
|
417
|
+
|
418
|
+
(defun mhc-input-recurrence-tag (&optional prompt default)
|
419
|
+
(interactive)
|
420
|
+
(read-from-minibuffer (or prompt "Recurrence Tag: ")
|
421
|
+
(or default "")
|
422
|
+
nil nil 'mhc-recurrence-tag-hist))
|
423
|
+
|
424
|
+
|
425
|
+
(defvar mhc-alarm-hist nil)
|
426
|
+
|
427
|
+
(defun mhc-input-alarm (&optional prompt default)
|
428
|
+
(interactive)
|
429
|
+
(read-from-minibuffer (or prompt "Alarm: ")
|
430
|
+
(or default mhc-default-alarm)
|
431
|
+
nil nil 'mhc-alarm-hist))
|
432
|
+
|
433
|
+
(provide 'mhc-minibuf)
|
434
|
+
|
435
|
+
;;; Copyright Notice:
|
436
|
+
|
437
|
+
;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
|
438
|
+
;; Copyright (C) 2000 MHC developing team. All rights reserved.
|
439
|
+
|
440
|
+
;; Redistribution and use in source and binary forms, with or without
|
441
|
+
;; modification, are permitted provided that the following conditions
|
442
|
+
;; are met:
|
443
|
+
;;
|
444
|
+
;; 1. Redistributions of source code must retain the above copyright
|
445
|
+
;; notice, this list of conditions and the following disclaimer.
|
446
|
+
;; 2. Redistributions in binary form must reproduce the above copyright
|
447
|
+
;; notice, this list of conditions and the following disclaimer in the
|
448
|
+
;; documentation and/or other materials provided with the distribution.
|
449
|
+
;; 3. Neither the name of the team nor the names of its contributors
|
450
|
+
;; may be used to endorse or promote products derived from this software
|
451
|
+
;; without specific prior written permission.
|
452
|
+
;;
|
453
|
+
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
|
454
|
+
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
455
|
+
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
456
|
+
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
457
|
+
;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
458
|
+
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
459
|
+
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
460
|
+
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
461
|
+
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
462
|
+
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
463
|
+
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
464
|
+
;; OF THE POSSIBILITY OF SUCH DAMAGE.
|
465
|
+
|
466
|
+
;;; mhc-minibuf.el ends here
|