mhc 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9eb513930c0f5d993e1755bed627593443df3e2
4
- data.tar.gz: d4a6c467fe781e96c68c0ebad0a96f743e8d6a8b
3
+ metadata.gz: 402d897f119ad032a3b79fe4a80c052e1a8c2c8b
4
+ data.tar.gz: 4dc290bec03d71233ef479963506b33b999661c7
5
5
  SHA512:
6
- metadata.gz: 0027ebd2eaab008113d12e02062011bf403ce7f3611f8d41cd874ee0c16434ed3e9c576abb10199426f2d374c6ea8c397209ee35ec453b86c42713c56c7c39b1
7
- data.tar.gz: 4b3ba18ed523c7105e9109f573b10f74bf1c4cfefbc99dea2e5d2dc4a09b03f6a17bd349097efae502b650323a6b64456dd3e0193fbc5f41516029519d1438e8
6
+ metadata.gz: ba669c599f75b7841a00629a3f5fa16d9833ec251a335bc9c8f147499fdcac02638d5e5f728d03adeac5e1f877e16c4bfb86c0bfc6e218b2f7d7a6139c699fe3
7
+ data.tar.gz: cdc5ddbbe58cdf8b81105b2f25218be682be480faa7dafe3143529d6dd35672aee37baffd403da52cb70b401b9e1ab74ce26db9fbba4e78565d52b7bdfe3f3f6
data/Gemfile CHANGED
@@ -2,7 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mhc.gemspec
4
4
  gemspec
5
- gem "thor"
6
- gem "ri_cal", :git => 'https://github.com/yoshinari-nomura/ri_cal.git'
7
- gem "tzinfo"
8
- gem "tzinfo-data"
data/README.org CHANGED
@@ -134,10 +134,9 @@
134
134
  #+BEGIN_SRC emacs-lisp
135
135
  (setq load-path
136
136
  (cons "~/src/mhc/emacs" load-path))
