annotate lisp/mail/pmailedit.el @ 101365:2f0f7be5cbea

* pmail.el (pmail-buffer-swapped): Mark as permanent local.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 23 Jan 2009 02:33:37 +0000
parents f0e145fc691b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
1 ;;; pmailedit.el --- "PMAIL edit mode" Edit the current message
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
2
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
3 ;; Copyright (C) 1985, 1994, 2001, 2002, 2003, 2004, 2005, 2006,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100757
diff changeset
4 ;; 2007, 2008, 2009 Free Software Foundation, Inc.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
5
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
6 ;; Maintainer: FSF
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
7 ;; Keywords: mail
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
8
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
10
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
14 ;; (at your option) any later version.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
15
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
20
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
23
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
24 ;;; Commentary:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
25
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
26 ;;; Code:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
27
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
28 (eval-when-compile
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
29 (require 'pmail)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
30 (require 'pmailsum))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
31
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
32 (defcustom pmail-edit-mode-hook nil
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
33 "List of functions to call when editing an PMAIL message."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
34 :type 'hook
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
35 :version "21.1"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
36 :group 'pmail-edit)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
37
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
38 (defvar pmail-old-text)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
39
100225
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
40 (defvar pmail-edit-map nil)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
41 (if pmail-edit-map
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
42 nil
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
43 ;; Make a keymap that inherits text-mode-map.
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
44 (setq pmail-edit-map (make-sparse-keymap))
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
45 (set-keymap-parent pmail-edit-map text-mode-map)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
46 (define-key pmail-edit-map "\C-c\C-c" 'pmail-cease-edit)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
47 (define-key pmail-edit-map "\C-c\C-]" 'pmail-abort-edit))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
48
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
49 ;; Pmail Edit mode is suitable only for specially formatted data.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
50 (put 'pmail-edit-mode 'mode-class 'special)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
51
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
52 (declare-function pmail-summary-disable "" ())
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
53 (declare-function pmail-summary-enable "pmailsum" ())
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
54
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
55 (defun pmail-edit-mode ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
56 "Major mode for editing the contents of an PMAIL message.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
57 The editing commands are the same as in Text mode, together with two commands
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
58 to return to regular PMAIL:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
59 * \\[pmail-abort-edit] cancels the changes
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
60 you have made and returns to PMAIL
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
61 * \\[pmail-cease-edit] makes them permanent.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
62 This functions runs the normal hook `pmail-edit-mode-hook'.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
63 \\{pmail-edit-map}"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
64 (if (pmail-summary-exists)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
65 (save-excursion
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
66 (set-buffer pmail-summary-buffer)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
67 (pmail-summary-disable)))
101340
f0e145fc691b (pmail-cease-edit, pmail-edit-mode): Use pmail-buffer-swapped.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
68 (let (pmail-buffer-swapped)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
69 ;; Prevent change-major-mode-hook from unswapping the buffers.
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
70 (delay-mode-hooks (text-mode))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
71 (use-local-map pmail-edit-map)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
72 (setq major-mode 'pmail-edit-mode)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
73 (setq mode-name "PMAIL Edit")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
74 (if (boundp 'mode-line-modified)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
75 (setq mode-line-modified (default-value 'mode-line-modified))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
76 (setq mode-line-format (default-value 'mode-line-format)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
77 (run-mode-hooks 'pmail-edit-mode-hook)))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
78
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
79 (defvar pmail-old-pruned nil)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
80 (put 'pmail-old-pruned 'permanent-local t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
81
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
82 ;;;###autoload
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
83 (defun pmail-edit-current-message ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
84 "Edit the contents of this message."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
85 (interactive)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
86 (if (= pmail-total-messages 0)
100659
b8a72d8ed8b5 (pmail-edit-current-message): Change error message.
Richard M. Stallman <rms@gnu.org>
parents: 100658
diff changeset
87 (error "No messages in this buffer"))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
88 (make-local-variable 'pmail-old-pruned)
100225
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
89 (setq pmail-old-pruned (eq pmail-header-style 'normal))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
90 (pmail-edit-mode)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
91 (make-local-variable 'pmail-old-text)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
92 (save-restriction
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
93 (widen)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
94 (setq pmail-old-text (buffer-substring (point-min) (point-max))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
95 (setq buffer-read-only nil)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
96 (setq buffer-undo-list nil)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
97 (force-mode-line-update)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
98 (if (and (eq (key-binding "\C-c\C-c") 'pmail-cease-edit)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
99 (eq (key-binding "\C-c\C-]") 'pmail-abort-edit))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
100 (message "Editing: Type C-c C-c to return to Pmail, C-c C-] to abort")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
101 (message "%s" (substitute-command-keys
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
102 "Editing: Type \\[pmail-cease-edit] to return to Pmail, \\[pmail-abort-edit] to abort"))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
103
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
104 (defun pmail-cease-edit ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
105 "Finish editing message; switch back to Pmail proper."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
106 (interactive)
100225
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
107 (if (pmail-summary-exists)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
108 (save-excursion
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
109 (set-buffer pmail-summary-buffer)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
110 (pmail-summary-enable)))
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
111 (widen)
100662
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
112 ;; Disguise any "From " lines so they don't start a new message.
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
113 (save-excursion
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
114 (goto-char (point-min))
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
115 (while (search-forward "\nFrom " nil t)
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
116 (beginning-of-line)
818439524f9b (pmail-cease-edit): Put `>' before `From ' lines in message.
Richard M. Stallman <rms@gnu.org>
parents: 100661
diff changeset
117 (insert ">")))
100661
af9f2d22b21d Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 100659
diff changeset
118 ;; Make sure buffer ends with a blank line
af9f2d22b21d Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 100659
diff changeset
119 ;; so as not to run this message together with the following one.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
120 (save-excursion
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
121 (goto-char (point-max))
100225
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
122 (if (/= (preceding-char) ?\n)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
123 (insert "\n"))
100653
14070fe82d72 (pmailhdr): Don't require it.
Richard M. Stallman <rms@gnu.org>
parents: 100229
diff changeset
124 (unless (looking-back "\n\n")
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
125 (insert "\n")))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
126 (let ((old pmail-old-text)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
127 character-coding is-text-message coding-system
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
128 headers-end)
100659
b8a72d8ed8b5 (pmail-edit-current-message): Change error message.
Richard M. Stallman <rms@gnu.org>
parents: 100658
diff changeset
129 ;; Go back to Pmail mode, but carefully.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
130 (force-mode-line-update)
101340
f0e145fc691b (pmail-cease-edit, pmail-edit-mode): Use pmail-buffer-swapped.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
131 (let (pmail-buffer-swapped)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
132 (kill-all-local-variables)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
133 (pmail-mode-1)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
134 (if (boundp 'tool-bar-map)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
135 (set (make-local-variable 'tool-bar-map) pmail-tool-bar-map))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
136 (setq buffer-undo-list t)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
137 (pmail-variables))
100659
b8a72d8ed8b5 (pmail-edit-current-message): Change error message.
Richard M. Stallman <rms@gnu.org>
parents: 100658
diff changeset
138 ;; If text has really changed, mark message as edited.
100653
14070fe82d72 (pmailhdr): Don't require it.
Richard M. Stallman <rms@gnu.org>
parents: 100229
diff changeset
139 (unless (and (= (length old) (- (point-max) (point-min)))
14070fe82d72 (pmailhdr): Don't require it.
Richard M. Stallman <rms@gnu.org>
parents: 100229
diff changeset
140 (string= old (buffer-substring (point-min) (point-max))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
141 (setq old nil)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
142 (goto-char (point-min))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
143 (search-forward "\n\n")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
144 (setq headers-end (point))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
145
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
146 (pmail-swap-buffers-maybe)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
147
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
148 (setq character-coding (mail-fetch-field "content-transfer-encoding")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
149 is-text-message (pmail-is-text-p)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
150 coding-system (pmail-get-coding-system))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
151 (if character-coding
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
152 (setq character-coding (downcase character-coding)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
153
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
154 (narrow-to-region (pmail-msgbeg pmail-current-message)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
155 (pmail-msgend pmail-current-message))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
156 (goto-char (point-min))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
157 (search-forward "\n\n")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
158 (let ((inhibit-read-only t)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
159 (headers-end-1 (point)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
160 (insert-buffer-substring pmail-view-buffer headers-end)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
161 (delete-region (point) (point-max))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
162
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
163 ;; Re-encode the message body in whatever
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
164 ;; way it was decoded.
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
165 (cond
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
166 ((string= character-coding "quoted-printable")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
167 (mail-quote-printable-region headers-end-1 (point-max)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
168 ((and (string= character-coding "base64") is-text-message)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
169 (base64-encode-region headers-end-1 (point-max)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
170 ((eq character-coding 'uuencode)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
171 (error "Not supported yet."))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
172 (t
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
173 (if (or (not coding-system) (not (coding-system-p coding-system)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
174 (setq coding-system 'undecided))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
175 (encode-coding-region headers-end-1 (point-max) coding-system)))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
176 ))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
177
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
178 (pmail-set-attribute pmail-edited-attr-index t)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
179
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
180 ;;??? BROKEN perhaps.
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
181 ;; I think that the Summary-Line header may not be kept there any more.
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
182 ;;; (if (boundp 'pmail-summary-vector)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
183 ;;; (progn
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
184 ;;; (aset pmail-summary-vector (1- pmail-current-message) nil)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
185 ;;; (save-excursion
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
186 ;;; (pmail-widen-to-current-msgbeg
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
187 ;;; (function (lambda ()
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
188 ;;; (forward-line 2)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
189 ;;; (if (looking-at "Summary-line: ")
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
190 ;;; (let ((buffer-read-only nil))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
191 ;;; (delete-region (point)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
192 ;;; (progn (forward-line 1)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
193 ;;; (point)))))))))))
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
194 )
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
195
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
196 (save-excursion
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
197 (pmail-show-message)
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
198 (pmail-toggle-header (if pmail-old-pruned 1 0)))
100653
14070fe82d72 (pmailhdr): Don't require it.
Richard M. Stallman <rms@gnu.org>
parents: 100229
diff changeset
199 (run-hooks 'pmail-mode-hook))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
200
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
201 (defun pmail-abort-edit ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
202 "Abort edit of current message; restore original contents."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
203 (interactive)
100757
02ad31ca52a9 (pmail-edit-mode): Bind buffer-swwapped-with to nil.
Richard M. Stallman <rms@gnu.org>
parents: 100662
diff changeset
204 (widen)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
205 (delete-region (point-min) (point-max))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
206 (insert pmail-old-text)
100225
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
207 (pmail-cease-edit)
cff49a741231 Sync with rmailedit.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
208 (pmail-highlight-headers))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
209
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
210 (provide 'pmailedit)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
211
98019
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97533
diff changeset
212 ;; Local Variables:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97533
diff changeset
213 ;; change-log-default-name: "ChangeLog.pmail"
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97533
diff changeset
214 ;; End:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97533
diff changeset
215
97533
ec1125c7ac26 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 97532
diff changeset
216 ;; arch-tag: 9524f335-12cc-4e95-9e9b-3208dc30550b
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
217 ;;; pmailedit.el ends here