shapiro@inria.UUCP (Marc Shapiro) (10/26/87)
For GNU Emacs users. Here is a useful function for mail mode,
mail-toggle-archive. It adds a mail archive line (FCC:) to the mail header
if there is none, and removes it if it's there. I bind it to C-c C-o.
(You should update the documentation string for mail-mode, too. It doesn't
print \\{mail-mode-map} as it should.)
---- (cut here) --------------------------
(setq mail-mode-hook
'(lambda ()
(define-key mail-mode-map "\C-c\C-o" 'mail-toggle-archive)))
(defun mail-toggle-archive ()
"Remove (if present) or add (if absent) the mail archive file name,
in a mail header. Variable ""mail-archive-file-name"" must be defined."
(interactive)
(save-excursion
(beginning-of-buffer)
(search-forward "\n--text follows this line--\n")
(backward-char 1)
(beginning-of-line)
(let ((eoh (point)))
(if (search-backward (concat "\nFCC: " mail-archive-file-name "\n")
(point-min) t)
(let ((bol (point)))
(forward-char 1)
(end-of-line)
(delete-region bol (point)))
(progn
(goto-char eoh)
(insert (concat "FCC: " mail-archive-file-name "\n")))))))
----- (the end) -------------------------------
Marc Shapiro
INRIA; B.P. 105; 78153 Le Chesnay Cedex; France; tel.: +33 (1) 39-63-53-25
e-mail: shapiro@inria.inria.fr; or: ...!mcvax!inria!shapiro