137
- (autoload 'mhc-mua-setup "mhc-mua")
138
- (mhc-mua-setup)
137
+ (autoload 'mhc "mhc" "Message Harmonized Calendar system." t)
139
138
 
140
- ;; M-x mhc-goto-this-month
139
+ ;; M-x mhc
141
140
  #+END_SRC
142
141
 
143
142
  9) Check if TODAY is good.
data/bin/mhc CHANGED
@@ -69,7 +69,7 @@ class MhcCLI < Thor
69
69
  register_option :repository, :desc => "Set MHC top directory", :banner => "DIRECTORY"
70
70
  register_option :calendar, :desc => "Set source CALENDAR"
71
71
  register_option :category, :desc => "Pick items only in CATEGORY"
72
- register_option :format, :desc => "Set printing format", :enum => %w(text mail orgtable emacs icalendar calfw howm)
72
+ register_option :format, :desc => "Set printing format", :enum => %w(text mail orgtable emacs icalendar calfw howm json)
73
73
  register_option :search, :desc => "Search items by complex expression"
74
74
  register_option :dry_run, :desc => "Perform a trial run with no changes made", :type => :boolean
75
75
 
@@ -11,6 +11,9 @@
11
11
 
12
12
  ;;; Configration Variables:
13
13
 
14
+ (require 'mhc-date)
15
+ (require 'mhc-day)
16
+ (require 'mhc-schedule)
14
17
  (require 'mhc-vars)
15
18
  (require 'mhc-face)
16
19
  (require 'mhc-e21)
@@ -227,10 +230,10 @@ ww-japanese-long => \"土曜日\"
227
230
 
228
231
  ;; Avoid warning of byte-compiler.
229
232
  (eval-when-compile
230
- (defvar mhc-yy)
231
- (defvar mhc-mm)
232
- (defvar mhc-dd)
233
- (defvar mhc-ww)
233
+ (defvar yy)
234
+ (defvar mm)
235
+ (defvar dd)
236
+ (defvar ww)
234
237
  (defvar hnf-diary-dir)
235
238
  (defvar hnf-diary-year-directory-flag)
236
239
  (defvar view-exit-action)
@@ -465,7 +468,7 @@ ww-japanese-long => \"土曜日\"
465
468
  (i 0)
466
469
  (from (mhc-date-mm-first date))
467
470
  (to (mhc-date-mm-last date))
468
- (start (mhc-date-ww date))
471
+ (start (mhc-date-ww from))
469
472
  (cdate from)
470
473
  week color cw day map dayinfo)
471
474
  (when (mhc-calendar/cw-week)
@@ -556,7 +559,7 @@ ww-japanese-long => \"土曜日\"
556
559
  (setq pos cpos)
557
560
  (throw 'detect t))))
558
561
  (goto-char pos)
559
- (funcall (mhc-get-function 'goto-message) view))
562
+ (when view (mhc-summary-display)))
560
563
  (t
561
564
  (unless (mhc-calendar-mouse-icon-function event)
562
565
  (setq func (or (lookup-key (current-local-map) (this-command-keys))
@@ -728,7 +731,8 @@ The keys that are defined for mhc-calendar-mode are:
728
731
  (caldate (mhc-date-mm+ date -1))
729
732
  (col mhc-calendar-start-column)
730
733
  (prefix " +|")
731
- (i 3))
734
+ (i 3)
735
+ (string))
732
736
  (mhc-calendar/delete-overlay)
733
737
  (set-text-properties (point-min) (point-max) nil)
734
738
  (erase-buffer)
@@ -743,8 +747,9 @@ The keys that are defined for mhc-calendar-mode are:
743
747
  (setq i (1- i)))
744
748
  (goto-char (point-min))
745
749
  (while (re-search-forward prefix nil t)
750
+ (setq string (match-string 0))
746
751
  (delete-region (match-end 0) (match-beginning 0))
747
- (insert (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
752
+ (insert (make-string (length string) ?\ )))
748
753
  (setq mhc-calendar-date date)
749
754
  ;; (mhc-calendar/put-property-date)
750
755
  (and mhc-calendar-link-hnf (mhc-calendar/hnf-mark-diary-entries))
@@ -850,7 +855,7 @@ The keys that are defined for mhc-calendar-mode are:
850
855
  (defun mhc-calendar/view-file-decode-header ()
851
856
  (let ((buffer-read-only nil))
852
857
  (goto-char (point-min))
853
- (mhc-decode-header)
858
+ (mhc-header-decode-ewords)
854
859
  (mhc-highlight-message)))
855
860
 
856
861
  ;; insert function
@@ -1062,53 +1067,53 @@ The keys that are defined for mhc-calendar-mode are:
1062
1067
  (and func (funcall func))))))
1063
1068
 
1064
1069
  (defun mhc-calendar/inserter-yy ()
1065
- (format "%4d" mhc-yy))
1070
+ (format "%4d" yy))
1066
1071
 
1067
1072
  (defun mhc-calendar/inserter-nengo ()
1068
- (if (> mhc-yy 1987)
1069
- (format "平成%2d年" (- mhc-yy 1988))
1070
- (if (> mhc-yy 1924)
1071
- (format "昭和%2d年" (- mhc-yy 1925))
1073
+ (if (> yy 1987)
1074
+ (format "平成%2d年" (- yy 1988))
1075
+ (if (> yy 1924)
1076
+ (format "昭和%2d年" (- yy 1925))
1072
1077
  "昔々")))
1073
1078
 
1074
1079
  (defun mhc-calendar/inserter-mm ()
1075
- (format "%d" mhc-mm))
1080
+ (format "%d" mm))
1076
1081
 
1077
1082
  (defun mhc-calendar/inserter-mm02 ()
1078
- (format "%02d" mhc-mm))
1083
+ (format "%02d" mm))
1079
1084
 
1080
1085
  (defun mhc-calendar/inserter-mm2 ()
1081
- (format "%2d" mhc-mm))
1086
+ (format "%2d" mm))
1082
1087
 
1083
1088
  (defun mhc-calendar/inserter-mm-string ()
1084
- (mhc-date-digit-to-mm-string mhc-mm))
1089
+ (mhc-date-digit-to-mm-string mm))
1085
1090
 
1086
1091
  (defun mhc-calendar/inserter-mm-string-long ()
1087
- (mhc-date-digit-to-mm-string mhc-mm t))
1092
+ (mhc-date-digit-to-mm-string mm t))
1088
1093
 
1089
1094
  (defun mhc-calendar/inserter-dd ()
1090
- (format "%d" mhc-dd))
1095
+ (format "%d" dd))
1091
1096
 
1092
1097
  (defun mhc-calendar/inserter-dd02 ()
1093
- (format "%02d" mhc-dd))
1098
+ (format "%02d" dd))
1094
1099
 
1095
1100
  (defun mhc-calendar/inserter-dd2 ()
1096
- (format "%2d" mhc-dd))
1101
+ (format "%2d" dd))
1097
1102
 
1098
1103
  (defun mhc-calendar/inserter-ww ()
1099
- (format "%d" mhc-ww))
1104
+ (format "%d" ww))
1100
1105
 
1101
1106
  (defun mhc-calendar/inserter-ww-string ()
1102
- (mhc-date-digit-to-ww-string mhc-ww))
1107
+ (mhc-date-digit-to-ww-string ww))
1103
1108
 
