annotate diary.el @ 79:4f01e4a447c6

shouldn't have been here!
author Henry S Thompson <ht@inf.ed.ac.uk>
date Thu, 25 Sep 2025 18:17:02 +0100
parents 800f0f595127
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 ;; Last edited: Wed Oct 24 17:08:20 1990
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2 ;; provide a simple diary facility on top of rmailsum
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 ;; Copyright (C) 1990 Henry S. Thompson
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 ;; GNU Emacs is distributed in the hope that it will be useful,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 ;; but WITHOUT ANY WARRANTY. No author or distributor
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
9 ;; accepts responsibility to anyone for the consequences of using it
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 ;; or for whether it serves any particular purpose or works at all,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
11 ;; unless he says so in writing. Refer to the GNU Emacs General Public
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 ;; License for full details.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
14 ;; Everyone is granted permission to copy, modify and redistribute
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
15 ;; GNU Emacs, but only under the conditions described in the
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
16 ;; GNU Emacs General Public License. A copy of this license is
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
17 ;; supposed to have been given to you along with GNU Emacs so you
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
18 ;; can know your rights and responsibilities. It should be in a
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
19 ;; file named COPYING. Among other things, the copyright notice
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
20 ;; and this notice must be preserved on all copies.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
21
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
22 (provide 'diary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
23 (require 'mail-extras)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
24
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
25 (autoload 'sort-subr "sort")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
26
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
27 (defvar ht-diary-file-name "~/DIARY.babyl"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
28 "default name of diary file")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
29
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
30 (defvar ht-Calendar-directory "~/Calendar")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
31
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
32 (defun xxx-date-lessp (date1 date2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
33 "Return T if DATE1 is earlyer than DATE2."
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
34 (string-lessp (gnus-comparable-date date1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
35 (gnus-comparable-date date2)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
36
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
37 (defun xxx-comparable-date (date)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
38 "Make comparable string by string-lessp from DATE."
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
39 (let ((month '(("JAN" . " 1")("FEB" . " 2")("MAR" . " 3")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
40 ("APR" . " 4")("MAY" . " 5")("JUN" . " 6")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
41 ("JUL" . " 7")("AUG" . " 8")("SEP" . " 9")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
42 ("OCT" . "10")("NOV" . "11")("DEC" . "12")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
43 (date (or date "")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
44 ;; Can understand the following styles:
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
45 ;; (1) 14 Apr 89 03:20:12 GMT
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
46 ;; (2) Fri, 17 March 89 4:01:33 GMT
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
47 (if (string-match
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
48 "\\([0-9]+\\) \\([^ ,]+\\) \\([0-9]+\\) *\\([0-9:]*\\)" date)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
49 (let ((year (substring date (match-beginning 3) (match-end 3)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
50 (mn (substring date
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
51 (match-beginning 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
52 (+ 3 (match-beginning 2))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
53 (day (substring date
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
54 (match-beginning 1) (match-end 1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
55 (time (substring date (match-beginning 4) (match-end 4))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
56 (concat
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
57 ;; Year
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
58 (if (= (length year) 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
59 (if (string-match "^9" year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
60 (concat "19" year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
61 (concat "20" year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
62 year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
63 ;; Month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
64 (cdr
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
65 (assoc
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
66 (upcase mn)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
67 month))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
68 ;; Day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
69 (format "%2d" (string-to-int day))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
70 ;; Time
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
71 time))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
72 ;; Cannot understand DATE string.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
73 date
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
74 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
75 ))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
76
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
77 (defun update-default-diary (arg) "update a diary - with arg, the one for
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
78 this file. Without arg, the default (named in ht-diary-file-name)"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
79 (interactive "P")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
80 (if arg
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
81 (update-diary (current-buffer))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
82 (require-diary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
83 (update-diary (get-file-buffer ht-diary-file-name))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
84
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
85 (defun update-diary (buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
86 ;; (setq rmail-summary-buffer (get-buffer-create "*Diary*"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
87 (let ((obuf (current-buffer)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
88 (set-buffer buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
89 (if (not has-diary-summary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
90 (progn (make-local-variable 'has-diary-summary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
91 (setq has-diary-summary t)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
92 (rmail-summary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
93 (set-buffer obuf)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
94
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
95 (defun do-diary-update () "rmail-summary-mode-hook calls this"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
96 (if (save-excursion (set-buffer rbuf)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
97 has-diary-summary)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
98 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
99 (make-local-variable 'diary-summary-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
100 (setq diary-summary-buffer t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
101 (setq description (concat "Diary " description))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
102 (setq buffer-read-only nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
103 (sort-diary-hdrs)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
104 (format-diary-hdrs)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
105 (setq buffer-read-only t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
106 (not-modified)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
107 (beginning-of-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
108 (setq mesg nil) ; to go to earliest, not first in file
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
109 )))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
110
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
111 (defun require-diary ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
112 (if (not (get-file-buffer ht-diary-file-name))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
113 (progn (rmail-input ht-diary-file-name)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
114 (rmail-show-message 1))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
115 ))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
116
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
117 (defvar diary-summary-buffer nil "flag to identify diary summaries")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
118 (defvar has-diary-summary nil "flag to identify buffers with diary summaries")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
119
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
120 (defun sort-diary-hdrs ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
121 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
122 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
123 (sort-subr nil 'forward-line 'end-of-line 'get-diary-hdr-date nil))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
124
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
125 (defun format-diary-hdrs ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
126 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
127 (while (< (point)(point-max))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
128 (forward-char 5)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
129 (delete-char 35)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
130 (looking-at " *\\([0-9]*\\) *\\([a-zA-Z]*\\) *\\([0-9]*\\) *\\([0-9]*\\)")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
131 (if (match-beginning 0)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
132 (let ((day (buffer-substring (match-beginning 1)(match-end 1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
133 (month (capitalize (buffer-substring (match-beginning 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
134 (min (+ (match-beginning 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
135 3)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
136 (match-end 2)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
137 (year (buffer-substring (max
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
138 (- (match-end 3) 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
139 (match-beginning 3))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
140 (match-end 3)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
141 (time (buffer-substring (match-beginning 4)(match-end 4))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
142 (delete-char (+ 1
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
143 (if (= (match-end 4)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
144 (match-beginning 4))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
145 0 ; fix for no time case
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
146 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
147 (- (match-end 4)(match-beginning 1))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
148 (insert (format " %2s %3s %2s %4s " day month year time))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
149 (forward-line 1))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
150 (goto-char (point-min)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
151
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
152 (defun get-diary-hdr-date ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
153 (looking-at " *[^ ]* *[^ ]* *[^ ]* *\\(.*\\)$")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
154 (xxx-comparable-date (buffer-substring (match-beginning 1)(match-end 1))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
155
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
156
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
157 (if (not (boundp 'rmail-edit-map))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
158 (load-library "rmailedit"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
159 (if (not (boundp 'rmail-summary-mode-map))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
160 (progn (load-library "rmailsum")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
161 (rmail-summary-mode-fun1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
162 (define-key rmail-edit-map "\C-c\C-c" 'ht-rmail-cease-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
163 (define-key rmail-edit-map "\C-c\C-]" 'ht-rmail-abort-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
164 ;(defvar diary-mode-map (copy-keymap rmail-summary-mode-map))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
165 ;(define-key diary-mode-map "s" 'diary-save)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
166 (define-key rmail-mode-map "h" 'ht-rmail-summarise)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
167 (setq rmail-summary-mode-hook 'do-diary-update)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
168
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
169 (defvar editing-diary-entry nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
170
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
171 (defun diary-save ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
172 "save parent file and update"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
173 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
174 (set-buffer rmail-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
175 (rmail-expunge-and-save)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
176 (if has-diary-summary (update-diary (current-buffer))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
177
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
178 (defun ht-rmail-summarise ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
179 "Display a summary of all messages, one line per message.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
180 If file is named as ht-diary-file-name, or the summary buffer is already
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
181 a diary summary, make it a Diary summary (see
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
182 \\[describe-mode] rmail-summary-mode for info)."
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
183 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
184 (if (eq (current-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
185 (get-file-buffer ht-diary-file-name))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
186 (update-default-diary t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
187 (rmail-summary)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
188
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
189 (defun edit-and-move-to-diary ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
190 "try to add a date to subject field, move to diary on exit"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
191 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
192 (make-local-variable 'editing-diary-entry)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
193 (setq editing-diary-entry t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
194 (rmail-edit-current-message)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
195 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
196 (search-forward "\n\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
197 (let ((try-date (and
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
198 (re-search-forward
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
199 "[0-9][-0-9 ]*[- ][a-zA-Z][a-zA-Z]*[- 0-9]*" nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
200 (buffer-substring (match-beginning 0)(match-end 0))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
201 sublp)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
202 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
203 (setq sublp (search-forward "Subject: " nil t))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
204 (if try-date
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
205 (progn (set-mark (point))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
206 (insert try-date)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
207
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
208 (defun gnus-edit-and-move-to-diary (&optional arg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
209 "try to add a date to subject field if not already there,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
210 move to diary on exit,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
211 delete if n is absent,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
212 move immediately w/o editing if marked.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
213 Repeat for subsequent marked, if any"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
214 (interactive "P")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
215 (set-buffer gnus-summary-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
216 (let* ((n (if arg (prefix-numeric-value arg)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
217 (no-delete (and n (> n 0)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
218 (neg (and n (< n 0)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
219 (no-edit (or gnus-newsgroup-processable neg)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
220 (let ((articles (gnus-summary-work-articles
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
221 (cond
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
222 (neg (- n))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
223 (gnus-newsgroup-processable nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
224 (t 1))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
225 article)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
226 (when (and (not no-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
227 (/= (length articles) 1))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
228 (error "Editting multiple articles for diary not implemented yet"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
229 (while (setq article (pop articles))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
230 (gnus-edit-and-move-to-diary_1 no-delete no-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
231 (when (memq article gnus-newsgroup-processable)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
232 (gnus-summary-remove-process-mark article)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
233 (if (and no-edit (not (gnus-summary-next-unread-article)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
234 (gnus-summary-exit)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
235 ))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
236
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
237 (defun gnus-edit-and-move-to-diary_1 (no-delete no-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
238 "try to add a date to subject field if not already there,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
239 move to diary on exit,
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
240 delete if not no-delete, move immediately w/o editing if no-edit"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
241 (let ((flush-shell nil))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
242 (when (and (not (and no-delete no-edit))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
243 (gnus-group-read-only-p))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
244 (error "The current newsgroup does not support article editing"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
245 ;; Select article if needed.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
246 (unless (eq (gnus-summary-article-number)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
247 gnus-current-article)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
248 (gnus-summary-select-article t))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
249 (gnus-article-date-original)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
250 (message "About to forward. . .")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
251 (gnus-summary-mail-forward 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
252 (message "Begin forward. . .")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
253 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
254 (re-search-forward "^To: " nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
255 ;(forward-char 4)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
256 (insert "htcalendar@markup.co.uk")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
257 (search-forward "------ Start of forwarded")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
258 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
259 (when (and (bufferp (get-buffer "*Shell Command Output*"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
260 (not (re-search-forward
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
261 "^--0000.*[[:space:]]*Content-Type: text/plain" nil t nil
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
262 (get-buffer " *Original Article*")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
263 (search-forward "<html" nil t))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
264 (backward-char 5)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
265 (push-mark nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
266 (re-search-forward "</html>[[:space:]]*")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
267 (exchange-point-and-mark)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
268 (use-text-not-html t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
269 (let ((pos (point)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
270 (when (search-backward "type=text/html" nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
271 (replace-match "type=text/plain")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
272 (goto-char (+ pos 1))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
273 (setq flush-shell t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
274 ))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
275 (let (sublp)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
276 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
277 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
278 (setq sublp (search-forward "Subject: " nil t))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
279 (delete-region (point)(progn (search-forward "] " nil t)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
280 (if (not
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
281 (looking-at "[123]?[0-9] [JFMASOND][a-z][a-z] (20)?[2-9][0-9] "))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
282 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
283 (let ((try-date
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
284 (and
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
285 (or (re-search-forward "^\r?$" nil 1) t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
286 (re-search-forward
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
287 "[0-9][-0-9 ]*[- ][jfmasondJFMASOND][a-zA-Z]*[- 0-9]*"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
288 (save-excursion (search-forward "\n--\n" nil t))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
289 t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
290 (buffer-substring (match-beginning 0)(match-end 0)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
291 (message (format "date: |%s| %s" try-date sublp))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
292 (if (and sublp
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
293 try-date)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
294 (progn (set-mark (point))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
295 (insert try-date)))))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
296 (make-local-hook 'message-send-hook)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
297 (if no-edit
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
298 (let ((hook `(lambda ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
299 (ht-gnus-cease-edit ,no-delete))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
300 (add-hook 'message-send-hook hook nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
301 (message-send-and-exit))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
302 (add-hook 'message-send-hook
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
303 `(lambda ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
304 (ht-gnus-cease-edit ',no-delete ',flush-shell))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
305 nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
306 (split-window-vertically 6)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
307 (other-window 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
308 (search-forward "\n\n" nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
309 (other-window 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
310 (goto-char sublp)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
311 (message "Exiting to buffer, we hope")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
312 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
313 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
314
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
315 (defun ht-gnus-cease-edit (&optional no-delete flush-shell)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
316 "check if diary edit, move if so"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
317 (interactive "P")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
318 (message "ceasing. . .")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
319 (ht-forward-to-Calendar)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
320 (let ((rmail-summary-redo '(rmail-summary)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
321 (gnus-output-to-rmail ht-diary-file-name)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
322 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
323 (unless no-delete
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
324 (with-current-buffer gnus-summary-buffer
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
325 (gnus-summary-move-article 1 "nnml+ht:_doom")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
326 (if (get-buffer "diary.babyl-summary")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
327 (kill-buffer "diary.babyl-summary"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
328 (with-current-buffer "diary.babyl"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
329 (rmail-mode)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
330 (save-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
331 (ht-rmail-summarise))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
332 (if flush-shell
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
333 (let ((sb (get-buffer "*Shell Command Output*")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
334 (if (bufferp sb)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
335 (kill-buffer sb))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
336 (message "ceased"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
337
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
338 (defun ht-gnus-summary-save-in-diary (&optional filename)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
339 (gnus-eval-in-buffer-window gnus-save-article-buffer
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
340 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
341 (save-restriction
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
342 (widen)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
343 (gnus-output-to-rmail ht-diary-file-name)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
344
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
345 ;; private copy to simulate hook
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
346 (defun ht-rmail-cease-edit ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
347 "check if diary edit, move if so"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
348 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
349 (rmail-cease-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
350 (if editing-diary-entry
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
351 (progn (setq editing-diary-entry nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
352 (ht-forward-to-Calendar)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
353 (rmail-output-to-rmail-file ht-diary-file-name 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
354 (ht-rmail-delete-forward))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
355
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
356 ;; try to add a diary subject field line to the appropriate calendar file
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
357 (defun ht-forward-to-Calendar ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
358 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
359 (search-forward "Subject: ")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
360 (or (looking-at
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
361 "\\([0-9]+\\) \\([A-Za-z]+\\) \\([0-9]+\\) \\([0-9:]*\\) ?\\(.*\\)\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
362 (error "not a recognisable diary line"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
363 (let ((day (buffer-substring (match-beginning 1) (match-end 1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
364 (month (buffer-substring (match-beginning 2) (match-end 2)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
365 (year (buffer-substring (match-beginning 3) (match-end 3)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
366 (time (buffer-substring (match-beginning 4) (match-end 4)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
367 (message (buffer-substring (match-beginning 5) (match-end 5)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
368 (mb (match-beginning 4))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
369 (me (match-end 5))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
370 ends e-day e-month fn)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
371 (let ((year (if (string-match "^\\(19\\|20\\).." year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
372 year
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
373 (if (eq (length year) 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
374 (concat "20" year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
375 (progn (if (and (equal time "")(eq (length year) 4))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
376 (setq time year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
377 (format-time-string "%Y")))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
378 (t-month (capitalize
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
379 (substring month 0 3))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
380 (let* ((n-day (read day))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
381 (mon-table '((Jan . 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
382 (Feb . 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
383 (Mar . 3)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
384 (Apr . 4)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
385 (May . 5)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
386 (Jun . 6)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
387 (Jul . 7)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
388 (Aug . 8)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
389 (Sep . 9)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
390 (Oct . 10)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
391 (Nov . 11)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
392 (Dec . 12)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
393 (a-month (assq (read t-month)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
394 mon-table))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
395 (n-month (if a-month (cdr a-month) 0))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
396 (u-time (if (equal time "") "0" time))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
397 (hour (/ (read u-time) 100))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
398 (minute (mod (read u-time) 100))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
399 (nhour (if (> minute 29)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
400 (+ 1 hour)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
401 hour))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
402 (nminute (if (> minute 29)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
403 (- minute 30)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
404 (+ minute 30)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
405 (n-year (read year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
406 (r-subj (mail-fetch-field "Subject"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
407 (body (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
408 (buffer-substring
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
409 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
410 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
411 (if (re-search-forward "^\r?$" nil 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
412 (match-beginning 0)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
413 (point-max)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
414 (point-max))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
415 (subj-matches (string-match "^\\([^(]*\\)\\((\\(.*\\))\\)?"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
416 message))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
417 (np-subj (match-string 1 message))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
418 (p-subj (or (match-string 3 message) ""))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
419 (uid (or (mail-fetch-field "Message-id")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
420 (let ((ct (current-time)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
421 (format "%d-%d-%d"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
422 (car ct)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
423 (cadr ct)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
424 (caddr ct)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
425 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
426 (if (string-match " -- \\(.*\\)$" message)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
427 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
428 (setq ends (substring message (match-beginning 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
429 (match-end 1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
430 (setq message (substring message 0 (match-beginning 0)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
431 (if (string-match "\\([0-9]+\\) \\([A-Za-z]+\\)" ends)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
432 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
433 (setq e-day (substring ends (match-beginning 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
434 (match-end 1)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
435 (setq e-month (assq
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
436 (read (capitalize
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
437 (substring
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
438 (substring ends (match-beginning 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
439 (match-end 2))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
440 0 3)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
441 mon-table))))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
442 (setq fn (build-vcal-message (my-time-iso8601
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
443 (encode-time
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
444 0 minute
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
445 hour
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
446 n-day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
447 n-month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
448 n-year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
449 (my-time-iso8601
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
450 (if e-day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
451 (encode-time
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
452 0 (if (eq hour 0) 30 minute) ;nminute
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
453 (if (eq hour 0) 23 hour) ; nhour
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
454 (read e-day)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
455 (if e-month (cdr e-month) 0)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
456 n-year)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
457 (encode-time
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
458 0 minute ; nminute
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
459 (+ hour 1) ; nhour
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
460 n-day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
461 n-month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
462 n-year)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
463 "ORGANIZER;CN=\"Henry S. Thompson\":mailto:htcalendar@markup.co.uk"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
464 ;(concat "ORGANIZER:" (mail-fetch-field "From"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
465 p-subj
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
466 body
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
467 np-subj
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
468 (concat "ht-vcal-" uid)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
469 (if fn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
470 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
471 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
472 (if (search-forward "<#multipart " nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
473 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
474 (if (search-forward "<#multipart type=alternative" nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
475 (beginning-of-line)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
476 (forward-line 2)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
477 ;; now at beginning of forwarded text
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
478 (if (search-forward "<#part " nil t)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
479 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
480 ;; now at beginning of _attachments_
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
481 (beginning-of-line))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
482 ;; no attachments, probably never happens
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
483 (search-forward "<#/multipart>"))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
484 ;; plain text, make it multipart
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
485 (search-forward "-------- Start of forwarded")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
486 (re-search-forward "^\r?$")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
487 (forward-line 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
488 (insert "<#multipart type=mixed>\n<#part type=text/plain charset=\"ISO-8859-1\" format=\"flowed\" disposition=inline nofile=yes>\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
489 (search-forward "--------- End of forwarded")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
490 (forward-line -1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
491 (insert "<#/multipart>\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
492 (forward-line -1))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
493 (mml-attach-file fn "application/octet-stream" "diary event")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
494 ; (let ((res (shell-command-to-string
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
495 ; (concat "updateCal.pl < " fn))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
496 ; (if (not (equal res ""))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
497 ; (message (format "update losing: %s" res))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
498 )))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
499 (if (file-exists-p ht-Calendar-directory)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
500 (let* ((dfn (concat ht-Calendar-directory
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
501 "/xy"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
502 year
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
503 "/xc"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
504 day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
505 t-month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
506 year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
507 (buf (find-file-noselect dfn))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
508 )
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
509 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
510 (set-buffer buf)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
511 (goto-char (point-max))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
512 (if (not (bolp))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
513 (insert "\n"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
514 (if time
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
515 (insert time " "))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
516 (insert message)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
517 (let ((require-final-newline nil))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
518 (save-buffer)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
519 (if ends
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
520 ;; an end date also given
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
521 (if e-day
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
522 (let (t-e-month msg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
523 (setq msg (concat
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
524 (substring message 0
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
525 (string-match " " message))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
526 " continues"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
527 (if (string-equal (setq t-e-month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
528 (if e-month (car e-month)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
529 t-month))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
530 t-month)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
531 (fill-dates year t-month (1+ (car
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
532 (read-from-string day)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
533 (car
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
534 (read-from-string e-day))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
535 msg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
536 (fill-dates year t-month (1+ (car
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
537 (read-from-string day)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
538 (cdr (assoc t-month
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
539 '(("Jan" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
540 ("Feb" . 28)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
541 ("Mar" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
542 ("Apr" . 30)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
543 ("May" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
544 ("Jun" . 30)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
545 ("Jul" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
546 ("Aug" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
547 ("Sep" . 30)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
548 ("Oct" . 31)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
549 ("Nov" . 30)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
550 ("Dec" . 31))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
551 msg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
552 (fill-dates year t-e-month 1
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
553 (car (read-from-string e-day))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
554 msg)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
555 (message "\C-g\C-gCouldn't parse end date: %s" ends)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
556 )))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
557
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
558 (defun fill-dates (year month start end mesg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
559 "fill the dates between start and end with message in the calendar"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
560 (let ((day start))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
561 (while (<= day end)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
562 (let* ((dfn (concat ht-Calendar-directory
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
563 "/xy"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
564 year
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
565 "/xc"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
566 (format "%d" day)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
567 (format "%s" month)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
568 year))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
569 (buf (find-file-noselect dfn)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
570 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
571 (set-buffer buf)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
572 (goto-char (point-max))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
573 (if (not (bolp))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
574 (insert "\n"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
575 (insert mesg)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
576 (let ((require-final-newline nil))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
577 (save-buffer))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
578 (setq day (1+ day)))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
579
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
580 ;; private copy
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
581 (defun ht-rmail-abort-edit ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
582 "add a hook"
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
583 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
584 (setq editing-diary-entry nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
585 (rmail-abort-edit))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
586
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
587 (defun rmail-edit-current-message ()
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
588 "Edit the contents of this message."
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
589 (interactive)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
590 (rmail-edit-mode)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
591 (make-local-variable 'rmail-old-text)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
592 (setq rmail-old-text (buffer-substring (point-min) (point-max)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
593 (setq buffer-read-only nil)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
594 (set-buffer-modified-p (buffer-modified-p))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
595 ;; Make mode line update.
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
596 (if (and (eq (key-binding "\C-c\C-c") 'ht-rmail-cease-edit)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
597 (eq (key-binding "\C-c\C-]") 'ht-rmail-abort-edit))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
598 (if editing-diary-entry
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
599 (message "Editing: Type C-c C-c to move to diary and return to Rmail, C-c C-] to abort")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
600 (message "Editing: Type C-c C-c to return to Rmail, C-c C-] to abort"))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
601 (message (substitute-command-keys
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
602 "Editing: Type \\[rmail-cease-edit] to return to Rmail, \\[rmail-abort-edit] to abort"))))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
603
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
604
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
605 (defun build-vcal-message (start end org location description summary uid)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
606 (save-excursion
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
607 (let ((fn (concat "/tmp/" (make-temp-name "vcal") ".ics")))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
608 (find-file fn)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
609 ;\nMETHOD:PUBLISH
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
610 (insert "BEGIN:VCALENDAR\nVERSION:1.0\nPRODID:-//Henry S. Thompson//gnus diary hack//EN\nBEGIN:VEVENT\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
611 (insert "UID:")(insert uid)(insert "\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
612 (insert "DTSTAMP:")(insert
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
613 (my-time-iso8601 (current-time)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
614 (insert "Z\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
615 (insert "DTSTART:")(insert start)(insert "Z\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
616 (insert "DTEND:")(insert end)(insert "Z\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
617 (insert "SUMMARY:")(insert-encoded-maybe summary)(insert "\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
618 (insert "DESCRIPTION")(insert-folded description)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
619 ; (insert "LOCATION")(insert-encoded-maybe location)(insert "\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
620 ;(insert "ORGANIZER")(insert-encoded-maybe org)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
621 ; (insert org)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
622 ; (insert "\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
623 ; (insert "BEGIN:VALARM\nTRIGGER:-PT15M\nACTION:DISPLAY\nDESCRIPTION:Reminder\nEND:VALARM\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
624 ; (insert "BEGIN:VALARM\nTRIGGER:-PT15M\nACTION:AUDIO\nDESCRIPTION:Reminder\nEND:VALARM\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
625 (insert "END:VEVENT\nEND:VCALENDAR\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
626 (save-buffer)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
627 fn)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
628
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
629 (defun insert-encoded-maybe (string)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
630 (if (string-match "[\000-\007\n\013\015-\037\200-\377=]" string)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
631 (progn
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
632 (insert ";ENCODING=QUOTED-PRINTABLE:")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
633 (let ((beg (point)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
634 (insert string)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
635 (message (format "%d;%d" beg (point)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
636 (quoted-printable-encode-region
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
637 beg
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
638 (point)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
639 t
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
640 "^\000-\007\n\013\015-\037\200-\377="))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
641 (goto-char (point-max)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
642 (insert "\n :")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
643 (insert string)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
644
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
645 (defun insert-folded (string)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
646 (insert "\n :")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
647 (let ((beg (point)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
648 (insert string)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
649 (narrow-to-region beg (point))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
650 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
651 (replace-string "\n" "\\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
652 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
653 (replace-string "\r" "")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
654 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
655 (replace-string "," "\\,")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
656 (goto-char (point-min))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
657 (while (> (- (point-max) (point)) 72)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
658 (forward-char 70)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
659 (insert "\n "))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
660 (goto-char (point-max))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
661 (insert "\r\n")
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
662 (widen)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
663
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
664 (defun my-time-iso8601 (time)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
665 (let ((tzo (car (current-time-zone time)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
666 (hi (car time))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
667 (lo (cadr time))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
668 (ignore (cddr time)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
669 (gnus-time-iso8601
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
670 (if (>= lo tzo)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
671 (cons hi
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
672 (cons (- lo tzo)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
673 ignore))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
674 (cons (- hi 1)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
675 (cons (- (+ lo 65536) tzo)
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
676 ignore)))
800f0f595127 try to get multiple invocation alternatives of alt-d to work,
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
677 )))