Mercurial > emacs
annotate lisp/mail/rmailedit.el @ 28567:3ed20cb4c9b3
(edebug-keywordp): Remove. Change callers
to use keywordp.
(edebug-spec): Enable keywordp.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 13 Apr 2000 19:04:33 +0000 |
parents | d1f081e4844a |
children | 9adbbd869684 |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
368
diff
changeset
|
1 ;;; rmailedit.el --- "RMAIL edit mode" Edit the current message. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
368
diff
changeset
|
2 |
7300 | 3 ;; Copyright (C) 1985, 1994 Free Software Foundation, Inc. |
845 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
7 |
36 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
36 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
25 ;;; Code: |
36 | 26 |
27 (require 'rmail) | |
28 | |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
29 (defvar rmail-old-text) |
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
30 |
36 | 31 (defvar rmail-edit-map nil) |
32 (if rmail-edit-map | |
33 nil | |
4179
dfc4e9e14d24
(rmail-edit-map): Inherit properly from text-mode-map;
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
34 ;; Make a keymap that inherits text-mode-map. |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
35 (setq rmail-edit-map (make-sparse-keymap)) |
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
36 (set-keymap-parent rmail-edit-map text-mode-map) |
36 | 37 (define-key rmail-edit-map "\C-c\C-c" 'rmail-cease-edit) |
38 (define-key rmail-edit-map "\C-c\C-]" 'rmail-abort-edit)) | |
39 | |
40 ;; Rmail Edit mode is suitable only for specially formatted data. | |
41 (put 'rmail-edit-mode 'mode-class 'special) | |
42 | |
43 (defun rmail-edit-mode () | |
44 "Major mode for editing the contents of an RMAIL message. | |
45 The editing commands are the same as in Text mode, together with two commands | |
46 to return to regular RMAIL: | |
47 * rmail-abort-edit cancels the changes | |
48 you have made and returns to RMAIL | |
49 * rmail-cease-edit makes them permanent. | |
50 \\{rmail-edit-map}" | |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
51 (text-mode) |
36 | 52 (use-local-map rmail-edit-map) |
53 (setq major-mode 'rmail-edit-mode) | |
54 (setq mode-name "RMAIL Edit") | |
55 (if (boundp 'mode-line-modified) | |
56 (setq mode-line-modified (default-value 'mode-line-modified)) | |
57 (setq mode-line-format (default-value 'mode-line-format))) | |
6723
6ff74185a672
(rmail-edit-mode, rmail-cease-edit): Disable summary during edit.
Karl Heuer <kwzh@gnu.org>
parents:
5851
diff
changeset
|
58 (if (rmail-summary-exists) |
6726 | 59 (save-excursion |
60 (set-buffer rmail-summary-buffer) | |
61 (rmail-summary-disable))) | |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
62 (run-hooks 'rmail-edit-mode-hook)) |
36 | 63 |
22264
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
64 (defvar rmail-old-pruned nil) |
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
65 (put 'rmail-old-pruned 'permanent-local t) |
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
66 |
22752
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
67 (defvar rmail-edit-saved-coding-system nil) |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
68 (put 'rmail-edit-saved-coding-system 'permanent-local t) |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
69 |
16347
d710d3502336
(rmail-edit-current-message): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
14326
diff
changeset
|
70 ;;;###autoload |
36 | 71 (defun rmail-edit-current-message () |
72 "Edit the contents of this message." | |
73 (interactive) | |
22264
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
74 (make-local-variable 'rmail-old-pruned) |
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
75 (setq rmail-old-pruned (rmail-msg-is-pruned)) |
22752
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
76 (make-local-variable 'rmail-edit-saved-coding-system) |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
77 (setq rmail-edit-saved-coding-system save-buffer-coding-system) |
22264
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
78 (rmail-toggle-header 0) |
36 | 79 (rmail-edit-mode) |
22752
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
80 ;; As the local value of save-buffer-coding-system is deleted by |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
81 ;; rmail-edit-mode, we restore the original value. |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
82 (make-local-variable 'save-buffer-coding-system) |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
83 (setq save-buffer-coding-system rmail-edit-saved-coding-system) |
36 | 84 (make-local-variable 'rmail-old-text) |
85 (setq rmail-old-text (buffer-substring (point-min) (point-max))) | |
86 (setq buffer-read-only nil) | |
11573
4ad650d4a65b
(rmail-edit-current-message): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
8498
diff
changeset
|
87 (force-mode-line-update) |
36 | 88 (if (and (eq (key-binding "\C-c\C-c") 'rmail-cease-edit) |
89 (eq (key-binding "\C-c\C-]") 'rmail-abort-edit)) | |
90 (message "Editing: Type C-c C-c to return to Rmail, C-c C-] to abort") | |
14326
e5799768c51b
(rmail-edit-current-message): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
91 (message "%s" (substitute-command-keys |
22264
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
92 "Editing: Type \\[rmail-cease-edit] to return to Rmail, \\[rmail-abort-edit] to abort")))) |
36 | 93 |
94 (defun rmail-cease-edit () | |
95 "Finish editing message; switch back to Rmail proper." | |
96 (interactive) | |
6723
6ff74185a672
(rmail-edit-mode, rmail-cease-edit): Disable summary during edit.
Karl Heuer <kwzh@gnu.org>
parents:
5851
diff
changeset
|
97 (if (rmail-summary-exists) |
6726 | 98 (save-excursion |
99 (set-buffer rmail-summary-buffer) | |
100 (rmail-summary-enable))) | |
36 | 101 ;; Make sure buffer ends with a newline. |
102 (save-excursion | |
103 (goto-char (point-max)) | |
104 (if (/= (preceding-char) ?\n) | |
105 (insert "\n")) | |
106 ;; Adjust the marker that points to the end of this message. | |
107 (set-marker (aref rmail-message-vector (1+ rmail-current-message)) | |
108 (point))) | |
109 (let ((old rmail-old-text)) | |
11573
4ad650d4a65b
(rmail-edit-current-message): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
8498
diff
changeset
|
110 (force-mode-line-update) |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
111 (kill-all-local-variables) |
36 | 112 (rmail-mode-1) |
21436
779c7dcd4c04
(rmail-cease-edit): Call kill-all-local-variables.
Karl Heuer <kwzh@gnu.org>
parents:
16347
diff
changeset
|
113 (rmail-variables) |
22752
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
114 ;; As the local value of save-buffer-coding-system is changed by |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
115 ;; rmail-variables, we restore the original value. |
00d24401ca1e
(rmail-edit-current-message, rmail-cease-edit):
Richard M. Stallman <rms@gnu.org>
parents:
22264
diff
changeset
|
116 (setq save-buffer-coding-system rmail-edit-saved-coding-system) |
36 | 117 (if (and (= (length old) (- (point-max) (point-min))) |
118 (string= old (buffer-substring (point-min) (point-max)))) | |
119 () | |
120 (setq old nil) | |
121 (rmail-set-attribute "edited" t) | |
122 (if (boundp 'rmail-summary-vector) | |
123 (progn | |
124 (aset rmail-summary-vector (1- rmail-current-message) nil) | |
125 (save-excursion | |
126 (rmail-widen-to-current-msgbeg | |
21877
ed912554aac6
(rmail-cease-edit): Call rmail-show-message even if message text is unchanged.
Richard M. Stallman <rms@gnu.org>
parents:
21436
diff
changeset
|
127 (function (lambda () |
36 | 128 (forward-line 2) |
129 (if (looking-at "Summary-line: ") | |
130 (let ((buffer-read-only nil)) | |
131 (delete-region (point) | |
132 (progn (forward-line 1) | |
21877
ed912554aac6
(rmail-cease-edit): Call rmail-show-message even if message text is unchanged.
Richard M. Stallman <rms@gnu.org>
parents:
21436
diff
changeset
|
133 (point)))))))))))) |
ed912554aac6
(rmail-cease-edit): Call rmail-show-message even if message text is unchanged.
Richard M. Stallman <rms@gnu.org>
parents:
21436
diff
changeset
|
134 (save-excursion |
22264
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
135 (rmail-show-message) |
225596bc6090
(rmail-old-pruned): New permanent local.
Richard M. Stallman <rms@gnu.org>
parents:
21877
diff
changeset
|
136 (rmail-toggle-header (if rmail-old-pruned 1 0)))) |
26485
d1f081e4844a
(rmail-cease-edit): Run rmail-mode-hook.
Gerd Moellmann <gerd@gnu.org>
parents:
22752
diff
changeset
|
137 (run-hooks 'rmail-mode-hook) |
36 | 138 (setq buffer-read-only t)) |
139 | |
140 (defun rmail-abort-edit () | |
141 "Abort edit of current message; restore original contents." | |
142 (interactive) | |
143 (delete-region (point-min) (point-max)) | |
144 (insert rmail-old-text) | |
8498
ba1acb3cf835
(rmail-abort-edit): Call `rmail-highlight-headers'.
Richard M. Stallman <rms@gnu.org>
parents:
7562
diff
changeset
|
145 (rmail-cease-edit) |
ba1acb3cf835
(rmail-abort-edit): Call `rmail-highlight-headers'.
Richard M. Stallman <rms@gnu.org>
parents:
7562
diff
changeset
|
146 (rmail-highlight-headers)) |
36 | 147 |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
368
diff
changeset
|
148 ;;; rmailedit.el ends here |