mhc 1.1.1 → 1.2.4

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 (57) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/bin/mhc +82 -3
  4. data/emacs/Cask +1 -1
  5. data/emacs/mhc-calendar.el +7 -5
  6. data/emacs/mhc-date.el +5 -12
  7. data/emacs/mhc-day.el +1 -1
  8. data/emacs/mhc-db.el +57 -38
  9. data/emacs/mhc-draft.el +36 -22
  10. data/emacs/mhc-face.el +1 -1
  11. data/emacs/mhc-header.el +20 -1
  12. data/emacs/mhc-minibuf.el +12 -7
  13. data/emacs/mhc-parse.el +1 -1
  14. data/emacs/mhc-process.el +26 -9
  15. data/emacs/mhc-ps.el +1 -1
  16. data/emacs/mhc-record.el +1 -1
  17. data/emacs/mhc-schedule.el +5 -2
  18. data/emacs/mhc-summary.el +36 -16
  19. data/emacs/mhc-vars.el +15 -2
  20. data/emacs/mhc.el +51 -25
  21. data/lib/mhc.rb +3 -1
  22. data/lib/mhc/builder.rb +5 -1
  23. data/lib/mhc/caldav.rb +1 -1
  24. data/lib/mhc/calendar.rb +5 -1
  25. data/lib/mhc/command/cache.rb +5 -4
  26. data/lib/mhc/command/completions.rb +1 -1
  27. data/lib/mhc/command/init.rb +2 -0
  28. data/lib/mhc/converter.rb +3 -2
  29. data/lib/mhc/datastore.rb +52 -13
  30. data/lib/mhc/date_enumerator.rb +2 -2
  31. data/lib/mhc/event.rb +42 -21
  32. data/lib/mhc/formatter.rb +17 -312
  33. data/lib/mhc/formatter/base.rb +125 -0
  34. data/lib/mhc/formatter/emacs.rb +47 -0
  35. data/lib/mhc/formatter/howm.rb +35 -0
  36. data/lib/mhc/formatter/icalendar.rb +17 -0
  37. data/lib/mhc/formatter/json.rb +27 -0
  38. data/lib/mhc/formatter/mail.rb +20 -0
  39. data/lib/mhc/formatter/org_table.rb +24 -0
  40. data/lib/mhc/formatter/symbolic_expression.rb +42 -0
  41. data/lib/mhc/formatter/text.rb +29 -0
  42. data/lib/mhc/modifier.rb +1 -0
  43. data/lib/mhc/occurrence.rb +27 -5
  44. data/lib/mhc/occurrence_enumerator.rb +1 -1
  45. data/lib/mhc/property_value.rb +6 -0
  46. data/lib/mhc/property_value/date.rb +23 -14
  47. data/lib/mhc/property_value/date_time.rb +19 -0
  48. data/lib/mhc/property_value/integer.rb +5 -1
  49. data/lib/mhc/property_value/list.rb +7 -6
  50. data/lib/mhc/property_value/period.rb +3 -1
  51. data/lib/mhc/property_value/range.rb +1 -1
  52. data/lib/mhc/property_value/time.rb +8 -1
  53. data/lib/mhc/version.rb +1 -1
  54. data/mhc.gemspec +0 -1
  55. data/samples/japanese-holidays.mhcc +36 -9
  56. data/spec/mhc_spec.rb +83 -0
  57. metadata +13 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7c9ab546227bfcd6c56b48af0bd308d2219214c3
4
- data.tar.gz: 0ec52f413f4e033d96032450fcc07c75d7fa2d60
2
+ SHA256:
3
+ metadata.gz: 4522630272ecdc9d44c9b994b2b31f8e36278abb0004708ec0e39d63e5d16792
4
+ data.tar.gz: cbcd079db569d336eec4eb87f21e5598cd3735b04f0fef6ffbbc8b7fdb583067
5
5
  SHA512:
