annotate emacs/mail-extras.el @ 0:509549c55989

from elsewhere
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 25 May 2021 13:57:42 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 ;; Last edited: Fri Nov 2 10:26:24 1990
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2 ;; extra widgets for rmail and rmailsum
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 ;; Copyright (C) 1990 Henry S. Thompson
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 ;; GNU Emacs is distributed in the hope that it will be useful,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 ;; but WITHOUT ANY WARRANTY. No author or distributor
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
9 ;; accepts responsibility to anyone for the consequences of using it
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 ;; or for whether it serves any particular purpose or works at all,
509549c55989 from elsewhere
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
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 ;; License for full details.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
14 ;; Everyone is granted permission to copy, modify and redistribute
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
15 ;; GNU Emacs, but only under the conditions described in the
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
16 ;; GNU Emacs General Public License. A copy of this license is
509549c55989 from elsewhere
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
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
18 ;; can know your rights and responsibilities. It should be in a
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
19 ;; file named COPYING. Among other things, the copyright notice
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
20 ;; and this notice must be preserved on all copies.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
21
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
22 (provide 'mail-extras)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
23 (require 'rmail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
24 (require 'sendmail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
25
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
26
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
28 ;; mods and fixes for reading mail ;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
30
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
31 (defvar ht-last-file (expand-file-name "~/XMAIL")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
32 "default for moving mail to")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
33 (make-variable-buffer-local 'ht-last-file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
34
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
35 (defvar rmht-always-recompress t
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
36 "If non-nil, when saving into compressed babyl file,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
37 always recompress and save immediately")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
38
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
39 (defvar rmht-allow-autosave t
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
40 "if non-nil, leaves autosave alone for compressed babyl files,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
41 otherwise turns it off")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
42
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
43 (add-hook 'rmail-mode-hook 'rmail-mode-fun1)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
44 (add-hook 'rmail-mode-hook 'rmail-mode-fun2)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
45
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
46 ;; run the first time in to RMAIL
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
47 (defun rmail-mode-fun1 ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
48 "add ht's mods to RMAIL"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
49 (define-key rmail-mode-map "R" 'reply-w/o-cc)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
50 (define-key rmail-mode-map "M" 'rmht-output)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
51 (define-key rmail-mode-map "H" 'print-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
52 (define-key rmail-mode-map "W" 'edit-and-move-to-diary)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
53 (define-key rmail-mode-map "D" 'update-default-diary)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
54 (define-key rmail-mode-map "F" 're-post-failed-mail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
55 (define-key rmail-mode-map "B" 'ht-write-body-to-file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
56 ;; fix the doc string
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
57 (repl-comment 'rmail-mode
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
58 "Rmail Mode is used by \\[rmail] for editing Rmail files.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
59 All normal editing commands are turned off.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
60 Instead, these commands are available (additions from ht's mail-extras.el
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
61 indicated by *:
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
62
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
63 . Move point to front of this message (same as \\[beginning-of-buffer]).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
64 SPC Scroll to next screen of this message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
65 DEL Scroll to previous screen of this message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
66 n Move to Next non-deleted message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
67 p Move to Previous non-deleted message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
68 M-n Move to Next message whether deleted or not.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
69 M-p Move to Previous message whether deleted or not.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
70 > Move to the last message in Rmail file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
71 j Jump to message specified by numeric position in file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
72 M-s Search for string and show message it is found in.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
73 d Delete this message, move to next nondeleted.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
74 C-d Delete this message, move to previous nondeleted.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
75 u Undelete message. Tries current message, then earlier messages
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
76 till a deleted message is found.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
77 e Expunge deleted messages.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
78 s Expunge and save the file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
79 q Quit Rmail: expunge, save, then switch to another buffer.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
80 C-x C-s Save without expunging.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
81 g Move new mail from system spool directory or mbox into this file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
82 m Mail a message (same as \\[mail-other-window]).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
83 c Continue composing outgoing message started before.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
84 r Reply to this message. Like m but initializes some fields.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
85 R * Like r, but reply to originator only.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
86 f Forward this message to another user.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
87 F * like f, but assumes message is \"failed mail\" for re-sending
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
88 o Output this message to an Rmail file (append it).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
89 C-o Output this message to a Unix-format mail file (append it).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
90 M * Output this message to a file,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
91 in format determined by extension (babyl for RMAIL/msg for Unix).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
92 B * Write the body of the message to a file, leaving a pointer
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
93 H * Print the message (same as \\<global-map>\\[print-buffer]).\\<rmail-mode-map>
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
94 i Input Rmail file. Run Rmail on that file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
95 a Add label to message. It will be displayed in the mode line.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
96 k Kill label. Remove a label from current message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
97 C-M-n Move to Next message with specified label
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
98 (label defaults to last one specified).
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
99 Standard labels: filed, unseen, answered, forwarded, deleted.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
100 Any other label is present only if you add it with `a'.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
101 C-M-p Move to Previous message with specified label
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
102 h, C-M-h Show headers buffer, with a one line summary of each message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
103 l, C-M-l Like h only just messages with particular label(s) are summarized.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
104 C-M-r Like h only just messages with particular recipient(s) are summarized.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
105 t Toggle header, show Rmail header if unformatted or vice versa.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
106 w Edit the current message. C-c C-c to return to Rmail.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
107 W * Edit the subject field. C-c C-c to move the message to the Diary.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
108 D * Update the Diary.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
109
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
110 Messages for the diary (see also \\[describe-mode] in rmail-summary mode
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
111 or \\[describe-function] rmail-summary-mode) should have a subject field
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
112 which begins with the date and optional time of the event described therein.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
113 These must be in the form
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
114 d m y t
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
115 where d is one or two digits for the day,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
116 m is either the full month name or the first three letters thereof,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
117 y is two digits for the year,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
118 and t, if present, is 4 digits for the time,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
119 thus for example
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
120 31 Jun 91 1530
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
121 ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
122 (remove-hook 'rmail-mode-hook 'rmail-mode-fun1))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
123
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
124 (defun rmail-mode-fun2 ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
125 "always run in RMAIL mode"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
126 (setq case-fold-search t))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
127
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
128 (defun reply-w/o-cc ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
129 "Reply as r, but without sending to other recipients"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
130 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
131 (rmail-reply t))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
132
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
133 (defun rmht-output (&optional file-name gnus)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
134 "Move to a file, determining format by extension (babyl/msg)"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
135 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
136 (if (not file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
137 (setq file-name (car (get-move-file-name))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
138 (if (string-match "\\.g?[zZ]$" file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
139 (let ((clean-file-name (substring file-name 0 (match-beginning 0)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
140 there)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
141 (if (setq there (get-file-buffer clean-file-name))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
142 nil
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
143 (save-window-excursion (rmail clean-file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
144 (setq there
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
145 (get-file-buffer clean-file-name))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
146 (rmht-output clean-file-name gnus)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
147 (if rmht-always-recompress
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
148 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
149 (set-buffer there)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
150 (save-buffer))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
151 (if (not rmht-allow-autosave)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
152 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
153 (set-buffer there)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
154 (auto-save-mode -1)))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
155 (setq file-name (expand-file-name file-name))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
156 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
157 (if (string-match "\\.babyl$" file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
158 (if gnus
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
159 (gnus-output-to-rmail file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
160 (rmail-output-to-rmail-file file-name 1))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
161 (if (string-match "\\.msg$" file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
162 (if (or (get-file-buffer file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
163 (file-exists-p file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
164 (yes-or-no-p
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
165 (concat "\"" file-name "\" does not exist, create it? ")))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
166 (rmail-output file-name 1)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
167 (error "Output file does not exist"))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
168 (error "not a valid mail file: %s" file-name))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
169 (setq ht-last-file file-name)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
170 (if (not gnus) (ht-rmail-delete-forward))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
171
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
172 (defun get-move-file-name ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
173 "get a file name for moving a message to"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
174 (list (read-file-name
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
175 (concat "Output message to file: (default "
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
176 (file-name-nondirectory ht-last-file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
177 ") ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
178 (file-name-directory ht-last-file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
179 ht-last-file)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
180
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
181 (defun re-post-failed-mail ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
182 "try to salvage the original from failed mail and prepare to resend it"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
183 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
184 (rmail-forward nil)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
185 (let ((top (point))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
186 subjp textp)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
187 (re-search-forward "^Subject: ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
188 (kill-line nil)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
189 (setq subjp (point))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
190 (re-search-forward "^From: ") ; the bouncer
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
191 (re-search-forward "^From: ") ; should be us
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
192 (re-search-forward "^Subject: ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
193 (kill-line nil)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
194 (save-excursion (goto-char subjp)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
195 (yank))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
196 (beginning-of-line 3)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
197 (setq textp (point))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
198 (goto-char top)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
199 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
200 (beginning-of-line 2)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
201 (delete-region (point) textp)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
202 (goto-char top)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
203
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
205 ;; mods and fixes for mail summaries ;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
207
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
208 (add-hook 'rmail-summary-mode-hook 'rmail-summary-mode-fun1)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
209
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
210 ;; run the first time we make a summary window
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
211 (defun rmail-summary-mode-fun1 ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
212 "install ht's mods"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
213 (define-key rmail-summary-mode-map "r" 'rms-reply-w-cc)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
214 (define-key rmail-summary-mode-map "R" 'rms-reply-w/o-cc)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
215 (define-key rmail-summary-mode-map "s" 'diary-save)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
216 (define-key rmail-summary-mode-map "m" 'rms-move)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
217 (define-key rmail-summary-mode-map "d" 'rms-delete)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
218 (define-key rmail-summary-mode-map "h" 'rms-hardcopy)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
219 (define-key rmail-summary-mode-map " " 'ht-rmailsum-scroll-msg-up)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
220 (define-key rmail-summary-mode-map "\177" 'ht-rmailsum-scroll-msg-down)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
221 ;; fix the doc string
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
222 (repl-comment 'rmail-summary-mode
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
223 "Major mode in effect in Rmail summary buffer.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
224 A subset of the Rmail mode commands are supported in this mode.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
225 As commands are issued in the summary buffer the corresponding
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
226 mail message is displayed in the rmail buffer.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
227 Modifications from ht's mail-extras.el indicated with *:
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
228
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
229 n Move to next undeleted message, or arg messages.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
230 p Move to previous undeleted message, or arg messages.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
231 C-n Move to next, or forward arg messages.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
232 C-p Move to previous, or previous arg messages.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
233 j Jump to the message at the cursor location.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
234 d Delete the message at the cursor location and move to next message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
235 u Undelete this or previous deleted message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
236 q Quit Rmail.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
237 x Exit and kill the summary window.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
238 space * If cursor is on line of current message,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
239 scroll message window forward. Otherwise, jump to indicated message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
240 delete * same as space, but scrolls backward.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
241 r * Same as r in rmail window. Reply to current message.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
242 R * Same as R in rmail window. Reply to current message, originator only.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
243 s * Update and save the rmail file, and re-summarise. Re-sorts if Diary.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
244 m * Same as M in rmail window. Moves message to file.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
245 h * Same as H in rmail window. Prints message on line printer.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
246
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
247 Entering this mode calls value of hook variable rmail-summary-mode-hook.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
248
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
249 If the file summarised is called by the name given in ht-diary-file-name,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
250 which defaults to diary.babyl,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
251 then the summary will be called *Diary*, sorted in date order and
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
252 formated in a special way.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
253
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
254 Messages in the diary should have a subject field
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
255 which begins with the date and optional time of the event described therein.
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
256 These must be in the form
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
257 d m y t
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
258 where d is one or two digits for the day,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
259 m is either the full month name or the first three letters thereof,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
260 y is two digits for the year,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
261 and t, if present, is 4 digits for the time,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
262 thus for example
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
263 Subject: 31 Jun 91 1530 Hades freezing ceremony followed by champagne reception
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
264 ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
265 (remove-hook 'rmail-summary-mode-hook 'rmail-summary-mode-fun1))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
266
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
267 (defun rmht-sum-reply (sender-only)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
268 "reply to current message"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
269 (rmail-summary-goto-msg)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
270 (pop-to-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
271 (rmail-reply sender-only)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
272 (switch-to-buffer rmail-summary-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
273 (switch-to-buffer "*mail*")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
274 )
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
275
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
276 (defun rms-reply-w-cc ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
277 "Do r in RMAIL - reply to everybody"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
278 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
279 (rmht-sum-reply nil))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
280
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
281 (defun rms-reply-w/o-cc ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
282 "Do R in RMAIL - reply to sender only"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
283 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
284 (rmht-sum-reply t))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
285
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
286 (defun rms-save ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
287 "expunge deleted messages, save RMAIL file and re-display headers"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
288 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
289 (pop-to-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
290 (rmail-expunge-and-save)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
291 (rmail-summary))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
292
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
293 (defun rms-delete ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
294 "delete current and move down to next in summary buffer"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
295 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
296 (rmail-summary-goto-msg)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
297 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
298 (set-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
299 (rmail-delete-forward nil))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
300 (rms-del))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
301
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
302 (defun rms-move ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
303 "Move to a file, mode determined by file extension (babyl/msg)"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
304 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
305 (rmail-summary-goto-msg)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
306 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
307 (set-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
308 (rmht-output))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
309 (rms-del))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
310
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
311 (defun rms-del ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
312 "mark current summary line as deleted and move down"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
313 (let ((buffer-read-only nil))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
314 (skip-chars-forward " ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
315 (skip-chars-forward "[0-9]")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
316 (delete-char 1)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
317 (insert "D"))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
318 (forward-line 1))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
319
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
320 (defun rms-hardcopy ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
321 "hardcopy the current message"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
322 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
323 (pop-to-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
324 (print-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
325 (pop-to-buffer rmail-summary-buffer))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
326
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
327
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
328 ;; fix interpretation of SPACE and DEL in summary windows to
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
329 ;; 1) scroll the right window regardless of how many panes are up;
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
330 ;; 2) go to the message associated with the current line if not already there,
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
331 ;; a la gnus, for instance
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
332
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
333 (defun ht-rmailsum-normalise ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
334 "if not already showing message named on current line, go to it & return t"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
335 (beginning-of-line)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
336 (let ((current-msg-num (cdr (assoc 'rmail-current-message
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
337 (buffer-local-variables
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
338 (or rmail-buffer
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
339 (error
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
340 "not in a summary buffer"))))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
341 (line-message-num (string-to-int
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
342 (buffer-substring
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
343 (point)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
344 (min (point-max)(+ 5 (point)))))))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
345 (if (= current-msg-num line-message-num)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
346 nil
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
347 (rmail-summary-goto-msg line-message-num)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
348 t)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
349
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
350 (defun ht-rmailsum-scroll-msg-up (&optional dist)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
351 "goto other message or scroll current message forward"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
352 (interactive "P")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
353 (if (ht-rmailsum-normalise)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
354 nil
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
355 (pop-to-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
356 (scroll-up dist)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
357 (pop-to-buffer rmail-summary-buffer)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
358
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
359 (defun ht-rmailsum-scroll-msg-down (&optional dist)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
360 "goto other message or scroll current message backward"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
361 (interactive "P")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
362 (if (ht-rmailsum-normalise)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
363 nil
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
364 (pop-to-buffer rmail-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
365 (scroll-down dist)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
366 (pop-to-buffer rmail-summary-buffer)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
367
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
368 (autoload 'edit-and-move-to-diary "diary")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
369 (autoload 'update-diary "diary")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
370 (autoload 'diary-save "diary")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
371
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
372 ;; unfortunately, gnus mucks about with the buffers before calling
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
373 ;; mail, so we have to intervene to make the about-to-mail-hook work right
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
374
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
375 (defun ht-Subject-mode-fun ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
376 "fix the map to save window state"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
377 (define-key gnus-summary-mode-map "r" 'ht-Subject-mail-reply)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
378 (define-key gnus-summary-mode-map "R" 'ht-Subject-mail-reply-with-original)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
379 (define-key gnus-summary-mode-map "m" 'ht-Subject-mail-other-window)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
380 (define-key gnus-summary-mode-map "M" 'ht-Subject-move)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
381 (remove-hook 'gnus-summary-mode-hook 'ht-Subject-mode-fun))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
382
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
383 (add-hook 'gnus-summary-mode-hook 'ht-Subject-mode-fun)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
384
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
385 (defun ht-Subject-mail-reply (yank)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
386 "Runs about-to-mail-hook, then calls gnus-summary-mail-reply"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
387 (interactive "P")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
388 (require 'sendmail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
389 (run-hooks 'about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
390 (let (about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
391 (gnus-summary-reply yank)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
392
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
393 (defun ht-Subject-mail-reply-with-original ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
394 "Runs about-to-mail-hook, then calls gnus-summary-mail-reply-with-original"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
395 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
396 (require 'sendmail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
397 (run-hooks 'about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
398 (let (about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
399 (gnus-summary-reply-with-original)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
400
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
401 (defun ht-Subject-mail-other-window ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
402 "Runs about-to-mail-hook, then calls gnus-summary-mail-other-window"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
403 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
404 (require 'sendmail)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
405 (run-hooks 'about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
406 (let (about-to-mail-hook)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
407 (gnus-summary-mail-other-window)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
408
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
409 (defun ht-Subject-move ()
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
410 "Move article to a file, mode determined by file extension (babyl/msg)"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
411 (interactive)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
412 (gnus-summary-select-article)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
413 (save-excursion
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
414 (set-buffer gnus-article-buffer)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
415 (rmht-output nil t)))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
416
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
417
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
418 (defun ht-write-body-to-file (file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
419 "Write the body of the message to a file and replace it with a pointer"
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
420 (interactive "FFile to save in: ")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
421 (goto-char (point-min))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
422 (or (search-forward "\n\n" nil t)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
423 (error "Can't find text"))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
424 (write-region (point)(point-max) file)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
425 (rmail-edit-current-message)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
426 (delete-region (point)(point-max))
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
427 (insert "\n>> " file "\n")
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
428 (rmail-cease-edit)
509549c55989 from elsewhere
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
429 (rmht-output))