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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +27 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -0
  5. data/COPYRIGHT +28 -0
  6. data/Gemfile +8 -0
  7. data/README.org +209 -0
  8. data/Rakefile +13 -0
  9. data/bin/mhc +312 -0
  10. data/emacs/Cask +25 -0
  11. data/emacs/Makefile +58 -0
  12. data/emacs/mhc-calendar.el +1723 -0
  13. data/emacs/mhc-calfw.el +135 -0
  14. data/emacs/mhc-compat.el +90 -0
  15. data/emacs/mhc-date.el +642 -0
  16. data/emacs/mhc-day.el +149 -0
  17. data/emacs/mhc-db.el +158 -0
  18. data/emacs/mhc-draft.el +211 -0
  19. data/emacs/mhc-e21.el +167 -0
  20. data/emacs/mhc-face.el +236 -0
  21. data/emacs/mhc-file.el +224 -0
  22. data/emacs/mhc-guess.el +648 -0
  23. data/emacs/mhc-header.el +176 -0
  24. data/emacs/mhc-logic.el +563 -0
  25. data/emacs/mhc-message.el +130 -0
  26. data/emacs/mhc-minibuf.el +466 -0
  27. data/emacs/mhc-misc.el +248 -0
  28. data/emacs/mhc-mua.el +260 -0
  29. data/emacs/mhc-parse.el +286 -0
  30. data/emacs/mhc-process.el +35 -0
  31. data/emacs/mhc-ps.el +1174 -0
  32. data/emacs/mhc-record.el +201 -0
  33. data/emacs/mhc-schedule.el +202 -0
  34. data/emacs/mhc-summary.el +763 -0
  35. data/emacs/mhc-sync.el +158 -0
  36. data/emacs/mhc-vars.el +149 -0
  37. data/emacs/mhc.el +1114 -0
  38. data/icons/Anniversary.xbm +6 -0
  39. data/icons/Anniversary.xpm +27 -0
  40. data/icons/Birthday.xbm +6 -0
  41. data/icons/Birthday.xpm +25 -0
  42. data/icons/Business.xbm +6 -0
  43. data/icons/Business.xpm +24 -0
  44. data/icons/CheckBox.xbm +6 -0
  45. data/icons/CheckBox.xpm +24 -0
  46. data/icons/CheckedBox.xbm +6 -0
  47. data/icons/CheckedBox.xpm +25 -0
  48. data/icons/Conflict.xbm +6 -0
  49. data/icons/Conflict.xpm +22 -0
  50. data/icons/Date.xbm +6 -0
  51. data/icons/Date.xpm +29 -0
  52. data/icons/Holiday.xbm +6 -0
  53. data/icons/Holiday.xpm +25 -0
  54. data/icons/Link.xbm +6 -0
  55. data/icons/Link.xpm +25 -0
  56. data/icons/Other.xbm +6 -0
  57. data/icons/Other.xpm +28 -0
  58. data/icons/Party.xbm +6 -0
  59. data/icons/Party.xpm +23 -0
  60. data/icons/Private.xbm +6 -0
  61. data/icons/Private.xpm +26 -0
  62. data/icons/Recurrence.xbm +6 -0
  63. data/icons/Recurrence.xpm +98 -0
  64. data/icons/Vacation.xbm +6 -0
  65. data/icons/Vacation.xpm +26 -0
  66. data/lib/mhc.rb +45 -0
  67. data/lib/mhc/builder.rb +64 -0
  68. data/lib/mhc/caldav.rb +304 -0
  69. data/lib/mhc/calendar.rb +106 -0
  70. data/lib/mhc/command.rb +13 -0
  71. data/lib/mhc/command/cache.rb +14 -0
  72. data/lib/mhc/command/completions.rb +108 -0
  73. data/lib/mhc/command/init.rb +133 -0
  74. data/lib/mhc/command/scan.rb +33 -0
  75. data/lib/mhc/command/sync.rb +22 -0
  76. data/lib/mhc/config.rb +229 -0
  77. data/lib/mhc/converter.rb +330 -0
  78. data/lib/mhc/datastore.rb +164 -0
  79. data/lib/mhc/date_enumerator.rb +274 -0
  80. data/lib/mhc/date_frame.rb +124 -0
  81. data/lib/mhc/date_helper.rb +49 -0
  82. data/lib/mhc/etag.rb +68 -0
  83. data/lib/mhc/event.rb +396 -0
  84. data/lib/mhc/formatter.rb +312 -0
  85. data/lib/mhc/logger.rb +94 -0
  86. data/lib/mhc/modifier.rb +149 -0
  87. data/lib/mhc/occurrence.rb +94 -0
  88. data/lib/mhc/occurrence_enumerator.rb +113 -0
  89. data/lib/mhc/property_value.rb +33 -0
  90. data/lib/mhc/property_value/date.rb +190 -0
  91. data/lib/mhc/property_value/integer.rb +15 -0
  92. data/lib/mhc/property_value/list.rb +41 -0
  93. data/lib/mhc/property_value/period.rb +49 -0
  94. data/lib/mhc/property_value/range.rb +100 -0
  95. data/lib/mhc/property_value/recurrence_condition.rb +272 -0
  96. data/lib/mhc/property_value/text.rb +11 -0
  97. data/lib/mhc/property_value/time.rb +45 -0
  98. data/lib/mhc/query.rb +210 -0
  99. data/lib/mhc/sync.rb +46 -0
  100. data/lib/mhc/sync/driver.rb +108 -0
  101. data/lib/mhc/sync/status.rb +70 -0
  102. data/lib/mhc/sync/status_manager.rb +142 -0
  103. data/lib/mhc/sync/strategy.rb +233 -0
  104. data/lib/mhc/sync/syncinfo.rb +98 -0
  105. data/lib/mhc/templates/config.yml.erb +142 -0
  106. data/lib/mhc/version.rb +4 -0
  107. data/lib/mhc/webdav.rb +319 -0
  108. data/mhc.gemspec +24 -0
  109. data/samples/DOT.mhc-config.yml +116 -0
  110. data/samples/japanese-holidays.mhcc +153 -0
  111. data/samples/mhc-completions.zsh +11 -0
  112. data/spec/mhc_spec.rb +682 -0
  113. data/spec/spec_helper.rb +9 -0
  114. data/xpm/close.xpm +18 -0
  115. data/xpm/delete.xpm +19 -0
  116. data/xpm/exit.xpm +18 -0
  117. data/xpm/month.xpm +18 -0
  118. data/xpm/next.xpm +18 -0
  119. data/xpm/next2.xpm +18 -0
  120. data/xpm/next_year.xpm +18 -0
  121. data/xpm/open.xpm +19 -0
  122. data/xpm/prev.xpm +18 -0
  123. data/xpm/prev2.xpm +18 -0
  124. data/xpm/prev_year.xpm +18 -0
  125. data/xpm/save.xpm +19 -0
  126. data/xpm/today.xpm +18 -0
  127. metadata +214 -0
