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
data/emacs/mhc-misc.el
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
;;; mhc-misc.el -- miscellaneous functions for mhc.
|
2
|
+
|
3
|
+
;; Author: Yoshinari Nomura <nom@quickhack.net>
|
4
|
+
;;
|
5
|
+
;; Created: 1997/10/12
|
6
|
+
;; Revised: $Date: 2002/12/01 03:55:06 $
|
7
|
+
|
8
|
+
;;;
|
9
|
+
;;; Commentay:
|
10
|
+
;;;
|
11
|
+
|
12
|
+
;;;
|
13
|
+
;;; Code:
|
14
|
+
;;;
|
15
|
+
|
16
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
17
|
+
;; string
|
18
|
+
|
19
|
+
(defun mhc-misc-sub (str regex replace)
|
20
|
+
(if (and (stringp str) (string-match regex str))
|
21
|
+
(concat (substring str 0 (match-beginning 0))
|
22
|
+
replace
|
23
|
+
(substring str (match-end 0)))
|
24
|
+
str))
|
25
|
+
|
26
|
+
(defun mhc-misc-gsub (str regex replace)
|
27
|
+
(if (and (stringp str) (string-match regex str))
|
28
|
+
(concat (substring str 0 (match-beginning 0))
|
29
|
+
replace
|
30
|
+
(mhc-misc-gsub (substring str (match-end 0)) regex replace))
|
31
|
+
str))
|
32
|
+
|
33
|
+
(defun mhc-misc-split (str &optional sep)
|
34
|
+
(let ((ret ()))
|
35
|
+
(while (string-match (or sep "[\t ]+") str)
|
36
|
+
(setq ret (cons (substring str 0 (match-beginning 0)) ret))
|
37
|
+
(setq str (substring str (match-end 0))))
|
38
|
+
(nreverse (cons str ret))))
|
39
|
+
|
40
|
+
(defun mhc-misc-strip (str)
|
41
|
+
(mhc-misc-sub
|
42
|
+
(mhc-misc-sub str "^[\t ]+" "") "[\t ]+$" ""))
|
43
|
+
|
44
|
+
(defun mhc-misc-substring-to-int (str pos)
|
45
|
+
(cond
|
46
|
+
((stringp str)
|
47
|
+
(string-to-number
|
48
|
+
(substring str (match-beginning pos) (match-end pos))))
|
49
|
+
(t
|
50
|
+
(string-to-number
|
51
|
+
(buffer-substring (match-beginning pos) (match-end pos))))))
|
52
|
+
|
53
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
54
|
+
;; file & path
|
55
|
+
|
56
|
+
(defun mhc-misc-get-new-path (dir &optional record)
|
57
|
+
"Return name for new schedule file on DIR."
|
58
|
+
(let ((filename
|
59
|
+
(cond
|
60
|
+
((and (stringp record) (file-exists-p record) (string-match "\\.mhc$" record))
|
61
|
+
(file-name-nondirectory record))
|
62
|
+
((and record (mhc-record-id record))
|
63
|
+
(concat (mhc-record-id record) ".mhc")))))
|
64
|
+
(if filename
|
65
|
+
;; uses UUID format, so simply change the directory
|
66
|
+
(expand-file-name filename dir)
|
67
|
+
;; make old-style number filename
|
68
|
+
(mhc-misc-get-new-path-by-number dir))))
|
69
|
+
|
70
|
+
(defun mhc-misc-get-new-path-by-number (dir)
|
71
|
+
"Return name for new schedule file on DIR."
|
72
|
+
(let (dirent (max 0) (num nil))
|
73
|
+
(mhc-file-make-directory dir)
|
74
|
+
(setq dirent (directory-files dir nil nil t))
|
75
|
+
(while dirent
|
76
|
+
(or (string-match "[^0-9]" (car dirent))
|
77
|
+
(if (< max (setq num (string-to-number (car dirent))))
|
78
|
+
(setq max num)))
|
79
|
+
(setq dirent (cdr dirent)))
|
80
|
+
(expand-file-name (number-to-string (1+ max)) dir)))
|
81
|
+
|
82
|
+
;;
|
83
|
+
;; touch directory and files.
|
84
|
+
;;
|
85
|
+
|
86
|
+
(defvar mhc-mtime-file ".mhc-mtime")
|
87
|
+
|
88
|
+
(defun mhc-misc-get-mtime (obj)
|
89
|
+
(let ((mtime-file (expand-file-name mhc-mtime-file obj)))
|
90
|
+
(cond
|
91
|
+
((not (stringp obj))
|
92
|
+
nil)
|
93
|
+
((file-exists-p mtime-file)
|
94
|
+
(nth 5 (file-attributes mtime-file)))
|
95
|
+
((file-exists-p obj)
|
96
|
+
(nth 5 (file-attributes obj)))
|
97
|
+
(t
|
98
|
+
nil))))
|
99
|
+
|
100
|
+
(defun mhc-misc-touch-directory (dir)
|
101
|
+
(let ((mtime-file (expand-file-name mhc-mtime-file dir)))
|
102
|
+
(if (file-writable-p mtime-file)
|
103
|
+
;; (write-region (point-min) (point-min) mtime-file nil 'silence))
|
104
|
+
(write-region 1 2 mtime-file nil 'silence))
|
105
|
+
))
|
106
|
+
|
107
|
+
|
108
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
109
|
+
;; rectangle
|
110
|
+
;;
|
111
|
+
;; Does (current-column) count visible character only?
|
112
|
+
;; emacs 19.34, 20.4, 20.5 -- yes
|
113
|
+
;; emacs 19.28 -- no
|
114
|
+
;; xemacs -- no
|
115
|
+
;;
|
116
|
+
(defvar mhc-misc-column-count-visible-only
|
117
|
+
(and (not (featurep 'xemacs)) (string< "19.3" emacs-version)))
|
118
|
+
|
119
|
+
(defun mhc-misc-move-to-column (column)
|
120
|
+
"Move point to column COLUMN rigidly in the current line, considering
|
121
|
+
invisible charracters."
|
122
|
+
(if mhc-misc-column-count-visible-only
|
123
|
+
()
|
124
|
+
(beginning-of-line)
|
125
|
+
(let* ((bol (point))
|
126
|
+
(vis (if (get-char-property bol 'invisible)
|
127
|
+
(next-single-property-change bol 'invisible)
|
128
|
+
bol)))
|
129
|
+
(setq column (+ column (- vis bol)))))
|
130
|
+
(if (< column (move-to-column column t))
|
131
|
+
(progn (delete-char -1) (insert ?\ ))))
|
132
|
+
|
133
|
+
(defun mhc-misc-current-column ()
|
134
|
+
"Return current column in a visible field."
|
135
|
+
(if mhc-misc-column-count-visible-only
|
136
|
+
(current-column)
|
137
|
+
(let* ((bol (save-excursion (beginning-of-line) (point)))
|
138
|
+
(vis (if (get-char-property bol 'invisible)
|
139
|
+
(next-single-property-change bol 'invisible)
|
140
|
+
bol)))
|
141
|
+
(- (current-column) (- vis bol)))))
|
142
|
+
|
143
|
+
(defun mhc-misc-insert-rectangle (rectangle)
|
144
|
+
(let ((lines rectangle)
|
145
|
+
(insertcolumn (mhc-misc-current-column))
|
146
|
+
(first t))
|
147
|
+
;; (push-mark)
|
148
|
+
(while lines
|
149
|
+
(or first
|
150
|
+
(progn
|
151
|
+
(forward-line 1)
|
152
|
+
(or (bolp) (insert ?\n))
|
153
|
+
(mhc-misc-move-to-column insertcolumn)))
|
154
|
+
(setq first nil)
|
155
|
+
(if (looking-at "[^\r\n]+")
|
156
|
+
(delete-region (point) (match-end 0)))
|
157
|
+
(insert (car lines))
|
158
|
+
(setq lines (cdr lines)))))
|
159
|
+
|
160
|
+
(defun mhc-misc-get-width ()
|
161
|
+
(let ((dw (* mhc-calendar-width 2))
|
162
|
+
(ww (window-width))
|
163
|
+
(fw (frame-width)))
|
164
|
+
(cond
|
165
|
+
((> ww dw) ww)
|
166
|
+
((and (< (* ww 2) fw)
|
167
|
+
(> (* ww 2) dw)) (* ww 2))
|
168
|
+
((> fw dw) fw)
|
169
|
+
(t dw))))
|
170
|
+
|
171
|
+
;; read-passwd
|
172
|
+
|
173
|
+
(defun mhc-misc-read-passwd (prompt)
|
174
|
+
(let ((inhibit-input-event-recording t))
|
175
|
+
(if (fboundp 'read-passwd)
|
176
|
+
(condition-case nil
|
177
|
+
(read-passwd prompt)
|
178
|
+
;; If read-passwd causes an error, let's return "" so that
|
179
|
+
;; the password process will safely fail.
|
180
|
+
(error ""))
|
181
|
+
(let ((pass "")
|
182
|
+
(c 0)
|
183
|
+
(echo-keystrokes 0)
|
184
|
+
(ociea cursor-in-echo-area))
|
185
|
+
(condition-case nil
|
186
|
+
(progn
|
187
|
+
(setq cursor-in-echo-area 1)
|
188
|
+
(while (and (/= c ?\r) (/= c ?\n) (/= c ?\e) (/= c 7)) ;; ^G
|
189
|
+
(message "%s%s"
|
190
|
+
prompt
|
191
|
+
(make-string (length pass) ?.))
|
192
|
+
(setq c (read-char-exclusive))
|
193
|
+
(cond
|
194
|
+
((char-equal c ?\C-u)
|
195
|
+
(setq pass ""))
|
196
|
+
((or (char-equal c ?\b) (char-equal c ?\177)) ;; BS DELL
|
197
|
+
;; delete one character in the end
|
198
|
+
(if (not (equal pass ""))
|
199
|
+
(setq pass (substring pass 0 -1))))
|
200
|
+
((< c 32) ()) ;; control, just ignore
|
201
|
+
(t
|
202
|
+
(setq pass (concat pass (char-to-string c))))))
|
203
|
+
(setq cursor-in-echo-area -1))
|
204
|
+
(quit
|
205
|
+
(setq cursor-in-echo-area ociea)
|
206
|
+
(signal 'quit nil))
|
207
|
+
(error
|
208
|
+
;; Probably not happen. Just align to the code above.
|
209
|
+
(setq pass "")))
|
210
|
+
(setq cursor-in-echo-area ociea)
|
211
|
+
(message "")
|
212
|
+
(sit-for 0)
|
213
|
+
pass))))
|
214
|
+
|
215
|
+
(provide 'mhc-misc)
|
216
|
+
|
217
|
+
;;; Copyright Notice:
|
218
|
+
|
219
|
+
;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
|
220
|
+
;; Copyright (C) 2000 MHC developing team. All rights reserved.
|
221
|
+
|
222
|
+
;; Redistribution and use in source and binary forms, with or without
|
223
|
+
;; modification, are permitted provided that the following conditions
|
224
|
+
;; are met:
|
225
|
+
;;
|
226
|
+
;; 1. Redistributions of source code must retain the above copyright
|
227
|
+
;; notice, this list of conditions and the following disclaimer.
|
228
|
+
;; 2. Redistributions in binary form must reproduce the above copyright
|
229
|
+
;; notice, this list of conditions and the following disclaimer in the
|
230
|
+
;; documentation and/or other materials provided with the distribution.
|
231
|
+
;; 3. Neither the name of the team nor the names of its contributors
|
232
|
+
;; may be used to endorse or promote products derived from this software
|
233
|
+
;; without specific prior written permission.
|
234
|
+
;;
|
235
|
+
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
|
236
|
+
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
237
|
+
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
238
|
+
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
239
|
+
;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
240
|
+
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
241
|
+
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
242
|
+
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
243
|
+
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
244
|
+
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
245
|
+
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
246
|
+
;; OF THE POSSIBILITY OF SUCH DAMAGE.
|
247
|
+
|
248
|
+
;;; mhc-misc.el ends here
|
data/emacs/mhc-mua.el
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
;;; mhc-mua.el --- MUA backend for MHC
|
2
|
+
|
3
|
+
;; Author: Yoshinari Nomura <nom@quickhack.net>
|
4
|
+
;; Created: 2014-09-20
|
5
|
+
|
6
|
+
;;; Commentary:
|
7
|
+
|
8
|
+
;; This file is a part of MHC, backend methods for Generic MUA.
|
9
|
+
|
10
|
+
;;; Code:
|
11
|
+
|
12
|
+
(defconst mhc-mua/summary-filename-regex
|
13
|
+
".*\r *\\+\\([^ \t]+\\)[ \t]+\\([^ \t\n]+\\)")
|
14
|
+
|
15
|
+
;; Setup function:
|
16
|
+
|
17
|
+
(eval-and-compile
|
18
|
+
(autoload 'rfc2047-decode-region "rfc2047")
|
19
|
+
(autoload 'rfc2047-decode-string "rfc2047")
|
20
|
+
;; (autoload 'eword-encode-string "eword-encode")
|
21
|
+
;; (autoload 'rfc2047-encode-message-header "rfc2047")
|
22
|
+
;; (autoload 'rfc2047-encode-string "rfc2047")
|
23
|
+
)
|
24
|
+
|
25
|
+
;;;###autoload
|
26
|
+
(defun mhc-mua-setup ()
|
27
|
+
(require 'mhc)
|
28
|
+
(setq mhc-mailer-package 'mua)
|
29
|
+
(mhc-setup)
|
30
|
+
(add-hook 'mhc-summary-mode-hook 'mhc-mode))
|
31
|
+
|
32
|
+
;;; Backend methods:
|
33
|
+
|
34
|
+
;;; for mhc-summary
|
35
|
+
|
36
|
+
(defun mhc-mua-summary-filename ()
|
37
|
+
(let (folder number)
|
38
|
+
(save-excursion
|
39
|
+
(beginning-of-line)
|
40
|
+
(if (not (looking-at mhc-mua/summary-filename-regex))
|
41
|
+
()
|
42
|
+
(buffer-substring (match-beginning 2) (match-end 2))))))
|
43
|
+
|
44
|
+
(defun mhc-mua-summary-display-article ()
|
45
|
+
"Display the current article pointed in summary."
|
46
|
+
(let ((file (mhc-mua-summary-filename)))
|
47
|
+
(if (not (and (stringp file) (file-exists-p file)))
|
48
|
+
(message "File does not exist.")
|
49
|
+
(mhc-window-push)
|
50
|
+
;; (view-file-other-window file)
|
51
|
+
(pop-to-buffer (get-buffer-create "*MHC message*"))
|
52
|
+
;; eword decode
|
53
|
+
(let ((buffer-read-only nil))
|
54
|
+
(goto-char (point-min))
|
55
|
+
(erase-buffer)
|
56
|
+
(insert-file-contents file)
|
57
|
+
(mhc-header-narrowing
|
58
|
+
(mhc-header-delete-header
|
59
|
+
"^\\(Content-.*\\|Mime-Version\\|User-Agent\\):" 'regexp))
|
60
|
+
(mhc-header-delete-empty-header
|
61
|
+
"^X-SC-.*:" 'regexp)
|
62
|
+
(mhc-message-mode)
|
63
|
+
(mhc-message-set-file-name file))
|
64
|
+
;; (setq view-exit-action 'mhc-calendar-view-exit-action)
|
65
|
+
(set-visited-file-name nil)
|
66
|
+
;; (rename-buffer (file-name-nondirectory file) 'unique)
|
67
|
+
;; (run-hooks 'mhc-calendar-view-file-hook)
|
68
|
+
(set-buffer-modified-p nil)
|
69
|
+
(setq buffer-read-only t)
|
70
|
+
)))
|
71
|
+
|
72
|
+
(defun mhc-mua-get-import-buffer (&optional get-raw)
|
73
|
+
"Return a buffer visiting import article.
|
74
|
+
If GET-RAW is non-nil, return a cons of buffer: car keeps a raw
|
75
|
+
message and cdr keeps a visible message."
|
76
|
+
(let ((buffer
|
77
|
+
(or
|
78
|
+
(save-window-excursion
|
79
|
+
(let ((mode (progn (other-window 1) major-mode)))
|
80
|
+
(if (or
|
81
|
+
(eq mode 'mew-message-mode)
|
82
|
+
(eq mode 'mhc-message-mode))
|
83
|
+
(current-buffer))))
|
84
|
+
(current-buffer))))
|
85
|
+
;; XXX get-raw is gone soon
|
86
|
+
(if get-raw
|
87
|
+
(cons buffer buffer)
|
88
|
+
buffer)))
|
89
|
+
|
90
|
+
(defun mhc-mua-generate-summary-buffer (name-or-date)
|
91
|
+
"Generate a summary buffer for DATE-OR-DATE, and change current buffer to it."
|
92
|
+
(switch-to-buffer
|
93
|
+
(set-buffer
|
94
|
+
(mhc-get-buffer-create
|
95
|
+
(if (stringp name-or-date)
|
96
|
+
name-or-date
|
97
|
+
(mhc-date-format name-or-date "%04d-%02d" yy mm)))))
|
98
|
+
(setq inhibit-read-only t
|
99
|
+
buffer-read-only nil
|
100
|
+
selective-display t
|
101
|
+
selective-display-ellipses nil
|
102
|
+
indent-tabs-mode nil)
|
103
|
+
(widen)
|
104
|
+
(delete-region (point-min) (point-max)))
|
105
|
+
|
106
|
+
(defun mhc-mua/schedule-foldermsg (schedule)
|
107
|
+
(concat "\r +MHC " (mhc-record-name (mhc-schedule-record schedule))))
|
108
|
+
|
109
|
+
(defun mhc-mua-insert-summary-contents (inserter)
|
110
|
+
(funcall inserter)
|
111
|
+
(insert (mhc-mua/schedule-foldermsg mhc-tmp-schedule) "\n"))
|
112
|
+
|
113
|
+
(defun mhc-mua-summary-mode-setup (date)
|
114
|
+
(mhc-summary-mode))
|
115
|
+
|
116
|
+
|
117
|
+
(defvar mhc-message-eof-marker-face 'mhc-message-eof-marker-face)
|
118
|
+
(defvar mhc-message-subject-face 'mhc-message-subject-face)
|
119
|
+
|
120
|
+
(defface mhc-message-eof-marker-face
|
121
|
+
'((((class color)
|
122
|
+
(background dark))
|
123
|
+
(:background "aquamarine2"))
|
124
|
+
(((class color)
|
125
|
+
(background light))
|
126
|
+
(:background "aquamarine2"))
|
127
|
+
(t
|
128
|
+
()))
|
129
|
+
"*Face used by mhc-message-eof-marker."
|
130
|
+
:group 'mhc-faces)
|
131
|
+
|
132
|
+
(defface mhc-message-subject-face
|
133
|
+
'((((class color)
|
134
|
+
(background dark))
|
135
|
+
(:foreground "OrangeRed" :bold t))
|
136
|
+
(((class color)
|
137
|
+
(background light))
|
138
|
+
(:foreground "Firebrick" :bold t))
|
139
|
+
(t
|
140
|
+
()))
|
141
|
+
"*Face used by mhc-message-subject."
|
142
|
+
:group 'mhc-faces)
|
143
|
+
|
144
|
+
(defvar mhc-message-font-lock-keywords
|
145
|
+
'(("\\([12][0-9][0-9][0-9]\\)\\([0-1][0-9]\\)\\([0-3][0-9]\\)"
|
146
|
+
(1 font-lock-type-face)
|
147
|
+
(2 font-lock-comment-face)
|
148
|
+
(3 font-lock-builtin-face))
|
149
|
+
("\\(X-SC-\\(Subject\\|Location\\|Day\\|Time\\|Category\\|Priority\\|Recurrence-Tag\\|Mission-Tag:\\|Cond\\|Duration\\|Alarm\\|Record-Id\\|Sequence\\):\\)"
|
150
|
+
(1 font-lock-keyword-face))
|
151
|
+
("\\(\\[End of message\\]\\)"
|
152
|
+
(1 mhc-message-eof-marker-face))
|
153
|
+
("\\(X-SC-Subject:\\) *\\(.*\\)"
|
154
|
+
(1 font-lock-keyword-face)
|
155
|
+
(2 mhc-message-subject-face))
|
156
|
+
))
|
157
|
+
|
158
|
+
(defun mhc-mua-highlight-message (&optional for-draft)
|
159
|
+
"Hilight message in the current buffer.
|
160
|
+
If FOR-DRAFT is non-nil, Hilight message as draft message."
|
161
|
+
(set (make-local-variable 'font-lock-defaults)
|
162
|
+
'(mhc-message-font-lock-keywords t)))
|
163
|
+
|
164
|
+
(defalias 'mhc-mua-eword-decode-string 'rfc2047-decode-string)
|
165
|
+
|
166
|
+
(defun mhc-mua-decode-header ()
|
167
|
+
(save-restriction
|
168
|
+
(mhc-header-narrowing
|
169
|
+
(rfc2047-decode-region (point-min) (point-max)))))
|
170
|
+
|
171
|
+
;;; for mhc-draft
|
172
|
+
|
173
|
+
(defun mhc-mua-draft-setup-new ()
|
174
|
+
(insert mail-header-separator "\n"))
|
175
|
+
|
176
|
+
(defun mhc-mua-draft-reedit-buffer (buffer original)
|
177
|
+
;; If current buffer is specified as buffer, no need to replace.
|
178
|
+
(unless (eq (current-buffer) buffer)
|
179
|
+
(erase-buffer)
|
180
|
+
(insert-buffer-substring buffer))
|
181
|
+
(mhc-header-narrowing
|
182
|
+
(mhc-header-delete-header
|
183
|
+
"^\\(Content-.*\\|Mime-Version\\|User-Agent\\):" 'regexp)
|
184
|
+
(rfc2047-decode-region (point-min) (point-max)))
|
185
|
+
(goto-char (point-min))
|
186
|
+
(when (re-search-forward "^\r?$" nil t)
|
187
|
+
(insert mail-header-separator)))
|
188
|
+
|
189
|
+
(defun mhc-mua-draft-reedit-file (file)
|
190
|
+
(erase-buffer)
|
191
|
+
(insert-file-contents file)
|
192
|
+
(mhc-mua-draft-reedit-buffer (current-buffer) 'original))
|
193
|
+
|
194
|
+
(defun mhc-mua-draft-translate ()
|
195
|
+
"Convert an article in the current buffer to an ENCODED one.
|
196
|
+
ENCODED article should be valid for storeing to a mhc file.
|
197
|
+
This function can be empty for the current mhc, whereas
|
198
|
+
the old mhc was supposed to encode the article into MIME message."
|
199
|
+
(save-excursion
|
200
|
+
(goto-char (point-min))
|
201
|
+
(when (search-forward (concat "\n" mail-header-separator "\n") nil t)
|
202
|
+
(replace-match "\n\n"))))
|
203
|
+
|
204
|
+
;;; for mhc-calendar
|
205
|
+
|
206
|
+
(defun mhc-mua-goto-message (&optional view)
|
207
|
+
"Go to a view position on summary buffer."
|
208
|
+
(when view
|
209
|
+
(mhc-summary-display)))
|
210
|
+
|
211
|
+
(provide 'mhc-mua)
|
212
|
+
(put 'mhc-mua 'summary-filename 'mhc-mua-summary-filename)
|
213
|
+
(put 'mhc-mua 'summary-display-article 'mhc-mua-summary-display-article)
|
214
|
+
(put 'mhc-mua 'get-import-buffer 'mhc-mua-get-import-buffer)
|
215
|
+
(put 'mhc-mua 'highlight-message 'mhc-mua-highlight-message)
|
216
|
+
(put 'mhc-mua 'draft-mode 'mhc-mua-draft-mode)
|
217
|
+
(put 'mhc-mua 'generate-summary-buffer 'mhc-mua-generate-summary-buffer)
|
218
|
+
(put 'mhc-mua 'insert-summary-contents 'mhc-mua-insert-summary-contents)
|
219
|
+
(put 'mhc-mua 'summary-search-date 'mhc-mua-summary-search-date)
|
220
|
+
(put 'mhc-mua 'summary-mode-setup 'mhc-mua-summary-mode-setup)
|
221
|
+
(put 'mhc-mua 'draft-setup-new 'mhc-mua-draft-setup-new)
|
222
|
+
(put 'mhc-mua 'draft-reedit-buffer 'mhc-mua-draft-reedit-buffer)
|
223
|
+
(put 'mhc-mua 'draft-reedit-file 'mhc-mua-draft-reedit-file)
|
224
|
+
(put 'mhc-mua 'draft-translate 'mhc-mua-draft-translate)
|
225
|
+
(put 'mhc-mua 'eword-decode-string 'mhc-mua-eword-decode-string)
|
226
|
+
(put 'mhc-mua 'decode-header 'mhc-mua-decode-header)
|
227
|
+
(put 'mhc-mua 'goto-message 'mhc-mua-goto-message)
|
228
|
+
|
229
|
+
;;; Copyright Notice:
|
230
|
+
|
231
|
+
;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
|
232
|
+
;; Copyright (C) 2000 MHC developing team. All rights reserved.
|
233
|
+
|
234
|
+
;; Redistribution and use in source and binary forms, with or without
|
235
|
+
;; modification, are permitted provided that the following conditions
|
236
|
+
;; are met:
|
237
|
+
;;
|
238
|
+
;; 1. Redistributions of source code must retain the above copyright
|
239
|
+
;; notice, this list of conditions and the following disclaimer.
|
240
|
+
;; 2. Redistributions in binary form must reproduce the above copyright
|
241
|
+
;; notice, this list of conditions and the following disclaimer in the
|
242
|
+
;; documentation and/or other materials provided with the distribution.
|
243
|
+
;; 3. Neither the name of the team nor the names of its contributors
|
244
|
+
;; may be used to endorse or promote products derived from this software
|
245
|
+
;; without specific prior written permission.
|
246
|
+
;;
|
247
|
+
;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
|
248
|
+
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
249
|
+
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
250
|
+
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
251
|
+
;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
252
|
+
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
253
|
+
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
254
|
+
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
255
|
+
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
256
|
+
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
257
|
+
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
258
|
+
;; OF THE POSSIBILITY OF SUCH DAMAGE.
|
259
|
+
|
260
|
+
;;; mhc-mua.el ends here
|