6
- metadata.gz: 70dbddc76e2f44969dc11cd233d402bc4de639ff1e5870c7044c6c8cad813149d342706f5040cce6ec642666828fdbe104d8dc50e76fb30f9bab57a00790ab5a
7
- data.tar.gz: ce91e6cbca1ca392399d259a21c5bab7247846fbe22611c1242fe5ee85f61439c5dcca8940bcfbf3651f34021146bdba669bfd0a700e606e3aac53bae3a53ed5
6
+ metadata.gz: 1f052c78047e59e8638248ef56928f2ee3e85ae544b959d294c6900afb06868cb305a4a23b1ae85a35d963b870dbb0ec950c4c1d5cd9ea25d9ffe07334be5cd8
7
+ data.tar.gz: 874b007618cfd8be8a49ba0fab497ba38f6a36edfedbedf0ec72bb983c6c5ceff67a52c2b6138a62ced23fb0586e5f644eca018e2d9b963a8d79666100b94b9a
data/.gitignore CHANGED
@@ -5,7 +5,7 @@
5
5
  .bundle
6
6
  .config
7
7
  .yardoc
8
- Gemfile.lock
8
+ Gemfile.lock*
9
9
  InstalledFiles
10
10
  _yardoc
11
11
  attic/
data/bin/mhc CHANGED
@@ -110,9 +110,48 @@ class MhcCLI < Thor
110
110
  named_option :repository
111
111
 
112
112
  def cache
113
- Mhc::Command::Cache.new(calendar)
113
+ Mhc::Command::Cache.new(builder.datastore)
114
114
  end
115
115
 
116
+ # Command: todo
117
+ desc "todo", "List Todo entries in MHC calendar"
118
+
119
+ named_option :repository
120
+ method_option :show_all, :desc => "Include all finished tasks."
121
+
122
+ def todo
123
+ todos = []
124
+ calendar.tasks.each do |task|
125
+ if task.recurring?
126
+ # Yearly: today - 90days .. today + 365d - 90days ?
127
+ # Weekly: today - 7days .. today + 7days
128
+ search_range = Mhc::PropertyValue::Date.parse_range("today+365d")
129
+ # search_range = nil
130
+ else
131
+ search_range = nil
132
+ end
133
+ next if task.in_category?("done") && !options[:show_all]
134
+ todos << task.occurrences(range: search_range).first
135
+ end
136
+ todos.each.sort{|a, b| a.dtstart <=> b.dtstart}.each do |t|
137
+ deadline = t.dtstart
138
+ deadline_string = ""
139
+ remaining = (deadline - Mhc::PropertyValue::Date.today).to_i
140
+ if remaining == 0
141
+ deadline_string = " (due this date)"
142
+ elsif remaining > 0
143
+ deadline_string = format(" (%d days to go)", remaining)
144
+ else
145
+ deadline_string = format(" (%d days overdue)", -remaining)
146
+ end
147
+ location_string = " [#{t.location}]" if !t.location.empty?
148
+ puts format("%s %-11s %s%s%s",
149
+ deadline.strftime("%Y/%m/%d %a"),
150
+ t.time_range.to_mhc_string,
151
+ t.subject, location_string, deadline_string)
152
+ end
153
+ end # todo
154
+
116
155
  ################################################################
117
156
  # Command: completions
118
157
  ################################################################
@@ -185,7 +224,7 @@ class MhcCLI < Thor
185
224
  def scan(range)
186
225
  begin
187
226
  Mhc::Command::Scan.new(calendar, range, **symbolize_keys(options))
188
- rescue Mhc::PropertyValue::ParseError, Mhc::FormatterNameError, Mhc::Query::ParseError => e
227
+ rescue Mhc::PropertyValue::ParseError, Mhc::Formatter::NameError, Mhc::Query::ParseError => e
189
228
  STDERR.print "Error: " + e.message + "\n"
190
229
  end
191
230
  return self
@@ -236,6 +275,40 @@ class MhcCLI < Thor
236
275
  return self
237
276
  end
238
277
 
278
+ ################################################################
279
+ # Command: validate
280
+ ################################################################
281
+ desc "validate FILE", "Validate event FILE"
282
+
283
+ named_option :format
284
+
285
+ def validate(file)
286
+ full_path = File.expand_path(file)
287
+
288
+ unless File.exist?(full_path)
289
+ puts Mhc::Converter::Emacs.new.to_emacs("No such file #{file}.")
290
+ return 1
291
+ end
292
+
293
+ errors = Mhc::Event.validate(File.open(full_path) {|f| f.read})
294
+
295
+ string = ""
296
+ exit_on_error do
297
+ errors.each do |err, key|
298
+ string += "#{err.to_s.capitalize}"
299
+ string += " in X-SC-#{key.capitalize}" if key
300
+ string += ".\n"
301
+ end
302
+ end
303
+ if errors.empty?
304
+ puts Mhc::Converter::Emacs.new.to_emacs("OK")
305
+ return 0
306
+ end
307
+
308
+ puts Mhc::Converter::Emacs.new.to_emacs(string)
309
+ return 1
310
+ end
311
+
239
312
  ################################################################
