Mercurial > emacs
annotate lisp/mail/rmailedit.el @ 6632:652dc23b83fd
(tex-start-shell): Use shell-mode-map (instead of comint-mode-map) because
it's bit a nicer.
Change the "require" from comint to shell for the same reason.
author | Edward M. Reingold <reingold@emr.cs.iit.edu> |
---|---|
date | Fri, 01 Apr 1994 16:57:56 +0000 |
parents | bdb049c20e39 |
children | 6ff74185a672 |
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 |
845 | 3 ;; Copyright (C) 1985 Free Software Foundation, Inc. |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
24 ;;; Code: |
36 | 25 |
26 (require 'rmail) | |
27 | |
28 (defvar rmail-edit-map nil) | |
29 (if rmail-edit-map | |
30 nil | |
4179
dfc4e9e14d24
(rmail-edit-map): Inherit properly from text-mode-map;
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
31 ;; Make a keymap that inherits text-mode-map. |
dfc4e9e14d24
(rmail-edit-map): Inherit properly from text-mode-map;
Richard M. Stallman <rms@gnu.org>
parents:
845
diff
changeset
|
32 (setq rmail-edit-map (nconc (make-sparse-keymap) text-mode-map)) |
36 | 33 (define-key rmail-edit-map "\C-c\C-c" 'rmail-cease-edit) |
34 (define-key rmail-edit-map "\C-c\C-]" 'rmail-abort-edit)) | |
35 | |
36 ;; Rmail Edit mode is suitable only for specially formatted data. | |
37 (put 'rmail-edit-mode 'mode-class 'special) | |
38 | |
39 (defun rmail-edit-mode () | |
40 "Major mode for editing the contents of an RMAIL message. | |
41 The editing commands are the same as in Text mode, together with two commands | |
42 to return to regular RMAIL: | |
43 * rmail-abort-edit cancels the changes | |
44 you have made and returns to RMAIL | |
45 * rmail-cease-edit makes them permanent. | |
46 \\{rmail-edit-map}" | |
47 (use-local-map rmail-edit-map) | |
48 (setq major-mode 'rmail-edit-mode) | |
49 (setq mode-name "RMAIL Edit") | |
50 (if (boundp 'mode-line-modified) | |
51 (setq mode-line-modified (default-value 'mode-line-modified)) | |
52 (setq mode-line-format (default-value 'mode-line-format))) | |
53 (run-hooks 'text-mode-hook 'rmail-edit-mode-hook)) | |
54 | |
55 (defun rmail-edit-current-message () | |
56 "Edit the contents of this message." | |
57 (interactive) | |
58 (rmail-edit-mode) | |
59 (make-local-variable 'rmail-old-text) | |
60 (setq rmail-old-text (buffer-substring (point-min) (point-max))) | |
5851
bdb049c20e39
(rmail-edit-current-message): Make local variables permanent, so
Karl Heuer <kwzh@gnu.org>
parents:
4179
diff
changeset
|
61 (put 'rmail-old-text 'permanent-local t) |
36 | 62 (setq buffer-read-only nil) |
63 (set-buffer-modified-p (buffer-modified-p)) | |
64 ;; Make mode line update. | |
65 (if (and (eq (key-binding "\C-c\C-c") 'rmail-cease-edit) | |
66 (eq (key-binding "\C-c\C-]") 'rmail-abort-edit)) | |
67 (message "Editing: Type C-c C-c to return to Rmail, C-c C-] to abort") | |
68 (message (substitute-command-keys | |
69 "Editing: Type \\[rmail-cease-edit] to return to Rmail, \\[rmail-abort-edit] to abort")))) | |
70 | |
71 (defun rmail-cease-edit () | |
72 "Finish editing message; switch back to Rmail proper." | |
73 (interactive) | |
74 ;; Make sure buffer ends with a newline. | |
75 (save-excursion | |
76 (goto-char (point-max)) | |
77 (if (/= (preceding-char) ?\n) | |
78 (insert "\n")) | |
79 ;; Adjust the marker that points to the end of this message. | |
80 (set-marker (aref rmail-message-vector (1+ rmail-current-message)) | |
81 (point))) | |
82 (let ((old rmail-old-text)) | |
83 ;; Update the mode line. | |
84 (set-buffer-modified-p (buffer-modified-p)) | |
85 (rmail-mode-1) | |
86 (if (and (= (length old) (- (point-max) (point-min))) | |
87 (string= old (buffer-substring (point-min) (point-max)))) | |
88 () | |
89 (setq old nil) | |
90 (rmail-set-attribute "edited" t) | |
91 (if (boundp 'rmail-summary-vector) | |
92 (progn | |
93 (aset rmail-summary-vector (1- rmail-current-message) nil) | |
94 (save-excursion | |
95 (rmail-widen-to-current-msgbeg | |
96 (function (lambda () | |
97 (forward-line 2) | |
98 (if (looking-at "Summary-line: ") | |
99 (let ((buffer-read-only nil)) | |
100 (delete-region (point) | |
101 (progn (forward-line 1) | |
102 (point)))))))) | |
103 (rmail-show-message)))))) | |
104 (setq buffer-read-only t)) | |
105 | |
106 (defun rmail-abort-edit () | |
107 "Abort edit of current message; restore original contents." | |
108 (interactive) | |
109 (delete-region (point-min) (point-max)) | |
110 (insert rmail-old-text) | |
111 (rmail-cease-edit)) | |
112 | |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
368
diff
changeset
|
113 ;;; rmailedit.el ends here |