comparison lisp/mail/sendmail.el @ 16634:a076177cfac7

(mail-reply-action): Renamed from mail-reply-buffer. (mail-yank-original): Handle either an action or a buffer in mail-reply-action. (mail): Doc fix. (mail-mode-fill-paragraph): New function. (mail-mode): Set fill-paragraph-function.
author Richard M. Stallman <rms@gnu.org>
date Sat, 07 Dec 1996 22:16:27 +0000
parents 90a2c2aebc37
children 0ecab43a0f69
comparison
equal deleted inserted replaced
16633:bd4dbc8ca6f7 16634:a076177cfac7
159 If t, it means to insert the contents of the file `mail-signature-file'.") 159 If t, it means to insert the contents of the file `mail-signature-file'.")
160 160
161 (defvar mail-signature-file "~/.signature" 161 (defvar mail-signature-file "~/.signature"
162 "*File containing the text inserted at end of mail buffer.") 162 "*File containing the text inserted at end of mail buffer.")
163 163
164 (defvar mail-reply-buffer nil) 164 (defvar mail-reply-action nil)
165 (defvar mail-send-actions nil 165 (defvar mail-send-actions nil
166 "A list of actions to be performed upon successful sending of a message.") 166 "A list of actions to be performed upon successful sending of a message.")
167 (put 'mail-reply-buffer 'permanent-local t) 167 (put 'mail-reply-action 'permanent-local t)
168 (put 'mail-send-actions 'permanent-local t) 168 (put 'mail-send-actions 'permanent-local t)
169 169
170 (defvar mail-default-headers nil 170 (defvar mail-default-headers nil
171 "*A string containing header lines, to be inserted in outgoing messages. 171 "*A string containing header lines, to be inserted in outgoing messages.
172 It is inserted before you edit the message, 172 It is inserted before you edit the message,
250 (progn 250 (progn
251 (setq mail-aliases nil) 251 (setq mail-aliases nil)
252 (if (file-exists-p mail-personal-alias-file) 252 (if (file-exists-p mail-personal-alias-file)
253 (build-mail-aliases)))) 253 (build-mail-aliases))))
254 (setq mail-send-actions actions) 254 (setq mail-send-actions actions)
255 (setq mail-reply-buffer replybuffer) 255 (setq mail-reply-action replybuffer)
256 (goto-char (point-min)) 256 (goto-char (point-min))
257 (insert "To: ") 257 (insert "To: ")
258 (save-excursion 258 (save-excursion
259 (if to 259 (if to
260 ;; Here removed code to extract names from within <...> 260 ;; Here removed code to extract names from within <...>
320 C-c C-y mail-yank-original (insert current message, in Rmail). 320 C-c C-y mail-yank-original (insert current message, in Rmail).
321 C-c C-q mail-fill-yanked-message (fill what was yanked). 321 C-c C-q mail-fill-yanked-message (fill what was yanked).
322 C-c C-v mail-sent-via (add a Sent-via field for each To or CC)." 322 C-c C-v mail-sent-via (add a Sent-via field for each To or CC)."
323 (interactive) 323 (interactive)
324 (kill-all-local-variables) 324 (kill-all-local-variables)
325 (make-local-variable 'mail-reply-buffer) 325 (make-local-variable 'mail-reply-action)
326 (make-local-variable 'mail-send-actions) 326 (make-local-variable 'mail-send-actions)
327 (set-syntax-table mail-mode-syntax-table) 327 (set-syntax-table mail-mode-syntax-table)
328 (use-local-map mail-mode-map) 328 (use-local-map mail-mode-map)
329 (setq local-abbrev-table text-mode-abbrev-table) 329 (setq local-abbrev-table text-mode-abbrev-table)
330 (setq major-mode 'mail-mode) 330 (setq major-mode 'mail-mode)
334 (setq font-lock-defaults '(mail-font-lock-keywords t)) 334 (setq font-lock-defaults '(mail-font-lock-keywords t))
335 (make-local-variable 'paragraph-separate) 335 (make-local-variable 'paragraph-separate)
336 (make-local-variable 'paragraph-start) 336 (make-local-variable 'paragraph-start)
337 (make-local-variable 'normal-auto-fill-function) 337 (make-local-variable 'normal-auto-fill-function)
338 (setq normal-auto-fill-function 'mail-mode-auto-fill) 338 (setq normal-auto-fill-function 'mail-mode-auto-fill)
339 (setq fill-paragraph-function 'mail-mode-fill-paragraph)
339 ;; `-- ' precedes the signature. `-----' appears at the start of the 340 ;; `-- ' precedes the signature. `-----' appears at the start of the
340 ;; lines that delimit forwarded messages. 341 ;; lines that delimit forwarded messages.
341 ;; Lines containing just >= 3 dashes, perhaps after whitespace, 342 ;; Lines containing just >= 3 dashes, perhaps after whitespace,
342 ;; are also sometimes used and should be separators. 343 ;; are also sometimes used and should be separators.
343 (setq paragraph-start (concat (regexp-quote mail-header-separator) 344 (setq paragraph-start (concat (regexp-quote mail-header-separator)
364 (while (not (eq (point) old-line-start)) 365 (while (not (eq (point) old-line-start))
365 (insert " ") 366 (insert " ")
366 (forward-line -1)) 367 (forward-line -1))
367 t))) 368 t)))
368 (do-auto-fill))) 369 (do-auto-fill)))
370
371 (defun mail-mode-fill-paragraph (arg)
372 ;; Do something special only if within the headers.
373 (if (< (point)
374 (save-excursion
375 (goto-char (point-min))
376 (if (search-forward mail-header-separator nil t)
377 (point)
378 0)))
379 (let (beg end fieldname)
380 (re-search-backward "^[-a-zA-Z]+:" nil 'yes)
381 (setq beg (point))
382 (setq fieldname
383 (downcase (buffer-substring beg (1- (match-end 0)))))
384 (forward-line 1)
385 ;; Find continuation lines and get rid of their continuation markers.
386 (while (looking-at "[ \t]")
387 (delete-horizontal-space)
388 (forward-line 1))
389 (setq end (point-marker))
390 (goto-char beg)
391 ;; If this field contains addresses,
392 ;; make sure we can fill after each address.
393 (if (member fieldname
394 '("to" "cc" "bcc" "from" "reply-to"
395 "resent-to" "resent-cc" "resent-bcc"
396 "resent-from" "resent-reply-to"))
397 (while (search-forward "," end t)
398 (or (looking-at "[ \t]")
399 (insert " "))))
400 (fill-region-as-paragraph beg end)
401 ;; Mark all lines except the first as continuations.
402 (goto-char beg)
403 (forward-line 1)
404 (while (< (point) end)
405 (insert " ")
406 (forward-line 1))
407 (move-marker end nil)
408 t)))
369 409
370 ;;; Set up keymap. 410 ;;; Set up keymap.
371 411
372 (if mail-mode-map 412 (if mail-mode-map
373 nil 413 nil
928 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line. 968 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
929 969
930 Just \\[universal-argument] as argument means don't indent, insert no prefix, 970 Just \\[universal-argument] as argument means don't indent, insert no prefix,
931 and don't delete any header fields." 971 and don't delete any header fields."
932 (interactive "P") 972 (interactive "P")
933 (if mail-reply-buffer 973 (if mail-reply-action
934 (let ((start (point))) 974 (let ((start (point))
935 ;; If the original message is in another window in the same frame, 975 (original mail-reply-action))
936 ;; delete that window to save screen space. 976 (and (consp original) (eq (car original) 'insert-buffer)
937 ;; t means don't alter other frames. 977 (setq original (nth 1 original)))
938 (delete-windows-on mail-reply-buffer t) 978 (if (consp original)
939 (insert-buffer mail-reply-buffer) 979 (apply (car original) (cdr original))
980 ;; If the original message is in another window in the same frame,
981 ;; delete that window to save screen space.
982 ;; t means don't alter other frames.
983 (delete-windows-on original t)
984 (insert-buffer original))
940 (if (consp arg) 985 (if (consp arg)
941 nil 986 nil
942 (goto-char start) 987 (goto-char start)
943 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg) 988 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
944 mail-indentation-spaces))) 989 mail-indentation-spaces)))
1005 1050
1006 The second through fifth arguments, 1051 The second through fifth arguments,
1007 TO, SUBJECT, IN-REPLY-TO and CC, specify if non-nil 1052 TO, SUBJECT, IN-REPLY-TO and CC, specify if non-nil
1008 the initial contents of those header fields. 1053 the initial contents of those header fields.
1009 These arguments should not have final newlines. 1054 These arguments should not have final newlines.
1010 The sixth argument REPLYBUFFER is a buffer whose contents 1055 The sixth argument REPLYBUFFER is a buffer which contains an
1011 should be yanked if the user types C-c C-y. 1056 original message being replied to, or else an action
1057 of the form (FUNCTION . ARGS) which says how to insert the original.
1058 Or it can be nil, if not replying to anything.
1012 The seventh argument ACTIONS is a list of actions to take 1059 The seventh argument ACTIONS is a list of actions to take
1013 if/when the message is sent. Each action looks like (FUNCTION . ARGS); 1060 if/when the message is sent. Each action looks like (FUNCTION . ARGS);
1014 when the message is sent, we apply FUNCTION to ARGS. 1061 when the message is sent, we apply FUNCTION to ARGS.
1015 This is how Rmail arranges to mark messages `answered'." 1062 This is how Rmail arranges to mark messages `answered'."
1016 (interactive "P") 1063 (interactive "P")