1104
1109
  (defun mhc-calendar/inserter-ww-string-long ()
1105
- (mhc-date-digit-to-ww-string mhc-ww t))
1110
+ (mhc-date-digit-to-ww-string ww t))
1106
1111
 
1107
1112
  (defun mhc-calendar/inserter-ww-japanese ()
1108
- (mhc-date-digit-to-ww-japanese-string mhc-ww))
1113
+ (mhc-date-digit-to-ww-japanese-string ww))
1109
1114
 
1110
1115
  (defun mhc-calendar/inserter-ww-japanese-long ()
1111
- (mhc-date-digit-to-ww-japanese-string mhc-ww t))
1116
+ (mhc-date-digit-to-ww-japanese-string ww t))
1112
1117
 
1113
1118
  (defun mhc-calendar/get-day-list (date &optional datelst dateend)
1114
1119
  (let (lst-org formlst retlst retlst2 ret con)
@@ -1526,7 +1531,7 @@ The keys that are defined for mhc-calendar-mode are:
1526
1531
  (setq lst (cdr lst))))
1527
1532
  (with-temp-buffer
1528
1533
  (insert-file-contents mhcfile)
1529
- (mhc-decode-header)
1534
+ (mhc-header-decode-ewords)
1530
1535
  (mhc-header-narrowing
1531
1536
  (setq cats (mhc-header-get-value "x-sc-category"))
1532
1537
  (setq subj (mhc-header-get-value "x-sc-subject"))
@@ -9,31 +9,6 @@
9
9
 
10
10
  ;; This file is a part of MHC, includes functions for draft.
11
11
 
12
- ;;; About MUA Backend:
13
-
14
- ;; In order to define new MUA backend, it is required to define these
15
- ;; methods.
16
- ;;
17
- ;; (mhc-foo-draft-setup-new)
18
- ;; Setup new draft (Insert header separator).
19
- ;;
20
- ;; (mhc-foo-draft-reedit-buffer BUFFER ORIGINAL)
21
- ;; Restore content of BUFFER as draft in the current buffer.
22
- ;; If ORIGINAL is non-nil, use BUFFER as raw buffer.
23
- ;;
24
- ;; (mhc-foo-draft-reedit-file FILENAME)
25
- ;; Restore contents of file FILENAME as draft in the current buffer.
26
- ;;
27
- ;; (mhc-foo-draft-translate)
28
- ;; Translate current buffer to raw buffer.
29
- ;;
30
- ;; Define these methods appropriately, and put definitions as follows:
31
- ;;
32
- ;; (put 'mhc-foo 'draft-setup-new 'mhc-foo-draft-setup-new)
33
- ;; (put 'mhc-foo 'draft-reedit-buffer 'mhc-foo-draft-reedit-buffer)
34
- ;; (put 'mhc-foo 'draft-reedit-file 'mhc-foo-draft-reedit-file)
35
- ;; (put 'mhc-foo 'draft-translate 'mhc-foo-draft-translate)
36
-
37
12
  ;;; Code:
38
13
 
39
14
  (require 'mhc-summary)
@@ -63,25 +38,80 @@
63
38
 
64
39
  (defvar mhc-draft-mode-map)
65
40
 
66
- (defsubst mhc-draft-setup-new ()
41
+ (defun mhc-draft-setup-new ()
67
42
  "Setup new draft (Insert header separator, etc)."
68
- (funcall (mhc-get-function 'draft-setup-new)))
69
-
43
+ (let ((sep-regexp (format "\n\\(%s\\)?\n" (regexp-quote mail-header-separator)))
44
+ (sep (concat "\n" mail-header-separator "\n")))
45
+ (save-excursion
46
+ (goto-char (point-min))
47
+ (if (re-search-forward sep-regexp nil t)
48
+ (replace-match sep)
49
+ (goto-char (point-max))
50
+ (unless (bolp) (insert "\n"))
51
+ (insert mail-header-separator "\n")))))
52
+
53
+ (defun mhc-draft-new (&optional template preset-fields)
54
+ "Prepare new mhc-draft buffer.
55
+ If TEMPLATE is a string or buffer, it is used for a new draft.
56
+ If PRESET-FIELDS is a list of cons-cell like: ((header-name . value) ...),
57
+ these fields are set to the draft after import TEMPLATE."
58
+ (interactive)
59
+ (let ((draft-buffer (generate-new-buffer mhc-draft-buffer-name)))
60
+ (with-current-buffer draft-buffer
61
+ ;; insert template
62
+ (cond
63
+ ((bufferp template)
64
+ (insert-buffer-substring-no-properties template))
65
+ ((stringp template)
66
+ (insert template)))
67
+ ;; insert header separator
68
+ (mhc-draft-setup-new)
69
+ (mhc-draft-delete-garbage-headers)
70
+ (mhc-draft-setup-headers preset-fields)
71
+ ;; remove end of message marker
72
+ (mhc-draft-remove-tailers)
73
+ (mhc-draft-mode)
74
+ (switch-to-buffer draft-buffer t)
75
+ (goto-char (point-min)))))
76
+
77
+ (defvar mhc-draft-template)
78
+
79
+ (defun mhc-draft-store-template (template)
80
+ "Store common draft template to TEMPLATE."
81
+ (setq mhc-draft-template template))
82
+
83
+ (defun mhc-draft-template ()
84
+ "Get common draft template."
85
+ mhc-draft-template)
70
86
 
71
87
  (defsubst mhc-draft-reedit-buffer (buffer &optional original)
72
88
  "Restore contents of BUFFER as draft in the current buffer.
73
89
  If optional argument ORIGINAL is non-nil, BUFFER is raw buffer."
74
- (funcall (mhc-get-function 'draft-reedit-buffer) buffer original))
75
-
90
+ (unless (eq (current-buffer) buffer)
91
+ (erase-buffer)
92
+ (insert-buffer-substring buffer))
93
+ (mhc-header-narrowing
94
+ (mhc-header-delete-header
95
+ "^\\(Content-.*\\|Mime-Version\\|User-Agent\\):" 'regexp))
96
+ (mhc-header-decode-ewords)
97
+ (goto-char (point-min))
98
+ (when (re-search-forward "^\r?$" nil t)
99
+ (insert mail-header-separator)))
76
100
 
77
101
  (defsubst mhc-draft-reedit-file (filename)
78
102
  "Restore contents of file FILENAME as draft in the current buffer."
79
- (funcall (mhc-get-function 'draft-reedit-file) filename))
103
+ (erase-buffer)
104
+ (insert-file-contents filename)
105
+ (mhc-draft-reedit-buffer (current-buffer) 'original))
80
106
 
81
107
 
82
108
  (defsubst mhc-draft-translate ()
83
- "Translate current buffer to raw buffer."
84
- (funcall (mhc-get-function 'draft-translate)))
109
+ "Convert an article in the current buffer to an ENCODED one.
110
+ ENCODED article should be valid for storeing to a mhc file."
111
+ (save-excursion
112
+ (goto-char (point-min))
113
+ (when (search-forward (concat "\n" mail-header-separator "\n") nil t)
114
+ (replace-match "\n\n"))))
85
115
 
86
116
 
87
117
  (define-derived-mode mhc-draft-mode
@@ -158,6 +188,36 @@ If optional argument NO-CONFIRM is non-nil, kill without confirmation."
158
188
  (mhc-header-put-value "x-sc-sequence"
159
189
  (1+ (string-to-number sequence))))))
160
190
 
191
+ (defun mhc-draft-remove-tailers ()
192
+ (save-excursion
193
+ (goto-char (point-max))
194
+ (if (re-search-backward
195
+ (regexp-quote mhc-message-end-of-messge-marker)
196
+ (- (point) (length mhc-message-end-of-messge-marker)) t)
197
+ (replace-match ""))
198
+ (unless (bolp) (insert "\n"))))
199
+
200
+ (defun mhc-draft-delete-garbage-headers ()
201
+ (mhc-header-narrowing
202
+ (mhc-header-delete-header
203
+ (concat "^\\(" (mhc-regexp-opt mhc-draft-unuse-hdr-list) "\\)")
204
+ 'regexp)))
205
+
206
+ (defun mhc-draft-setup-headers (&optional headers-values)
207
+ "Put X-SC-* headers to draft.
208
+ HEADERS-VALUES is a list of cons-cell like: ((header-name . value) ...)."
209
+ (let ((xsc-headers (mapcar (lambda (v) (downcase (substring v 0 -1)))
210
+ (mhc-header-list)))
211
+ (item))
212
+ (mhc-header-narrowing
213
+ (mapc
214
+ (lambda (xsc)
215
+ (if (setq item (assoc xsc headers-values))
216
+ (mhc-header-put-value xsc (or (cdr item) ""))
217
+ (unless (mhc-header-get-value xsc)
218
+ (mhc-header-put-value xsc ""))))
219
+ xsc-headers))))
220
+
161
221
  (defun mhc-draft-finish ()
162
222
  "Add current draft as a schedule."
163
223
  (interactive)
@@ -33,6 +33,51 @@ in setup time.")
33
33
  (FACE-SYMBOL . (PARENT FG BG UNDERLINED FONT STIPPLE)).
34
34
  refer to mhc-calendar-hnf-face-alist-internal.")
35
35
 
36
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37
+ ;; Message faces.
38
+
39
+ (defvar mhc-message-face-eof-marker 'mhc-message-face-eof-marker)
40
+ (defvar mhc-message-face-subject 'mhc-message-face-subject)
41
+
42
+ (defface mhc-message-face-eof-marker
43
+ '((((class color)
44
+ (background dark))
45
+ (:background "aquamarine2"))
46
+ (((class color)
47
+ (background light))
48
+ (:background "aquamarine2"))
49
+ (t
50
+ ()))
51
+ "*Face used by mhc-message-eof-marker."
52
+ :group 'mhc-faces)
53
+
54
+ (defface mhc-message-face-subject
55
+ '((((class color)
56
+ (background dark))
57
+ (:foreground "OrangeRed" :bold t))
58
+ (((class color)
59
+ (background light))
60
+ (:foreground "Firebrick" :bold t))
61
+ (t
62
+ ()))
63
+ "*Face used by mhc-message-subject."
64
+ :group 'mhc-faces)
65
+
66
+ (defvar mhc-message-font-lock-keywords
67
+ '(("\\([12][0-9][0-9][0-9]\\)\\([0-1][0-9]\\)\\([0-3][0-9]\\)"
68
+ (1 font-lock-type-face)
69
+ (2 font-lock-comment-face)
70
+ (3 font-lock-builtin-face))
71
+ ("\\(X-SC-\\(Subject\\|Location\\|Day\\|Time\\|Category\\|Priority\\|Recurrence-Tag\\|Mission-Tag:\\|Cond\\|Duration\\|Alarm\\|Record-Id\\|Sequence\\):\\)"
72
+ (1 font-lock-keyword-face))
73
+ ("\\(\\[End of message\\]\\)"
74
+ (1 mhc-message-face-eof-marker))
75
+ ("\\(X-SC-Subject:\\) *\\(.*\\)"
76
+ (1 font-lock-keyword-face)
77
+ (2 mhc-message-face-subject))
78
+ ))
79
+
80
+
36
81
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37
82
  ;; for necessary faces.
38
83
 
@@ -17,24 +17,20 @@
17
17
  ;; Global Variable:
18
18
 
19
19
  (defconst mhc-header-table
20
- '(("x-sc-day" "X-SC-Day:" mhc-parse/day)
21
- ("x-sc-cond" "X-SC-Cond:" mhc-parse/cond)
22
- ("x-sc-duration" "X-SC-Duration:" mhc-parse/duration)
23
- ("x-sc-subject" "X-SC-Subject:" mhc-parse/subject)
24
- ("x-sc-location" "X-SC-Location:" mhc-parse/location)
25
- ("x-sc-time" "X-SC-Time:" mhc-parse/time)
26
- ("x-sc-alarm" "X-SC-Alarm:" mhc-parse/alarm)
27
- ("x-sc-category" "X-SC-Category:" mhc-parse/category)
28
- ("x-sc-recurrence-tag" "X-SC-Recurrence-Tag:" mhc-parse/recurrence-tag)
29
- ("x-sc-priority" "X-SC-Priority:" mhc-parse/priority)
30
- ("x-sc-record-id" "X-SC-Record-Id:" mhc-parse/record-id)
31
- ("x-sc-schedule" "X-SC-Schdule:" mhc-parse/schedule)
32
- ("x-sc-sequence" "X-SC-Sequence:" mhc-parse/sequence)
33
- ;; For backward compatibility
34
- ("x-sc-date" "X-SC-Date:" mhc-parse/old-style-date)
35
- ;; FIXME: 要削除
36
- ("x-sc-next" "X-SC-Next:" mhc-parse/next)))
37
-
20
+ '(
21
+ ("x-sc-subject" "X-SC-Subject:" mhc-parse/subject)
22
+ ("x-sc-location" "X-SC-Location:" mhc-parse/location)
23
+ ("x-sc-day" "X-SC-Day:" mhc-parse/day)
24
+ ("x-sc-time" "X-SC-Time:" mhc-parse/time)
25
+ ("x-sc-category" "X-SC-Category:" mhc-parse/category)
26
+ ("x-sc-priority" "X-SC-Priority:" mhc-parse/priority)
27
+ ("x-sc-recurrence-tag" "X-SC-Recurrence-Tag:" mhc-parse/recurrence-tag)
28
+ ("x-sc-cond" "X-SC-Cond:" mhc-parse/cond)
29
+ ("x-sc-duration" "X-SC-Duration:" mhc-parse/duration)
30
+ ("x-sc-alarm" "X-SC-Alarm:" mhc-parse/alarm)
31
+ ("x-sc-record-id" "X-SC-Record-Id:" mhc-parse/record-id)
32
+ ("x-sc-sequence" "X-SC-Sequence:" mhc-parse/sequence)
33
+ ))
38
34
 
39
35
  (defmacro mhc-header-list ()
40
36
  "Return headers which are referenced by MHC."
@@ -139,6 +135,14 @@ If REGEXP, HEADER is a regular expression."
139
135
  (delete-region (match-beginning 0) (match-end 0)))))
140
136
 
141
137
 
138
+ (eval-and-compile
139
+ (autoload 'rfc2047-decode-region "rfc2047"))
140
+
141
+ (defsubst mhc-header-decode-ewords ()
142
+ "Decode rfc2047 encoded header."
143
+ (save-restriction
144
+ (mhc-header-narrowing
145
+ (rfc2047-decode-region (point-min) (point-max)))))
142
146
 
143
147
  (provide 'mhc-header)
144
148