annotate lisp/vm/vm-edit.el @ 73:e2d7a37b7c8d

Added tag r20-0b31 for changeset b9518feda344
author cvs
date Mon, 13 Aug 2007 09:03:47 +0200
parents 131b0175ea99
children 0d2f883870bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Editing VM messages
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2 ;;; Copyright (C) 1990, 1991, 1993, 1994 Kyle E. Jones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-edit-message (&optional prefix-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Edit the current message. Prefix arg means mark as unedited instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 If editing, the current message is copied into a temporary buffer, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 this buffer is selected for editing. The major mode of this buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 controlled by the variable vm-edit-message-mode. The hooks specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 in vm-edit-message-hook are run just prior to returning control to the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 for editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 Use C-c ESC when you have finished editing the message. The message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 will be inserted into its folder replacing the old version of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 message. If you don't want your edited version of the message to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 replace the original, use C-c C-] and the edit will be aborted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (vm-error-if-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (if (and (vm-virtual-message-p (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (null (vm-virtual-messages-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (error "Can't edit unmirrored virtual messages."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if prefix-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (if (vm-edited-flag (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (vm-set-edited-flag-of (car vm-message-pointer) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (vm-update-summary-and-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (let ((mp vm-message-pointer)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
47 (offset (- (point) (vm-headers-of (car vm-message-pointer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (edit-buf (vm-edit-buffer-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (folder-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if (not (and edit-buf (buffer-name edit-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq edit-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (generate-new-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (format "edit of %s's note re: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (vm-su-full-name (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (vm-su-subject (car vm-message-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (vm-set-edit-buffer-of (car mp) edit-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (copy-to-buffer edit-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (vm-headers-of (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (vm-text-end-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (set-buffer edit-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (< offset 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (forward-char offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (funcall (or vm-edit-message-mode 'text-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (use-local-map vm-edit-message-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; (list (car mp)) because a different message may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; later be stuffed into a cons linked that is linked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; into the folder's message list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq vm-message-pointer (list (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 vm-mail-buffer folder-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 vm-system-state 'editing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (run-hooks 'vm-edit-message-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Type \\[vm-edit-message-end] to end edit, \\[vm-edit-message-abort] to abort with no change.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (set-buffer edit-buf))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
82 (if (and vm-frame-per-edit (vm-multiple-frames-possible-p))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (let ((w (vm-get-buffer-window edit-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (if (null w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (vm-goto-new-frame 'edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (vm-set-hooks-for-frame-deletion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (select-window w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (and vm-warp-mouse-to-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (vm-warp-mouse-to-frame-maybe (vm-window-frame w)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (vm-display edit-buf t '(vm-edit-message vm-edit-message-other-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (list this-command 'editing-message)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun vm-edit-message-other-frame (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "Like vm-edit-message, but run in a newly created frame."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (if (vm-multiple-frames-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (vm-goto-new-frame 'edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (let ((vm-search-other-frames nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (vm-frame-per-edit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (vm-edit-message prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if (vm-multiple-frames-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (vm-set-hooks-for-frame-deletion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defun vm-discard-cached-data (&optional count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 "Discard cached information about the current message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 When VM gathers information from the headers of a message, it stores it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 internally for future reference. This command causes VM to forget this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 information, and VM will be forced to search the headers of the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 again for these data. VM will also have to decide again which headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 should be displayed and which should not. Therefore this command is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 useful if you change the value of vm-visible-headers or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 vm-invisible-header-regexp in the midst of a VM session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Numeric prefix argument N means to discard data from the current message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 plus the next N-1 messages. A negative N means discard data from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 current message and the previous N-1 messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 When invoked on marked messages (via vm-next-command-uses-marks),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 data is discarded only from the marked messages in the current folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (or count (setq count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (let ((mlist (vm-select-marked-or-prefixed-messages count)) m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (setq m (vm-real-message-of (car mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (vm-unthread-message m t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (fillarray (vm-cache-of m) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (vm-set-vheaders-of m nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (vm-set-vheaders-regexp-of m nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (vm-set-text-of m nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (vm-build-threads (list m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (vm-sort-messages "thread"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (let ((v-list (vm-virtual-messages-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (while v-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (set-buffer (vm-buffer-of (car v-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (vm-build-threads (list (car v-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (vm-sort-messages "thread"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq v-list (cdr v-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (vm-mark-for-summary-update m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq mlist (cdr mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (vm-display nil nil '(vm-discard-cached-data) '(vm-discard-cached-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun vm-edit-message-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "End the edit of a message and copy the result to its folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (error "This is not a VM message edit buffer."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (null (buffer-name (vm-buffer-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (error "The folder buffer for this message has been killed."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; make sure the message ends with a newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (and (/= (preceding-char) ?\n) (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; munge message separators found in the edited message to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; prevent message from being split into several messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (vm-munge-message-separators (vm-message-type-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; for From_-with-Content-Length recompute the Content-Length header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (if (eq (vm-message-type-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; first delete all copies of Content-Length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (while (and (re-search-forward vm-content-length-search-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (null (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (vm-match-header vm-content-length-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (delete-region (vm-matched-header-start) (vm-matched-header-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; now compute the message body length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (search-forward "\n\n" nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq length (- (point-max) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; insert the header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (insert vm-content-length-header " " (int-to-string length) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (let ((edit-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (mp vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (set-buffer (vm-buffer-of (vm-real-message-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if (not (memq (vm-real-message-of (car mp)) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (error "The original copy of this message has been expunged."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (goto-char (vm-headers-of (vm-real-message-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (let ((vm-message-pointer mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 opoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (insert-buffer-substring edit-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (point) (vm-text-end-of (vm-real-message-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (vm-discard-cached-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (vm-set-edited-flag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (vm-set-edit-buffer-of (car mp) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (set-buffer (vm-buffer-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (eq (vm-real-message-of (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (vm-real-message-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (vm-update-summary-and-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (message "No change."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (vm-display edit-buf nil '(vm-edit-message-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 '(vm-edit-message-end reading-message startup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (kill-buffer edit-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun vm-edit-message-abort ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Abort the edit of a message, forgetting changes to the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (if (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (error "This is not a VM message edit buffer."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (null (buffer-name (vm-buffer-of (vm-real-message-of (car vm-message-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (error "The folder buffer for this message has been killed."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (vm-set-edit-buffer-of (car vm-message-pointer) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (vm-display (current-buffer) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 '(vm-edit-message-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 '(vm-edit-message-abort reading-message startup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (message "Aborted, no change."))