240
313
  # add some hooks to Thor
241
314
 
@@ -312,4 +385,10 @@ class MhcCLI < Thor
312
385
  end
313
386
  end
314
387
 
315
- command = MhcCLI.start(ARGV)
388
+ result = MhcCLI.start(ARGV)
389
+
390
+ if result.is_a?(Numeric)
391
+ exit result
392
+ else
393
+ exit 0
394
+ end
data/emacs/Cask CHANGED
@@ -5,7 +5,7 @@
5
5
  (source org)
6
6
  (source melpa)
7
7
 
8
- (package "mhc" "1.1.1" "Message Harmonized Calendaring system") ;; MHC_VERSION
8
+ (package "mhc" "1.2.4" "Message Harmonized Calendaring system") ;; MHC_VERSION
9
9
 
10
10
  (files "mhc.el" "mhc-*.el")
11
11
 
@@ -1071,11 +1071,13 @@ The keys that are defined for mhc-calendar-mode are:
1071
1071
  (format "%4d" yy))
1072
1072
 
1073
1073
  (defun mhc-calendar/inserter-nengo ()
1074
- (if (> yy 1987)
1075
- (format "平成%2d年" (- yy 1988))
1076
- (if (> yy 1924)
1077
- (format "昭和%2d年" (- yy 1925))
1078
- "昔々")))
1074
+ (if (or (> yy 2019) (and (= yy 2019) (> mm 4)))
1075
+ (format "令和%2d年" (- yy 2018))
1076
+ (if (> yy 1987)
1077
+ (format "平成%2d年" (- yy 1988))
1078
+ (if (> yy 1924)
1079
+ (format "昭和%2d年" (- yy 1925))
1080
+ "昔々"))))
1079
1081
 
1080
1082
  (defun mhc-calendar/inserter-mm ()
1081
1083
  (format "%d" mm))