data/emacs/mhc-e21.el ADDED
@@ -0,0 +1,167 @@
1
+ ;;; mhc-e21.el -- Emacs 21 stuff for MHC.
2
+
3
+ ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
4
+ ;;
5
+ ;; Created: 2000/11/21
6
+ ;; Revised: $Date: 2008/03/06 09:40:12 $
7
+
8
+ (defcustom mhc-e21-icon-alist
9
+ '(("Conflict" . "Conflict.xpm")
10
+ ("Recurrence" . "Recurrence.xpm")
11
+ ("Private" . "Private.xpm")
12
+ ("Holiday" . "Holiday.xpm")
13
+ ("Todo" . "CheckBox.xpm")
14
+ ("Done" . "CheckedBox.xpm")
15
+ ("Link" . "Link.xpm"))
16
+ "*Alist to define icons.
17
+ Each element should have the form
18
+ (NAME . ICON-FILE)
19
+ It defines icon named NAME created from ICON-FILE.
20
+ Example:
21
+ '((\"Holiday\" . \"Holiday.xpm\")
22
+ (\"Work\" . \"Business.xpm\")
23
+ (\"Private\" . \"Private.xpm\")
24
+ (\"Anniversary\" . \"Anniversary.xpm\")
25
+ (\"Birthday\" . \"Birthday.xpm\")
26
+ (\"Other\" . \"Other.xpm\")
27
+ (\"Todo\" . \"CheckBox.xpm\")
28
+ (\"Done\" . \"CheckedBox.xpm\")
29
+ (\"Conflict\" . \"Conflict.xpm\"))"
30
+ :group 'mhc
31
+ :type '(repeat
32
+ :inline t
33
+ (cons (string :tag "Icon Name")
34
+ (string :tag "XPM File Name"))))
35
+
36
+ (defcustom mhc-icon-function-alist
37
+ '(("Link" . mhc-browse-x-url))
38
+ "*Alist to define callback function for icons.
39
+ Each element should have the form
40
+ (NAME . FUNCTION)
41
+ If the icon named NAME is clicked, then FUNCTION is invoked at
42
+ icon line."
43
+ :group 'mhc
44
+ :type '(repeat
45
+ :inline t
46
+ (cons (string :tag "Icon Name")
47
+ (function :tag "Function"))))
48
+
49
+ (defvar mhc-e21-icon-keymap nil)
50
+ (if (null mhc-e21-icon-keymap)
51
+ (setq mhc-e21-icon-keymap (make-sparse-keymap)))
52
+ (define-key mhc-e21-icon-keymap [mouse-1] 'mhc-e21-icon-call-function)
53
+ (define-key mhc-e21-icon-keymap [mouse-2] 'mhc-e21-icon-call-function)
54
+
55
+ (defun mhc-e21-icon-call-function (event)
56
+ (interactive "e")
57
+ (save-excursion
58
+ (mouse-set-point event)
59
+ (when (get-text-property (point) 'mhc-e21-icon-function)
60
+ (call-interactively
61
+ (get-text-property (point) 'mhc-e21-icon-function))
62
+ t)))
63
+
64
+ ;; internal variable.
65
+ (defvar mhc-e21/icon-glyph-alist nil)
66
+ (defvar mhc-e21/icon-function-alist nil)
67
+
68
+ (defsubst mhc-e21/setup-icons ()
69
+ (let ((alist mhc-e21-icon-alist)
70
+ name image
71
+ (load-path (cons mhc-icon-path load-path)))
72
+ (setq mhc-e21/icon-glyph-alist nil)
73
+ (while alist
74
+ (setq image (find-image (list (list
75
+ :type 'xpm
76
+ :file (cdr (car alist))
77
+ :ascent 'center))))
78
+ (when image
79
+ (setq mhc-e21/icon-glyph-alist
80
+ (cons
81
+ (cons (downcase (car (car alist))) image)
82
+ mhc-e21/icon-glyph-alist)))
83
+ (setq alist (cdr alist)))
84
+ (setq mhc-e21/icon-function-alist
85
+ (mapcar (lambda (pair)
86
+ (cons (downcase (car pair)) (cdr pair)))
87
+ mhc-icon-function-alist))))
88
+
89
+ ;; Icon interface
90
+ (defun mhc-icon-setup ()
91
+ "Initialize MHC icons."
92
+ (interactive)
93
+ (if (called-interactively-p 'interactive)
94
+ (setq mhc-e21/icon-glyph-alist nil))
95
+ (or mhc-e21/icon-glyph-alist
96
+ (progn
97
+ (message "Initializing MHC icons...")
98
+ (mhc-e21/setup-icons)
99
+ (run-hooks 'mhc-icon-setup-hook)
100
+ (message "Initializing MHC icons...done"))))
101
+
102
+ (defun mhc-use-icon-p ()
103
+ "Returns t if MHC displays icon."
104
+ (and (display-graphic-p)
105
+ (image-type-available-p 'xpm)
106
+ mhc-use-icon))
107
+
108
+ (defun mhc-icon-exists-p (name)
109
+ "Returns non-nil if icon with NAME exists."
110
+ (cdr (assoc (downcase name) mhc-e21/icon-glyph-alist)))
111
+
112
+ (defun mhc-put-icon (icons)
113
+ "Put ICONS on current buffer.
114
+ Icon is decided by `mhc-e21-icon-alist'."
115
+ (let (icon pos func props)
116
+ (while icons
117
+ (when (setq icon (cdr (assoc (downcase (car icons))
118
+ mhc-e21/icon-glyph-alist)))
119
+ (setq pos (point))
120
+ (insert (make-string (floor (car (image-size icon))) ? ))
121
+ (setq props (list 'display icon
122
+ 'invisible nil
123
+ 'intangible icon))
124
+ (when (setq func (cdr (assoc (downcase (car icons))
125
+ mhc-e21/icon-function-alist)))
126
+ (setq props (nconc props
127
+ (list
128
+ 'mouse-face 'highlight
129
+ 'mhc-e21-icon-function func
130
+ 'local-map mhc-e21-icon-keymap))))
131
+ (add-text-properties pos (point) props))
132
+ (setq icons (cdr icons)))))
133
+
134
+ (provide 'mhc-e21)
135
+
136
+ ;;; Copyright Notice:
137
+
138
+ ;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
139
+ ;; Copyright (C) 2000 MHC developing team. All rights reserved.
140
+
141
+ ;; Redistribution and use in source and binary forms, with or without
142
+ ;; modification, are permitted provided that the following conditions
143
+ ;; are met:
144
+ ;;
145
+ ;; 1. Redistributions of source code must retain the above copyright
146
+ ;; notice, this list of conditions and the following disclaimer.
147
+ ;; 2. Redistributions in binary form must reproduce the above copyright
148
+ ;; notice, this list of conditions and the following disclaimer in the
149
+ ;; documentation and/or other materials provided with the distribution.
150
+ ;; 3. Neither the name of the team nor the names of its contributors
151
+ ;; may be used to endorse or promote products derived from this software
152
+ ;; without specific prior written permission.
153
+ ;;
154
+ ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
155
+ ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
156
+ ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
157
+ ;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
158
+ ;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
159
+ ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
160
+ ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
161
+ ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
162
+ ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
163
+ ;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
164
+ ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
165
+ ;; OF THE POSSIBILITY OF SUCH DAMAGE.
166
+
167
+ ;;; mhc-e21.el ends here
data/emacs/mhc-face.el ADDED
@@ -0,0 +1,236 @@
1
+ ;;; mhc-face.el
2
+
3
+ ;; Author: Yoshinari Nomura <nom@quickhack.net>
4
+ ;;
5
+ ;; Created: 2000/02/08
6
+ ;; Revised: $Date: 2004/05/04 13:48:31 $
7
+
8
+ ;;;
9
+ ;;; Commentay:
10
+ ;;;
11
+
12
+ ;;;
13
+ ;;; Code:
14
+ ;;;
15
+
16
+ (defvar mhc-symbol-face-alist nil
17
+ "*Alist which is used in setup time to define required faces.
18
+ Each element should have the form
19
+ (FACE-SYMBOL . (PARENT FG BG UNDERLINED FONT STIPPLE))
20
+ If this variable does't have necessary face definitions for mhc,
21
+ mhc will lookup them from mhc-symbol-face-alist-internal instead.
22
+ So, this variable doesn't have to cover all the face definitions.")
23
+
24
+ (defvar mhc-category-face-alist nil
25
+ "*Alist to rule the catgegory-to-face conversion.
26
+ Each element should have the form
27
+ (CATEGORY-STRING . (PARENT FG BG UNDERLINED FONT STIPPLE))
28
+ mhc will define mhc-summary-category-face-(downcase CATEGORY-STRING)
29
+ in setup time.")
30
+
31
+ (defvar mhc-calendar-hnf-face-alist nil
32
+ "*Alist of HNS faces. Each element should have the form
33
+ (FACE-SYMBOL . (PARENT FG BG UNDERLINED FONT STIPPLE)).
34
+ refer to mhc-calendar-hnf-face-alist-internal.")
35
+
36
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37
+ ;; for necessary faces.
38
+
39
+ (defconst mhc-symbol-face-alist-internal
40
+ '((mhc-calendar-face-default . (nil nil nil))
41
+ (mhc-calendar-face-saturday . (nil "blue" nil))
42
+ (mhc-calendar-face-sunday . (nil "red" nil))
43
+ (mhc-calendar-face-duration . (nil nil "gray"))
44
+ (mhc-calendar-face-cw . (nil "slate gray" nil))
45
+ ;;
46
+ (mhc-summary-face-default . (nil nil nil))
47
+ (mhc-summary-face-saturday . (nil "blue" nil))
48
+ (mhc-summary-face-sunday . (nil "red" nil))
49
+ (mhc-summary-face-today . (nil "black" "chocolate"))
50
+ (mhc-summary-face-cw . (nil "slate gray" nil))
51
+ ;;
52
+ (mhc-summary-face-separator . (nil "gray" nil))
53
+ (mhc-summary-face-month-separator . (nil "DarkKhaki" nil))
54
+ (mhc-summary-face-time . (nil "yellowgreen" nil))
55
+ (mhc-summary-face-location . (nil "black" "paleturquoise"))
56
+ (mhc-summary-face-conflict . (nil "white" "purple"))
57
+ (mhc-summary-face-recurrence . (nil "black" "green"))
58
+ (mhc-summary-face-secret . (nil "gray" nil))
59
+ ;;
60
+ (mhc-minibuf-face-candidate . (nil nil "yellow"))
61
+ ;;
62
+ (mhc-category-face-holiday . (nil "red" nil))))
63
+
64
+ (defconst mhc-calendar-hnf-face-alist-internal
65
+ '((mhc-calendar-hnf-face-mark . (nil "MediumSeaGreen" nil))
66
+ (mhc-calendar-hnf-face-newtag . (italic "red" "paleturquoise"))
67
+ (mhc-calendar-hnf-face-subtag . (italic "blue" nil))
68
+ (mhc-calendar-hnf-face-cat . (nil "DarkGreen" nil))
69
+ (mhc-calendar-hnf-face-new . (bold "DarkGreen" nil))
70
+ (mhc-calendar-hnf-face-sub . (nil "DarkGreen" nil))
71
+ (mhc-calendar-hnf-face-uri . (italic "blue" nil))))
72
+
73
+ (defmacro mhc-face-put (symbol face)
74
+ `(put-text-property 0 (length ,symbol) 'face ,face ,symbol))
75
+
76
+ (eval-when-compile
77
+ (cond
78
+ ((featurep 'xemacs)
79
+ ;; XEmacs 21.2 (make-face-bold FACE &optional LOCALE TAGS)
80
+ ;; XEmacs 21.1 (make-face-bold FACE &optional LOCALE)
81
+ (defmacro mhc-face/make-face-bold (face)
82
+ `(make-face-bold ,face))
83
+ (defmacro mhc-face/make-face-italic (face)
84
+ `(make-face-italic ,face))
85
+ (defmacro mhc-face/make-face-bold-italic (face)
86
+ `(make-face-bold-italic ,face)))
87
+ (t
88
+ ;; (make-face-bold FACE &optional FRAME NOERROR)
89
+ (defmacro mhc-face/make-face-bold (face)
90
+ `(make-face-bold ,face nil t))
91
+ (defmacro mhc-face/make-face-italic (face)
92
+ `(make-face-italic ,face nil t))
93
+ (defmacro mhc-face/make-face-bold-italic (face)
94
+ `(make-face-bold-italic ,face nil t)))))
95
+
96
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97
+ ;; make faces from string/symbol
98
+
99
+ (defun mhc-face-category-to-face (category)
100
+ (if category
101
+ (or (intern-soft (format "mhc-category-face-%s" (downcase category)))
102
+ 'default)
103
+ 'default))
104
+
105
+ (defun mhc-face-make-face-from-string (string prop &optional overwrite prefix)
106
+ (let ((symbol-name (concat prefix (if prefix "-") string)))
107
+ (mhc-face-make-face-from-symbol (intern symbol-name) prop overwrite)))
108
+
109
+ (defun mhc-face-make-face-from-symbol (symbol prop &optional overwrite)
110
+ (let ((parent (nth 0 prop))
111
+ (fg (nth 1 prop))
112
+ (bg (nth 2 prop))
113
+ (uline (nth 3 prop))
114
+ (font (nth 4 prop))
115
+ (stipple (nth 5 prop))
116
+ (face nil))
117
+ (if (and (facep symbol) (not overwrite))
118
+ symbol
119
+ (setq face (if parent (copy-face parent symbol) (make-face symbol)))
120
+ (if fg (set-face-foreground face fg))
121
+ (if bg (set-face-background face bg))
122
+ (set-face-underline face uline)
123
+ (if font (set-face-font face font))
124
+ (if stipple (set-face-stipple face stipple))
125
+ face)))
126
+
127
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
128
+ ;; make faces arrange.
129
+
130
+ (defvar mhc-face-effect-alist
131
+ ;; fg bg bold talic ul
132
+ '((today . (nil "gray" nil nil nil))
133
+ (busy . (nil nil t nil nil))
134
+ (saturday . ("Blue" nil nil nil nil))
135
+ (sunday . ("Red" nil nil nil nil))))
136
+
137
+ ;; get decolated face from face and effect
138
+ ;; ex. mhc-summary-face + today -> mhc-summary-face-today
139
+ (defun mhc-face-get-effect (face effect)
140
+ (let ((new-face (intern (concat
141
+ (symbol-name face) "-"
142
+ (symbol-name effect))))
143
+ effect-list)
144
+ (if (facep new-face)
145
+ ()
146
+ (copy-face face new-face)
147
+ (if (setq effect-list (cdr (assq effect mhc-face-effect-alist)))
148
+ (let ((fg (nth 0 effect-list))
149
+ (bg (nth 1 effect-list))
150
+ (bl (nth 2 effect-list))
151
+ (it (nth 3 effect-list))
152
+ (ul (nth 4 effect-list)))
153
+ (if fg (set-face-foreground new-face fg))
154
+ (if bg (set-face-background new-face bg))
155
+ (if ul (set-face-underline new-face t))
156
+ ;;
157
+ (if bl (or (mhc-face/make-face-bold new-face)
158
+ (and (fboundp 'set-face-bold-p)
159
+ (set-face-bold-p new-face t))))
160
+ ;;
161
+ (if it (or (mhc-face/make-face-italic new-face)
162
+ (and (fboundp 'set-face-italic-p)
163
+ (set-face-italic-p new-face t)))))))
164
+ new-face))
165
+ ;;
166
+ ;; (make-face-italic new-face nil t))))
167
+
168
+ (defsubst mhc-face-get-today-face (face)
169
+ (mhc-face-get-effect face 'today))
170
+
171
+ (defsubst mhc-face-get-busy-face (face)
172
+ (mhc-face-get-effect face 'busy))
173
+
174
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
175
+ ;; setup faces.
176
+
177
+ (defun mhc-face-setup ()
178
+ (interactive)
179
+ (let ((ow (called-interactively-p 'interactive)))
180
+ ;;
181
+ (mhc-face-setup-internal mhc-symbol-face-alist ow)
182
+ (mhc-face-setup-internal mhc-category-face-alist ow)
183
+ ;;
184
+ (mhc-face-setup-internal mhc-symbol-face-alist-internal nil)
185
+ ))
186
+
187
+ (defun mhc-face-setup-internal (alist &optional overwrite)
188
+ (let (lst)
189
+ (while (setq lst (car alist))
190
+ (cond
191
+ ((stringp (car lst))
192
+ (mhc-face-make-face-from-string
193
+ (format "mhc-category-face-%s" (downcase (car lst)))
194
+ (cdr lst)
195
+ overwrite))
196
+ ((symbolp (car lst))
197
+ (mhc-face-make-face-from-symbol
198
+ (car lst)
199
+ (cdr lst)
200
+ overwrite)))
201
+ (setq alist (cdr alist)))))
202
+
203
+ (provide 'mhc-face)
204
+
205
+ ;;; Copyright Notice:
206
+
207
+ ;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
208
+ ;; Copyright (C) 2000 MHC developing team. All rights reserved.
209
+
210
+ ;; Redistribution and use in source and binary forms, with or without
211
+ ;; modification, are permitted provided that the following conditions
212
+ ;; are met:
213
+ ;;
214
+ ;; 1. Redistributions of source code must retain the above copyright
215
+ ;; notice, this list of conditions and the following disclaimer.
216
+ ;; 2. Redistributions in binary form must reproduce the above copyright
217
+ ;; notice, this list of conditions and the following disclaimer in the
218
+ ;; documentation and/or other materials provided with the distribution.
219
+ ;; 3. Neither the name of the team nor the names of its contributors
220
+ ;; may be used to endorse or promote products derived from this software
221
+ ;; without specific prior written permission.
222
+ ;;
223
+ ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
224
+ ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
225
+ ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
226
+ ;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
227
+ ;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
228
+ ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
229
+ ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
230
+ ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231
+ ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
232
+ ;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
233
+ ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
234
+ ;; OF THE POSSIBILITY OF SUCH DAMAGE.
235
+
236
+ ;;; mhc-face.el ends here
data/emacs/mhc-file.el ADDED
@@ -0,0 +1,224 @@
1
+ ;;; -*- mode: Emacs-Lisp; coding: utf-8 -*-
2
+
3
+ ;; Author: Yoshinari Nomura <nom@quickhack.net>,
4
+ ;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>
5
+ ;; Created: 2000/05/01
6
+ ;; Revised: $Date$
7
+
8
+
9
+ ;;; Comments:
10
+
11
+ ;; This file is a part of MHC, and includes functions to manipulate
12
+ ;; files of schedules.
13
+
14
+
15
+ ;;; About Backend:
16
+
17
+ ;; このライブラリは、実際にファイルを操作するバックエンドを呼び出すこ
18
+ ;; とによって動作する。バックエンドは、以下のようなメソッドを提供する
19
+ ;; ことが期待されている。
20
+ ;;
21
+ ;; (mhc-foo/init)
22
+ ;; ネットワークの状態に依存しない初期化処理を行う関数
23
+ ;;
24
+ ;; (mhc-foo/exit)
25
+ ;; ネットワークの状態に依存しない終了処理を行う関数
26
+ ;;
27
+ ;; (mhc-foo/open &optional OFFLINE)
28
+ ;; ネットワークの状態に依存する初期化処理を行う関数
29
+ ;;
30
+ ;; (mhc-foo/close &optional OFFLINE)
31
+ ;; ネットワークの状態に依存する終了処理を行う関数
32
+ ;;
33
+ ;; (mhc-foo/sync)
34
+ ;; スケジュールファイルの同期を取る関数
35
+ ;;
36
+ ;; (mhc-foo/add FILENAME &optional OFFLINE)
37
+ ;; ファイルを追加を通知する関数
38
+ ;; (ファイルの実体は追加された後に呼び出される)
39
+ ;;
40
+ ;; (mhc-foo/modify FILENAME &optional OFFLINE)
41
+ ;; ファイルの変更を通知する関数
42
+ ;; (ファイルの実体が変更された後に呼び出される)
43
+ ;;
44
+ ;; (mhc-foo/remove FILENAME &optional OFFLINE)
45
+ ;; ファイルを削除する関数
46
+ ;; (ファイルの実体は *削除されずに* 呼び出される)
47
+ ;;
48
+ ;; これらのメソッドを適切に定義し、更に以下のような宣言を付け加える。
49
+ ;;
50
+ ;; (provide 'mhc-foo)
51
+ ;; (put 'mhc-foo 'init 'mhc-foo/init)
52
+ ;; (put 'mhc-foo 'exit 'mhc-foo/exit)
53
+ ;; (put 'mhc-foo 'open 'mhc-foo/open)
54
+ ;; (put 'mhc-foo 'close 'mhc-foo/close)
55
+ ;; (put 'mhc-foo 'sync 'mhc-foo/sync)
56
+ ;; (put 'mhc-foo 'add 'mhc-foo/add)
57
+ ;; (put 'mhc-foo 'modify 'mhc-foo/modify)
58
+ ;; (put 'mhc-foo 'remove 'mhc-foo/remove)
59
+ ;;
60
+ ;; メソッドの関数名は任意に選ぶことができる。
61
+ ;;
62
+ ;; また、メソッドの定義は省略することができる。省略されたメソッドは、
63
+ ;; 関数 mhc-file/true によって置換され、その処理は常に成功したものと見
64
+ ;; なされる。
65
+
66
+
67
+ ;;; Definition
68
+ (require 'mhc-compat)
69
+ (require 'mhc-vars)
70
+
71
+ ;;; Code:
72
+
73
+ ;;; Global Variables
74
+ (defcustom mhc-file-method 'mhc-sync
75
+ "*Variable to specify the method to control schdule files."
76
+ :group 'mhc
77
+ :type '(radio (const :tag "Backup and remove" mhc-sync)
78
+ (symbol :tag "Other")))
79
+
80
+ (defcustom mhc-file-sync-enable-offline nil
81
+ "*If non-nil, enable mhc-file-sync when status is offline."
82
+ :group 'mhc
83
+ :type '(radio (const :tag "Disable when offline" nil)
84
+ (const :tag "Enable when offline" t)))
85
+
86
+ ;;; Internal Variables
87
+ (defvar mhc-file/offline (not mhc-default-network-status)
88
+ "Keep current line status.")
89
+
90
+
91
+ ;;; Codes
92
+ (defun mhc-file/true (&rest arguments)
93
+ "Dummy function for undefind backend functions."
94
+ t)
95
+
96
+ (defconst mhc-file/backend-method-list
97
+ '(init exit open close sync add modify remove))
98
+
99
+ ;; To suprress byte compile warnings.
100
+ (eval-when-compile
101
+ (mapcar (lambda (s)
102
+ (let ((f (intern (concat "mhc-file/" (symbol-name s)))))
103
+ (or (fboundp f) (fset f 'mhc-file/true))))
104
+ mhc-file/backend-method-list))
105
+
106
+ (defun mhc-file-setup (&optional method)
107
+ "Initialize backend to manipulate files."
108
+ (require (or method mhc-file-method))
109
+ (mapc (lambda (s)
110
+ (fset (intern (concat "mhc-file/" (symbol-name s)))
111
+ (or (get mhc-file-method s) 'mhc-file/true)))
112
+ mhc-file/backend-method-list)
113
+ (and (mhc-file/init)
114
+ (mhc-file/open mhc-file/offline)))
115
+
116
+ (defun mhc-file-exit ()
117
+ "Exit backend to manipulate files."
118
+ (and (mhc-file/close mhc-file/offline)
119
+ (mhc-file/exit)))
120
+
121
+ (defmacro mhc-file-add (file)
122
+ `(mhc-file/add ,file mhc-file/offline))
123
+ (defmacro mhc-file-modify (file)
124
+ `(mhc-file/modify ,file mhc-file/offline))
125
+ (defmacro mhc-file-remove (file)
126
+ `(mhc-file/remove ,file mhc-file/offline))
127
+
128
+ (defcustom mhc-file-line-status-strings
129
+ '(" mhc[offline]" . " mhc[ONLINE]")
130
+ "Strings to describe MHC network status."
131
+ :group 'mhc
132
+ :type '(choice
133
+ (const :tag "Long format" (" mhc[offline]" . " mhc[ONLINE]"))
134
+ (const :tag "Short format" (" Mhc" . " MHC"))
135
+ (cons :tag "User definition"
136
+ (string :tag "String for offline")
137
+ (string :tag "String for online")))
138
+ :set (lambda (symbol value)
139
+ (set-default symbol value)
140
+ (if (assq 'mhc-mode minor-mode-alist)
141
+ (setcdr (assq 'mhc-mode minor-mode-alist) (list (mhc-file-line-status))))
142
+ (force-mode-line-update)))
143
+
144
+ (defun mhc-file-line-status ()
145
+ "Return status string for mode line."
146
+ (if mhc-show-network-status
147
+ (if mhc-file/offline
148
+ (car mhc-file-line-status-strings)
149
+ (cdr mhc-file-line-status-strings))))
150
+
151
+ (defun mhc-file-toggle-offline (&optional full set-to no-sync)
152
+ "*Toggle line status of file manipulation backend."
153
+ (interactive (list current-prefix-arg (not mhc-file/offline)))
154
+ (let ((previous mhc-file/offline))
155
+ (setq mhc-file/offline set-to)
156
+ (if (assq 'mhc-mode minor-mode-alist)
157
+ (setcdr (assq 'mhc-mode minor-mode-alist)
158
+ (list (mhc-file-line-status))))
159
+ (if mhc-file/offline
160
+ (message "mhc-file is offline.")
161
+ (if (and (not no-sync)
162
+ previous
163
+ (y-or-n-p "Sync schedule files right now ? "))
164
+ (mhc-file-sync full))
165
+ (message "mhc-file is online."))))
166
+
167
+
168
+ (defun mhc-file-sync (&optional full)
169
+ "*Sync schedule files."
170
+ (interactive "P")
171
+ (if (and mhc-file/offline (not mhc-file-sync-enable-offline))
172
+ (message "\"M-x mhc-file-toggle-offline\" first.")
173
+ (message "mhc file sync...")
174
+ (when (mhc-file/sync full)
175
+ (message "mhc file sync...done"))))
176
+
177
+
178
+ ;; almost same as (make-directory dirname t)
179
+ (defun mhc-file-make-directory (dirname)
180
+ (if (file-directory-p dirname)
181
+ t
182
+ (if (mhc-file-make-directory
183
+ (directory-file-name (file-name-directory (directory-file-name dirname))))
184
+ (progn
185
+ (make-directory (directory-file-name dirname))
186
+ (mhc-file-add (file-name-as-directory dirname))
187
+ t))))
188
+
189
+
190
+
191
+ (provide 'mhc-file)
192
+
193
+ ;;; Copyright Notice:
194
+
195
+ ;; Copyright (C) 1999, 2000 Yoshinari Nomura. All rights reserved.
196
+ ;; Copyright (C) 2000 MHC developing team. All rights reserved.
197
+
198
+ ;; Redistribution and use in source and binary forms, with or without
199
+ ;; modification, are permitted provided that the following conditions
200
+ ;; are met:
201
+ ;;
202
+ ;; 1. Redistributions of source code must retain the above copyright
203
+ ;; notice, this list of conditions and the following disclaimer.
204
+ ;; 2. Redistributions in binary form must reproduce the above copyright
205
+ ;; notice, this list of conditions and the following disclaimer in the
206
+ ;; documentation and/or other materials provided with the distribution.
207
+ ;; 3. Neither the name of the team nor the names of its contributors
208
+ ;; may be used to endorse or promote products derived from this software
209
+ ;; without specific prior written permission.
210
+ ;;
211
+ ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS''
212
+ ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
213
+ ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
214
+ ;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
215
+ ;; THE TEAM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
216
+ ;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
217
+ ;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
218
+ ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
219
+ ;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
220
+ ;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
221
+ ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
222
+ ;; OF THE POSSIBILITY OF SUCH DAMAGE.
223
+
224
+ ;;; mhc-file.el ends here