@@ -411,17 +411,10 @@
411
411
  `(/ (1- (mhc-date-dd ,date)) 7))
412
412
 
413
413
  (defsubst mhc-date-cw (date)
414
- (mhc-date-let date
415
- (let* ((yday (mhc-date/day-number yy mm dd))
416
- (days (mhc-date/iso-week-days yday ww))
417
- (d))
418
- (if (< days 0)
419
- (setq days (mhc-date/iso-week-days
420
- (+ yday 365 (if (mhc-date/leap-year-p (1- yy)) 1 0)) ww))
421
- (setq d (mhc-date/iso-week-days
422
- (- yday 365 (if (mhc-date/leap-year-p yy) 1 0)) ww))
423
- (if (<= 0 d) (setq days d)))
424
- (1+ (/ days 7)))))
414
+ (string-to-number
415
+ (format-time-string
416
+ (if (= mhc-start-day-of-week 1) "%V" "%U")
417
+ (mhc-date-to-second date))))
425
418
 
426
419
  ;;
427
420
  ;; compare.
@@ -646,4 +639,4 @@ If WKST is not specified, 0 (Sunday) is used."
646
639
  ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
647
640
  ;; OF THE POSSIBILITY OF SUCH DAMAGE.
648
641
 
649
- ;;; mhc-date.el ends here.
642
+ ;;; mhc-date.el ends here
@@ -146,4 +146,4 @@ This special form converts DAY, as the number of days since
146
146
  ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
147
147
  ;; OF THE POSSIBILITY OF SUCH DAMAGE.
148
148
 
149
- ;;; mhc-day.el ends here.
149
+ ;;; mhc-day.el ends here
@@ -1,4 +1,4 @@
1
- ;;; -*- mode: Emacs-Lisp; coding: utf-8 -*-
1
+ ;;; mhc-db.el --- Database Interface to MHC.
2
2
 
3
3
  ;; Author: Yoshinari Nomura <nom@quickhack.net>,
4
4
  ;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>
@@ -18,18 +18,38 @@
18
18
  (require 'mhc-process)
19
19
  (require 'mhc-schedule)
20
20
 
21
- (defun mhc-db-scan (b e &optional nosort category search)
21
+ (defun mhc-db-scan (begin-date end-date &optional nosort category search)
22
+ "Scan MHC database from BEGIN-DATE to END-DATE.
23
+ If optional NOSORT is non-nil, returned value is not sort.
24
+ If optional CATEGORY is non-nil, returned value is clipped by category.
25
+ If optional SEARCH is non-nil returned value is clipped by search string."
22
26
  (mhc-process-send-command
23
27
  (format "scan --format=emacs %04d%02d%02d-%04d%02d%02d%s%s"
24
- (mhc-date-yy b)
25
- (mhc-date-mm b)
26
- (mhc-date-dd b)
27
- (mhc-date-yy e)
28
- (mhc-date-mm e)
29
- (mhc-date-dd e)
28
+ (mhc-date-yy begin-date)
29
+ (mhc-date-mm begin-date)
30
+ (mhc-date-dd begin-date)
31
+ (mhc-date-yy end-date)
32
+ (mhc-date-mm end-date)
33
+ (mhc-date-dd end-date)
30
34
  (if category (format " --category=%s" category) "")
31
35
  (if search (format " --search='%s'" search) ""))))
32
36
 
37
+ (defun mhc-db-scan-flat (begin-date end-date &optional nosort category search)
38
+ "Scan MHC database from BEGIN-DATE to END-DATE.
39
+ Unlike `mhc-db-scan`, returned value is not grouped by date.
40
+ For example:
41
+ ((date . mhc-schedule) (date . mhc-schedule) ...)
42
+ If optional NOSORT is non-nil, returned value is not sort.
43
+ If optional CATEGORY is non-nil, returned value is clipped by category.
44
+ If optional SEARCH is non-nil returned value is clipped by search string."
45
+ (let ((dayinfo-list (mhc-db-scan begin-date end-date nosort category search)))
46
+ (apply 'append
47
+ (mapcar (lambda (dayinfo)
48
+ (let ((date (mhc-day-date dayinfo))
49
+ (schedules (mhc-day-schedules dayinfo)))
50
+ (mapcar (lambda (sch) (cons date sch)) schedules)))
51
+ dayinfo-list))))
52
+
33
53
  (defun mhc-db-search (&rest query)
34
54
  (let ((b (mhc-date-new 1970 1 1))
35
55
  (e (mhc-date-yy+ (mhc-date-now) 10)))
@@ -60,32 +80,33 @@
60
80
  nosort
61
81
  category)))
62
82
 
63
- (defun mhc-db-add-record-from-buffer (record buffer &optional force-refile)
64
- (let* ((slot (mhc-logic-record-to-slot record))
65
- (directory (and slot
66
- (file-name-as-directory
67
- (expand-file-name
68
- "spool" (mhc-config-base-directory)))))
69
- (old-record))
70
- (unless slot (error "Cannot get schedule slot"))
71
- (if (mhc-record-name record)
72
- ;; Modifying existing record
73
- (setq old-record record)
74
- ;; Creating new record
75
- (mhc-record-set-name record (mhc-misc-get-new-path directory record)))
76
- (if (or force-refile
77
- (y-or-n-p (format
78
- "Refile %s to %s "
79
- (or (mhc-record-name old-record) "it")
80
- (mhc-record-name record))))
81
- (progn
82
- (mhc-record-write-buffer record buffer old-record)
83
- (if (and old-record
84
- (not (eq record old-record)))
85
- (let* ((dir (file-name-directory
86
- (directory-file-name
87
- (mhc-record-name old-record)))))
88
- (mhc-misc-touch-directory dir)))
83
+ (defun mhc-db-record-path-from-buffer (buffer)
84
+ "Return file path in MHC spool bound to BUFFER.
85
+ File path is taken from X-SC-Record-Id field."
86
+ (with-current-buffer buffer
87
+ (let ((spool-directory (file-name-as-directory
88
+ (expand-file-name
89
+ "spool" (mhc-config-base-directory))))
90
+ (record-id (mhc-draft-record-id)))
91
+ (expand-file-name (concat record-id ".mhc") spool-directory))))
92
+
93
+ (defun mhc-db-add-record-from-buffer (buffer &optional allow-overwrite)
94
+ "Add current mhc-draft BUFFER to MHC db.
95
+ If optional ALLOW-OVERWRITE is non-nil, do not ask overwrite."
96
+ (let* ((path (mhc-db-record-path-from-buffer buffer))
97
+ (directory (file-name-directory path))
98
+ (overwriting (file-exists-p path)))
99
+ (if (or (not overwriting)
100
+ allow-overwrite
101
+ (y-or-n-p (format "Overwrite existing %s? " path)))
102
+ (with-current-buffer buffer
103
+ (mhc-draft-increment-sequence)
104
+ (mhc-draft-translate)
105
+ (mhc-file-make-directory directory)
106
+ (mhc-write-region-as-coding-system
107
+ mhc-default-coding-system
108
+ (point-min) (point-max) path nil 'nomsg)
109
+ (set-buffer-modified-p nil)
89
110
  (mhc-misc-touch-directory directory)
90
111
  t))))
91
112
 
@@ -118,9 +139,7 @@
118
139
  (mhc-schedule-condition schedule))))
119
140
  " "))))
120
141
  (mhc-record-set-name record (mhc-record-name original-record))
121
- (mhc-db-add-record-from-buffer record (current-buffer))))))
122
-
123
-
142
+ (mhc-db-add-record-from-buffer (current-buffer) t)))))
124
143
 
125
144
  (provide 'mhc-db)
126
145
 
@@ -155,4 +174,4 @@
155
174
  ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
156
175
  ;; OF THE POSSIBILITY OF SUCH DAMAGE.
157
176
 
158
- ;;; mhc-db.el ends here.
177
+ ;;; mhc-db.el ends here
@@ -17,14 +17,10 @@
17
17
 
18
18
  (defconst mhc-draft-buffer-name "*mhc draft*")
19
19
 
20
- (defcustom mhc-draft-unuse-hdr-list
21
- '(">From " "From " "Delivered-To:" "Delivery-date:" "Envelope-to:"
22
- "Errors-To:" "Gnus-Warning:" "Lines:" "Posted:" "Precedence:" "Received:"
23
- "Replied:" "Return-Path:" "Sender:" "User-Agent:" "X-Bogosity:"
24
- "X-Dispatcher:" "X-Filter:" "X-Gnus-Mail-Source:" "X-Mailer:" "X-Received:"
25
- "X-Sender:" "X-Seqno:" "X-Spam-Flag:" "X-Spam-Probability:" "X-UIDL:"
26
- "Xref:")
27
- "*These headers are removed when article is imported."
20
+ (defcustom mhc-draft-import-header-list
21
+ '("Subject:" "From:" "To:" "Cc:" "Date:" "Message-Id:"
22
+ "X-GM-THRID:" "X-GM-MSGID:" "X-GM-LABELS:")
23
+ "*These headers are used when article is imported."
28
24
  :group 'mhc
29
25
  :type '(repeat string))
30
26
 
@@ -199,7 +195,7 @@ If optional argument NO-CONFIRM is non-nil, kill without confirmation."
199
195
  (defun mhc-draft-delete-garbage-headers ()
200
196
  (mhc-header-narrowing
201
197
  (mhc-header-delete-header
202
- (concat "^\\(" (mhc-regexp-opt mhc-draft-unuse-hdr-list) "\\)")
198
+ (concat "^\\(" (mhc-regexp-opt mhc-draft-import-header-list) "\\)")
203
199
  'regexp)))
204
200
 
205
201
  (defun mhc-draft-setup-headers (&optional headers-values)
@@ -217,22 +213,40 @@ HEADERS-VALUES is a list of cons-cell like: ((header-name . value) ...)."
217
213
  (mhc-header-put-value xsc ""))))
218
214
  xsc-headers))))
219
215
 
216
+ (defun mhc-draft-record-id ()
217
+ "Get X-SC-Record-Id header value in draft buffer."
218
+ (mhc-header-narrowing
219
+ (mhc-header-get-value "x-sc-record-id")))
220
+
221
+ (defun mhc-draft-validate-buffer (&optional buffer)
222
+ "Validate mhc draft BUFFER.
223
+ If BUFFER is omitted, current buffer will be validated."
224
+ (interactive)
225
+ (let ((validation (mhc-process-send-command-with-buffer
226
+ "validate --format=emacs"
227
+ (or buffer (current-buffer)))))
228
+ (if (and (stringp validation)
229
+ (string-match "^OK" validation))
230
+ (message "Validation passed.")
231
+ ;; \\' means end of string (not end of each line)
232
+ (error "ERROR: %s" (replace-regexp-in-string "[.\r\n]+\\'" "" validation)))))
233
+
220
234
  (defun mhc-draft-finish ()
221
235
  "Add current draft as a schedule."
222
236
  (interactive)
223
- (let ((record
224
- (mhc-parse-buffer (mhc-record-new mhc-draft-buffer-file-name)
225
- 'strict)))
226
- (mhc-calendar-input-exit)
227
- (if (mhc-db-add-record-from-buffer record (current-buffer)
228
- (not (called-interactively-p 'interactive)))
229
- (progn
230
- (kill-buffer (current-buffer))
231
- (mhc-window-pop)
232
- (or (and (mhc-summary-buffer-p)
233
- (mhc-rescan-month mhc-default-hide-private-schedules))
234
- (and (mhc-calendar-p) (mhc-calendar-rescan)))
235
- (run-hooks 'mhc-draft-finish-hook)))))
237
+ (mhc-draft-validate-buffer)
238
+ (mhc-calendar-input-exit)
239
+ (if (mhc-db-add-record-from-buffer
240
+ (current-buffer)
241
+ (not (called-interactively-p 'interactive)))
242
+ (progn
243
+ (kill-buffer (current-buffer))
244
+ (mhc-window-pop)
245
+ (or (and (mhc-summary-buffer-p)
246
+ (mhc-rescan-month mhc-default-hide-private-schedules))
247
+ (and (mhc-calendar-p) (mhc-calendar-rescan)))
248
+ (run-hooks 'mhc-draft-finish-hook)
249
+ (message "Successfully registered."))))
236
250
 
237
251
  (provide 'mhc-draft)
238
252
 
@@ -68,7 +68,7 @@ refer to mhc-calendar-hnf-face-alist-internal.")
68
68
  (1 font-lock-type-face)
69
69
  (2 font-lock-comment-face)
70
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\\):\\)"
71
+ ("\\(X-SC-\\(Subject\\|Location\\|Day\\|Time\\|Category\\|Priority\\|Recurrence-Tag\\|Mission-Tag\\|Cond\\|Duration\\|Alarm\\|Record-Id\\|Sequence\\):\\)"
72
72
  (1 font-lock-keyword-face))
73
73
  ("\\(\\[End of message\\]\\)"
74
74
  (1 mhc-message-face-eof-marker))
@@ -63,6 +63,25 @@
63
63
  (memq (following-char) '(? ?\t)))))
64
64
 
65
65
 
66
+ (defun mhc-header-distill-header (header &optional regexp)
67
+ "Remove all headers except X-SC-* and HEADER.
68
+ If REGEXP is non-nil, HEADER is a regular expression."
69
+ (save-excursion
70
+ (let ((case-fold-search t)
71
+ (header-top)
72
+ (header-name)
73
+ (all-regexp "^[^:]+:")
74
+ (use-regexp (if regexp header (concat "^" (regexp-quote header) ":")))
75
+ (xsc-regexp (concat "^\\(" (mhc-regexp-opt (mhc-header-list)) "\\)")))
76
+ (goto-char (point-min))
77
+ (while (re-search-forward all-regexp nil t)
78
+ (setq header-top (match-beginning 0)
79
+ header-name (match-string 0))
80
+ (mhc-header-goto-end)
81
+ (unless (or (string-match use-regexp header-name)
82
+ (string-match xsc-regexp header-name))
83
+ (delete-region header-top (point)))))))
84
+
66
85
  (defun mhc-header-delete-header (header &optional regexp) "\
67
86
  Remove HEADER in the narrowed buffer.
68
87
  If REGEXP, HEADER is a regular expression."
@@ -177,4 +196,4 @@ If REGEXP, HEADER is a regular expression."
177
196
  ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
178
197
  ;; OF THE POSSIBILITY OF SUCH DAMAGE.
179
198
 
180
- ;;; mhc-header.el ends here.
199
+ ;;; mhc-header.el ends here