1 ;;; mh-comp.el --- MH-E functions for composing messages
3 ;; Copyright (C) 1993, 1995, 1997,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Bill Wohler <wohler@newt.com>
7 ;; Maintainer: Bill Wohler <wohler@newt.com>
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
30 ;; Internal support for MH-E package.
36 ;;(message "> mh-comp")
37 (eval-when-compile (require 'mh-acros))
46 (eval-when (compile load eval)
47 (ignore-errors (require 'mailabbrev)))
48 ;;(message "< mh-comp")
54 (autoload 'mail-mode-fill-paragraph "sendmail")
55 (autoload 'mm-handle-displayed-p "mm-decode")
57 (autoload 'sc-cite-original "sc"
58 "Workhorse citing function which performs the initial citation.
59 This is callable from the various mail and news readers' reply
60 function according to the agreed upon standard. See `sc-describe'
61 for more details. `sc-cite-original' does not do any yanking of the
62 original message but it does require a few things:
64 1) The reply buffer is the current buffer.
66 2) The original message has been yanked and inserted into the
69 3) Verbose mail headers from the original message have been
70 inserted into the reply buffer directly before the text of the
73 4) Point is at the beginning of the verbose headers.
75 5) Mark is at the end of the body of text to be cited.
77 For Emacs 19's, the region need not be active (and typically isn't
78 when this function is called. Also, the hook `sc-pre-hook' is run
79 before, and `sc-post-hook' is run after the guts of this function.")
83 ;;; Site customization (see also mh-utils.el):
85 (defvar mh-send-prog "send"
86 "Name of the MH send program.
87 Some sites need to change this because of a name conflict.")
89 (defvar mh-redist-background nil
90 "If non-nil redist will be done in background like send.
91 This allows transaction log to be visible if -watch, -verbose or
98 (defvar mh-note-repl ?-
99 "Messages that have been replied to are marked by this character.")
101 (defvar mh-note-forw ?F
102 "Messages that have been forwarded are marked by this character.")
104 (defvar mh-note-dist ?R
105 "Messages that have been redistributed are marked by this character.")
107 (defvar mh-yank-hooks nil
108 "Obsolete hook for modifying a citation just inserted in the mail buffer.
110 Each hook function can find the citation between point and mark.
111 And each hook function should leave point and mark around the
112 citation text as modified.
114 This is a normal hook, misnamed for historical reasons. It is
115 semi-obsolete and is only used if `mail-citation-hook' is nil.")
117 (defvar mh-comp-formfile "components"
118 "Name of file to be used as a skeleton for composing messages.
120 Default is \"components\".
122 If not an absolute file name, the file is searched for first in the
123 user's MH directory, then in the system MH lib directory.")
125 (defvar mh-repl-formfile "replcomps"
126 "Name of file to be used as a skeleton for replying to messages.
128 Default is \"replcomps\".
130 If not an absolute file name, the file is searched for first in the
131 user's MH directory, then in the system MH lib directory.")
133 (defvar mh-repl-group-formfile "replgroupcomps"
134 "Name of file to be used as a skeleton for replying to messages.
136 Default is \"replgroupcomps\".
138 This file is used to form replies to the sender and all recipients of
139 a message. Only used if `(mh-variant-p 'nmh)' is non-nil.
140 If not an absolute file name, the file is searched for first in the
141 user's MH directory, then in the system MH lib directory.")
143 (defvar mh-rejected-letter-start
146 '("Content-Type: message/rfc822" ;MIME MDN
147 "------ This is a copy of the message, including all the headers. ------";from exim
148 "--- Below this line is a copy of the message."; from qmail
149 " ----- Unsent message follows -----" ;from sendmail V5
150 " --------Unsent Message below:" ; from sendmail at BU
151 " ----- Original message follows -----" ;from sendmail V8
152 "------- Unsent Draft" ;from MH itself
153 "---------- Original Message ----------" ;from zmailer
154 " --- The unsent message follows ---" ;from AIX mail system
155 " Your message follows:" ;from MMDF-II
156 "Content-Description: Returned Content" ;1993 KJ sendmail
159 (defvar mh-new-draft-cleaned-headers
160 "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Errors-To:\\|^Delivery-Date:\\|^Return-Path:"
161 "Regexp of header lines to remove before offering a message as a new draft\\<mh-folder-mode-map>.
162 Used by the \\[mh-edit-again] and \\[mh-extract-rejected-mail] commands.")
164 (defvar mh-to-field-choices '(("a" . "Mail-Reply-To:")
169 ("l" . "Mail-Followup-To:")
174 "Alist of (final-character . field-name) choices for `mh-to-field'.")
176 (defvar mh-letter-mode-map (copy-keymap text-mode-map)
177 "Keymap for composing mail.")
179 (defvar mh-letter-mode-syntax-table nil
180 "Syntax table used by MH-E while in MH-Letter mode.")
182 (if mh-letter-mode-syntax-table
184 (setq mh-letter-mode-syntax-table
185 (make-syntax-table text-mode-syntax-table))
186 (modify-syntax-entry ?% "." mh-letter-mode-syntax-table))
188 (defvar mh-sent-from-folder nil
189 "Folder of msg assoc with this letter.")
191 (defvar mh-sent-from-msg nil
192 "Number of msg assoc with this letter.")
194 (defvar mh-send-args nil
195 "Extra args to pass to \"send\" command.")
197 (defvar mh-annotate-char nil
198 "Character to use to annotate `mh-sent-from-msg'.")
200 (defvar mh-annotate-field nil
201 "Field name for message annotation.")
203 (defvar mh-insert-auto-fields-done-local nil
204 "Buffer-local variable set when `mh-insert-auto-fields' called successfully.")
205 (make-variable-buffer-local 'mh-insert-auto-fields-done-local)
209 "Compose a message with the MH mail system.
210 See `mh-send' for more details on composing mail."
213 (call-interactively 'mh-send))
216 (defun mh-smail-other-window ()
217 "Compose a message with the MH mail system in other window.
218 See `mh-send' for more details on composing mail."
221 (call-interactively 'mh-send-other-window))
223 (defvar mh-error-if-no-draft nil) ;raise error over using old draft
226 (defun mh-smail-batch (&optional to subject other-headers &rest ignored)
227 "Compose a message with the MH mail system.
229 This function does not prompt the user for any header fields, and
230 thus is suitable for use by programs that want to create a mail
231 buffer. Users should use \\[mh-smail] to compose mail.
233 Optional arguments for setting certain fields include TO,
234 SUBJECT, and OTHER-HEADERS. Additional arguments are IGNORED.
236 This function remains for Emacs 21 compatibility. New
237 applications should use `mh-user-agent-compose'."
239 (let ((mh-error-if-no-draft t))
240 (mh-send (or to "") "" (or subject ""))))
243 (define-mail-user-agent 'mh-e-user-agent
244 'mh-user-agent-compose 'mh-send-letter 'mh-fully-kill-draft
245 'mh-before-send-letter-hook)
248 (defun mh-user-agent-compose (&optional to subject other-headers continue
249 switch-function yank-action
251 "Set up mail composition draft with the MH mail system.
252 This is the `mail-user-agent' entry point to MH-E. This function
253 conforms to the contract specified by `define-mail-user-agent'
254 which means that this function should accept the same arguments
257 The optional arguments TO and SUBJECT specify recipients and the
258 initial Subject field, respectively.
260 OTHER-HEADERS is an alist specifying additional header fields.
261 Elements look like (HEADER . VALUE) where both HEADER and VALUE
264 CONTINUE, SWITCH-FUNCTION, YANK-ACTION and SEND-ACTIONS are
267 (let ((mh-error-if-no-draft t))
268 (mh-send to "" subject)
270 (mh-insert-fields (concat (car (car other-headers)) ":")
271 (cdr (car other-headers)))
272 (setq other-headers (cdr other-headers)))))
275 (defun mh-edit-again (message)
276 "Edit a MESSAGE to send it again.
278 If you don't complete a draft for one reason or another, and if
279 the draft buffer is no longer available, you can pick your draft
280 up again with this command. If you don't use a draft folder, your
281 last \"draft\" file will be used. If you use draft folders,
282 you'll need to visit the draft folder with \"\\[mh-visit-folder]
283 drafts <RET>\", use \\[mh-next-undeleted-msg] to move to the
284 appropriate message, and then use \\[mh-edit-again] to prepare
285 the message for editing.
287 This command can also be used to take messages that were sent to
288 you and to send them to more people.
290 Don't use this command to re-edit a message from a Mailer-Daemon
291 who complained that your mail wasn't posted for some reason or
292 another (see `mh-extract-rejected-mail').
294 The default message is the current message.
297 (interactive (list (mh-get-msg-num t)))
298 (let* ((from-folder mh-current-folder)
299 (config (current-window-configuration))
301 (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
302 (pop-to-buffer (find-file-noselect (mh-msg-filename message))
304 (rename-buffer (format "draft-%d" message))
305 ;; Make buffer writable...
306 (setq buffer-read-only nil)
307 ;; If buffer was being used to display the message reinsert
309 (when (eq major-mode 'mh-show-mode)
311 (insert-file-contents buffer-file-name))
314 (mh-read-draft "clean-up" (mh-msg-filename message) nil)))))
315 (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
316 (mh-insert-header-separator)
317 (goto-char (point-min))
319 (mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
321 (mh-letter-mode-message)
322 (mh-letter-adjust-point)))
325 (defun mh-extract-rejected-mail (message)
326 "Edit a MESSAGE that was returned by the mail system.
328 This command prepares the message for editing by removing the
329 Mailer-Daemon envelope and unneeded header fields. Fix whatever
330 addressing problem you had, and send the message again with
333 The default message is the current message.
336 (interactive (list (mh-get-msg-num t)))
337 (let ((from-folder mh-current-folder)
338 (config (current-window-configuration))
339 (draft (mh-read-draft "extraction" (mh-msg-filename message) nil)))
340 (goto-char (point-min))
341 (cond ((re-search-forward mh-rejected-letter-start nil t)
342 (skip-chars-forward " \t\n")
343 (delete-region (point-min) (point))
344 (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil))
346 (message "Does not appear to be a rejected letter")))
347 (mh-insert-header-separator)
348 (goto-char (point-min))
350 (mh-compose-and-send-mail draft "" from-folder message
351 (mh-get-header-field "To:")
352 (mh-get-header-field "From:")
353 (mh-get-header-field "Cc:")
355 (mh-letter-mode-message)))
358 (defun mh-forward (to cc &optional range)
361 You are prompted for the TO and CC recipients. You are given a
362 draft to edit that looks like it would if you had run the MH
363 command \"forw\". You can then add some text.
365 You can forward several messages by using a RANGE. All of the
366 messages in the range are inserted into your draft. Check the
367 documentation of `mh-interactive-range' to see how RANGE is read
370 The hook `mh-forward-hook' is called on the draft.
372 See also `mh-compose-forward-as-mime-flag',
373 `mh-forward-subject-format', and `mh-send'."
374 (interactive (list (mh-interactive-read-address "To: ")
375 (mh-interactive-read-address "Cc: ")
376 (mh-interactive-range "Forward")))
377 (let* ((folder mh-current-folder)
378 (msgs (mh-range-to-msg-list range))
379 (config (current-window-configuration))
380 (fwd-msg-file (mh-msg-filename (car msgs) folder))
381 ;; forw always leaves file in "draft" since it doesn't have -draft
382 (draft-name (expand-file-name "draft" mh-user-path))
383 (draft (cond ((or (not (file-exists-p draft-name))
384 (y-or-n-p "The file draft exists; discard it? "))
385 (mh-exec-cmd "forw" "-build"
386 (if (and (mh-variant-p 'nmh)
387 mh-compose-forward-as-mime-flag)
390 (mh-coalesce-msg-list msgs))
392 (mh-read-draft "" draft-name t)
393 (mh-insert-fields "To:" to "Cc:" cc)
396 (mh-read-draft "" draft-name nil)))))
400 (set-buffer (get-buffer-create mh-temp-buffer))
402 (insert-file-contents fwd-msg-file)
403 (setq orig-from (mh-get-header-field "From:"))
404 (setq orig-subject (mh-get-header-field "Subject:")))
406 (mh-forwarded-letter-subject orig-from orig-subject)))
407 (mh-insert-fields "Subject:" forw-subject)
408 (goto-char (point-min))
409 ;; If using MML, translate MH-style directive
410 (if (equal mh-compose-insertion 'mml)
412 (goto-char (mh-mail-header-end))
415 "^#forw \\[\\([^]]+\\)\\] \\(+\\S-+\\) \\(.*\\)$"
417 (let ((description (if (equal (match-string 1)
418 "forwarded messages")
419 "forwarded message %d"
421 (msgs (split-string (match-string 3)))
424 (delete-region (point) (progn (forward-line 1) (point)))
427 (mh-mml-forward-message (format description i)
429 ;; Postition just before forwarded message
430 (if (re-search-forward "^------- Forwarded Message" nil t)
432 (goto-char (mh-mail-header-end))
434 (delete-other-windows)
435 (mh-add-msgs-to-seq msgs 'forwarded t)
436 (mh-compose-and-send-mail draft "" folder msgs
438 mh-note-forw "Forwarded:"
440 (mh-letter-mode-message)
441 (mh-letter-adjust-point)
442 (run-hooks 'mh-forward-hook)))))
444 (defun mh-forwarded-letter-subject (from subject)
445 "Return a Subject suitable for a forwarded message.
446 Original message has headers FROM and SUBJECT."
447 (let ((addr-start (string-match "<" from))
448 (comment (string-match "(" from)))
449 (cond ((and addr-start (> addr-start 0))
450 ;; Full Name <luser@host>
451 (setq from (substring from 0 (1- addr-start))))
453 ;; luser@host (Full Name)
454 (setq from (substring from (1+ comment) (1- (length from)))))))
455 (format mh-forward-subject-format from subject))
458 (defun mh-redistribute (to cc &optional message)
459 "Redistribute a message.
461 This command is similar in function to forwarding mail, but it
462 does not allow you to edit the message, nor does it add your name
463 to the \"From\" header field. It appears to the recipient as if
464 the message had come from the original sender. When you run this
465 command, you are prompted for the TO and CC recipients. The
466 default MESSAGE is the current message.
468 Also investigate the command \\[mh-edit-again] for another way to
469 redistribute messages.
471 See also `mh-redist-full-contents-flag'."
472 (interactive (list (mh-read-address "Redist-To: ")
473 (mh-read-address "Redist-Cc: ")
476 (setq message (mh-get-msg-num t)))
477 (save-window-excursion
478 (let ((folder mh-current-folder)
479 (draft (mh-read-draft "redistribution"
480 (if mh-redist-full-contents-flag
481 (mh-msg-filename message)
484 (mh-goto-header-end 0)
485 (insert "Resent-To: " to "\n")
486 (if (not (equal cc "")) (insert "Resent-cc: " cc "\n"))
489 "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:"
492 (message "Redistributing...")
493 (let ((env "mhdist=1"))
494 ;; Setup environment...
495 (setq env (concat env " mhaltmsg="
496 (if mh-redist-full-contents-flag
498 (mh-msg-filename message folder))))
499 (unless mh-redist-full-contents-flag
500 (setq env (concat env " mhannotate=1")))
502 (if mh-redist-background
503 (mh-exec-cmd-env-daemon env mh-send-prog nil buffer-file-name)
504 (mh-exec-cmd-error env mh-send-prog "-push" buffer-file-name))
506 (mh-annotate-msg message folder mh-note-dist
507 "-component" "Resent:"
508 "-text" (format "\"%s %s\"" to cc)))
510 (message "Redistributing...done"))))
512 (defun mh-show-buffer-message-number (&optional buffer)
513 "Message number of displayed message in corresponding show buffer.
515 Return nil if show buffer not displayed.
516 If in `mh-letter-mode', don't display the message number being replied
517 to, but rather the message number of the show buffer associated with
518 our originating folder buffer.
519 Optional argument BUFFER can be used to specify the buffer."
523 (cond ((eq major-mode 'mh-show-mode)
524 (let ((number-start (mh-search-from-end ?/ buffer-file-name)))
525 (string-to-number (substring buffer-file-name
526 (1+ number-start)))))
527 ((and (eq major-mode 'mh-folder-mode)
529 (get-buffer mh-show-buffer))
530 (mh-show-buffer-message-number mh-show-buffer))
531 ((and (eq major-mode 'mh-letter-mode)
533 (get-buffer mh-sent-from-folder))
534 (mh-show-buffer-message-number mh-sent-from-folder))
539 (defun mh-reply (message &optional reply-to includep)
542 When you reply to a message, you are first prompted with \"Reply
543 to whom?\" (unless the optional argument REPLY-TO is provided).
544 You have several choices here.
546 Response Reply Goes To
548 from The person who sent the message. This is the
549 default, so <RET> is sufficient.
551 to Replies to the sender, plus all recipients in the
552 \"To:\" header field.
555 cc Forms a reply to the sender, plus all recipients.
557 Depending on your answer, \"repl\" is given a different argument
558 to form your reply. Specifically, a choice of \"from\" or none at
559 all runs \"repl -nocc all\", and a choice of \"to\" runs \"repl
560 -cc to\". Finally, either \"cc\" or \"all\" runs \"repl -cc all
563 Two windows are then created. One window contains the message to
564 which you are replying in an MH-Show buffer. Your draft, in
565 MH-Letter mode (see `mh-letter-mode'), is in the other window.
567 If you supply a prefix argument INCLUDEP, the message you are
568 replying to is inserted in your reply after having first been run
569 through \"mhl\" with the format file \"mhl.reply\".
571 Alternatively, you can customize the option `mh-yank-behavior'
572 and choose one of its \"Automatically\" variants to do the same
573 thing. If you do so, the prefix argument has no effect.
575 Another way to include the message automatically in your draft is
576 to use \"repl: -filter repl.filter\" in your MH profile.
578 If you wish to customize the header or other parts of the reply
579 draft, please see \"repl\" and \"mh-format\".
581 See also `mh-reply-show-message-flag',
582 `mh-reply-default-reply-to', and `mh-send'."
585 (let ((minibuffer-help-form
586 "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
587 (or mh-reply-default-reply-to
588 (completing-read "Reply to whom (default from): "
589 '(("from") ("to") ("cc") ("all"))
593 (let* ((folder mh-current-folder)
594 (show-buffer mh-show-buffer)
595 (config (current-window-configuration))
596 (group-reply (or (equal reply-to "cc") (equal reply-to "all")))
597 (form-file (cond ((and (mh-variant-p 'nmh 'mu-mh) group-reply
598 (stringp mh-repl-group-formfile))
599 mh-repl-group-formfile)
600 ((stringp mh-repl-formfile) mh-repl-formfile)
602 (message "Composing a reply...")
603 (mh-exec-cmd "repl" "-build" "-noquery" "-nodraftfolder"
605 (list "-form" form-file))
606 mh-current-folder message
607 (cond ((or (equal reply-to "from") (equal reply-to ""))
609 ((equal reply-to "to")
611 (group-reply (if (mh-variant-p 'nmh 'mu-mh)
612 '("-group" "-nocc" "me")
613 '("-cc" "all" "-nocc" "me"))))
614 (cond ((or (eq mh-yank-behavior 'autosupercite)
615 (eq mh-yank-behavior 'autoattrib))
617 (includep '("-filter" "mhl.reply"))
619 (let ((draft (mh-read-draft "reply"
620 (expand-file-name "reply" mh-user-path)
622 (delete-other-windows)
625 (let ((to (mh-get-header-field "To:"))
626 (subject (mh-get-header-field "Subject:"))
627 (cc (mh-get-header-field "Cc:")))
628 (goto-char (point-min))
629 (mh-goto-header-end 1)
631 (not mh-reply-show-message-flag)
632 (mh-in-show-buffer (show-buffer)
633 (mh-display-msg message folder)))
634 (mh-add-msgs-to-seq message 'answered t)
635 (message "Composing a reply...done")
636 (mh-compose-and-send-mail draft "" folder message to subject cc
637 mh-note-repl "Replied:" config))
638 (when (and (or (eq 'autosupercite mh-yank-behavior)
639 (eq 'autoattrib mh-yank-behavior))
640 (eq (mh-show-buffer-message-number) mh-sent-from-msg))
643 (mh-letter-mode-message))))
646 (defun mh-send (to cc subject)
649 Your letter appears in an Emacs buffer whose mode is
650 MH-Letter (see `mh-letter-mode').
652 The arguments TO, CC, and SUBJECT can be used to prefill the
653 draft fields or suppress the prompts if `mh-compose-prompt-flag'
654 is on. They are also passed to the function set in the option
655 `mh-compose-letter-function'.
657 See also `mh-insert-x-mailer-flag' and `mh-letter-mode-hook'.
659 Outside of an MH-Folder buffer (`mh-folder-mode'), you must call
660 either \\[mh-smail] or \\[mh-smail-other-window] to compose a new
663 (mh-interactive-read-address "To: ")
664 (mh-interactive-read-address "Cc: ")
665 (mh-interactive-read-string "Subject: ")))
666 (let ((config (current-window-configuration)))
667 (delete-other-windows)
668 (mh-send-sub to cc subject config)))
671 (defun mh-send-other-window (to cc subject)
672 "Compose a message in another window.
674 See `mh-send' for more information and a description of how the
675 TO, CC, and SUBJECT arguments are used."
677 (mh-interactive-read-address "To: ")
678 (mh-interactive-read-address "Cc: ")
679 (mh-interactive-read-string "Subject: ")))
680 (let ((pop-up-windows t))
681 (mh-send-sub to cc subject (current-window-configuration))))
683 (defun mh-send-sub (to cc subject config)
684 "Do the real work of composing and sending a letter.
685 Expects the TO, CC, and SUBJECT fields as arguments.
686 CONFIG is the window configuration before sending mail."
687 (let ((folder mh-current-folder)
688 (msg-num (mh-get-msg-num nil)))
689 (message "Composing a message...")
690 (let ((draft (mh-read-draft
696 (expand-file-name mh-comp-formfile mh-user-path)))
700 (expand-file-name mh-comp-formfile mh-lib)))
704 (expand-file-name mh-comp-formfile
705 ;; What is this mh-etc ?? -sm
706 ;; This is dead code, so
708 ;(and (boundp 'mh-etc) mh-etc)
712 (error "Can't find components file \"%s\""
715 (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
716 (goto-char (point-max))
717 (mh-compose-and-send-mail draft "" folder msg-num
720 (mh-letter-mode-message)
721 (mh-letter-adjust-point))))
723 (defun mh-read-draft (use initial-contents delete-contents-file)
724 "Read draft file into a draft buffer and make that buffer the current one.
726 USE is a message used for prompting about the intended use of the
728 INITIAL-CONTENTS is filename that is read into an empty buffer, or nil
729 if buffer should not be modified. Delete the initial-contents file if
730 DELETE-CONTENTS-FILE flag is set.
731 Returns the draft folder's name.
732 If the draft folder facility is enabled in ~/.mh_profile, a new buffer
733 is used each time and saved in the draft folder. The draft file can
735 (cond (mh-draft-folder
736 (let ((orig-default-dir default-directory)
737 (draft-file-name (mh-new-draft-name)))
738 (pop-to-buffer (generate-new-buffer
740 (file-name-nondirectory draft-file-name))))
742 (insert-file-contents draft-file-name t)
744 (setq default-directory orig-default-dir)))
746 (let ((draft-name (expand-file-name "draft" mh-user-path)))
747 (pop-to-buffer "draft") ; Create if necessary
748 (if (buffer-modified-p)
749 (if (y-or-n-p "Draft has been modified; kill anyway? ")
750 (set-buffer-modified-p nil)
751 (error "Draft preserved")))
752 (setq buffer-file-name draft-name)
753 (clear-visited-file-modtime)
755 (cond ((and (file-exists-p draft-name)
756 (not (equal draft-name initial-contents)))
757 (insert-file-contents draft-name)
758 (delete-file draft-name))))))
759 (cond ((and initial-contents
760 (or (zerop (buffer-size))
762 (format "A draft exists. Use for %s? " use))
763 (if mh-error-if-no-draft
764 (error "A prior draft exists"))
767 (insert-file-contents initial-contents)
768 (if delete-contents-file (delete-file initial-contents))))
771 (save-buffer)) ; Do not reuse draft name
774 (defun mh-new-draft-name ()
775 "Return the pathname of folder for draft messages."
777 (mh-exec-cmd-quiet t "mhpath" mh-draft-folder "new")
778 (buffer-substring (point-min) (1- (point-max)))))
780 (defun mh-annotate-msg (msg buffer note &rest args)
781 "Mark MSG in BUFFER with character NOTE and annotate message with ARGS.
782 MSG can be a message number, a list of message numbers, or a
784 (apply 'mh-exec-cmd "anno" buffer
785 (if (listp msg) (append msg args) (cons msg args)))
787 (cond ((get-buffer buffer) ; Buffer may be deleted
789 (mh-iterate-on-range nil msg
791 (+ mh-cmd-note mh-scan-field-destination-offset)))))))
793 (defun mh-insert-fields (&rest name-values)
794 "Insert the NAME-VALUES pairs in the current buffer.
795 If the field exists, append the value to it.
796 Do not insert any pairs whose value is the empty string."
797 (let ((case-fold-search t))
799 (let ((field-name (car name-values))
800 (value (car (cdr name-values))))
801 (if (not (string-match "^.*:$" field-name))
802 (setq field-name (concat field-name ":")))
803 (cond ((equal value "")
805 ((mh-position-on-field field-name)
806 (insert " " (or value "")))
808 (insert field-name " " value "\n")))
809 (setq name-values (cdr (cdr name-values)))))))
811 (defun mh-position-on-field (field &optional ignored)
812 "Move to the end of the FIELD in the header.
813 Move to end of entire header if FIELD not found.
814 Returns non-nil iff FIELD was found.
815 The optional second arg is for pre-version 4 compatibility and is
817 (cond ((mh-goto-header-field field)
818 (mh-header-field-end)
820 ((mh-goto-header-end 0)
824 (defun mh-get-header-field (field)
825 "Find and return the body of FIELD in the mail header.
826 Returns the empty string if the field is not in the header of the
828 (if (mh-goto-header-field field)
830 (skip-chars-forward " \t") ;strip leading white space in body
831 (let ((start (point)))
832 (mh-header-field-end)
833 (buffer-substring-no-properties start (point))))
836 (fset 'mh-get-field 'mh-get-header-field) ;MH-E 4 compatibility
838 (defun mh-goto-header-field (field)
839 "Move to FIELD in the message header.
840 Move to the end of the FIELD name, which should end in a colon.
841 Returns t if found, nil if not."
842 (goto-char (point-min))
843 (let ((case-fold-search t)
844 (headers-end (save-excursion
845 (mh-goto-header-end 0)
847 (re-search-forward (format "^%s" field) headers-end t)))
849 (defun mh-goto-header-end (arg)
850 "Move the cursor ARG lines after the header."
851 (if (re-search-forward "^-*$" nil nil)
854 (defun mh-extract-from-header-value ()
855 "Extract From: string from header."
857 (if (not (mh-goto-header-field "From:"))
859 (skip-chars-forward " \t")
860 (buffer-substring-no-properties
861 (point) (progn (mh-header-field-end)(point))))))
865 ;;; Mode for composing and sending a draft message.
867 (defvar mh-pgp-support-flag (not (not (locate-library "mml2015")))
868 "Non-nil means PGP support is available.")
870 (put 'mh-letter-mode 'mode-class 'special)
872 ;; Menu extracted from mh-menubar.el V1.1 (31 July 2001)
873 (eval-when-compile (defvar mh-letter-menu nil))
875 mh-letter-menu mh-letter-mode-map "Menu for MH-E letter mode."
877 ["Send This Draft" mh-send-letter t]
878 ["Split Current Line" mh-open-line t]
879 ["Check Recipient" mh-check-whom t]
880 ["Yank Current Message" mh-yank-cur-msg t]
881 ["Insert a Message..." mh-insert-letter t]
882 ["Insert Signature" mh-insert-signature t]
883 ("Encrypt/Sign Message"
885 mh-mml-secure-message-sign mh-pgp-support-flag]
887 mh-mml-secure-message-encrypt mh-pgp-support-flag]
888 ["Sign+Encrypt Message"
889 mh-mml-secure-message-signencrypt mh-pgp-support-flag]
891 mh-mml-unsecure-message mh-pgp-support-flag]
894 ["PGP (MIME)" (setq mh-mml-method-default "pgpmime")
896 :selected (equal mh-mml-method-default "pgpmime")]
897 ["PGP" (setq mh-mml-method-default "pgp")
899 :selected (equal mh-mml-method-default "pgp")]
900 ["S/MIME" (setq mh-mml-method-default "smime")
902 :selected (equal mh-mml-method-default "smime")]
904 ["Save Method as Default"
905 (customize-save-variable 'mh-mml-method-default mh-mml-method-default) t]
907 ["Compose Insertion..." mh-compose-insertion t]
908 ["Compose Compressed tar (MH)..."
909 mh-mh-compose-external-compressed-tar t]
910 ["Compose Get File (MH)..." mh-mh-compose-anon-ftp t]
911 ["Compose Forward..." mh-compose-forward t]
912 ;; The next two will have to be merged. But I also need to make sure the
913 ;; user can't mix tags of both types.
914 ["Pull in All Compositions (MH)"
915 mh-mh-to-mime (mh-mh-directive-present-p)]
916 ["Pull in All Compositions (MML)"
917 mh-mml-to-mime (mh-mml-tag-present-p)]
918 ["Revert to Non-MIME Edit (MH)"
919 mh-mh-to-mime-undo (equal mh-compose-insertion 'mh)]
920 ["Kill This Draft" mh-fully-kill-draft t]))
926 ;; Group messages logically, more or less.
927 (defvar mh-letter-mode-help-messages
929 "Send letter: \\[mh-send-letter]"
930 "\t\tOpen line: \\[mh-open-line]\n"
931 "Kill letter: \\[mh-fully-kill-draft]"
933 "Check recipients: \\[mh-check-whom]"
934 "\t\t Current message: \\[mh-yank-cur-msg]\n"
935 "\t\t Attachment: \\[mh-compose-insertion]\n"
936 "\t\t Message to forward: \\[mh-compose-forward]\n"
939 "\t\t Encrypt message: \\[mh-mml-secure-message-encrypt]"
940 "\t\t Sign+Encrypt message: \\[mh-mml-secure-message-signencrypt]"
941 "\t\t Sign message: \\[mh-mml-secure-message-sign]\n"
943 "\t\t Signature: \\[mh-insert-signature]"))
944 "Key binding cheat sheet.
946 This is an associative array which is used to show the most
947 common commands. The key is a prefix char. The value is one or
948 more strings which are concatenated together and displayed in the
949 minibuffer if ? is pressed after the prefix character. The
950 special key nil is used to display the non-prefixed commands.
952 The substitutions described in `substitute-command-keys' are
957 (defvar adaptive-fill-first-line-regexp)
958 (defvar tool-bar-map))
960 (defvar mh-letter-buttons-init-flag nil)
963 (define-derived-mode mh-letter-mode mail-mode "MH-Letter"
964 "Mode for composing letters in MH-E\\<mh-letter-mode-map>.
966 When you have finished composing, type \\[mh-send-letter] to send
967 the message using the MH mail handling system.
969 There are two types of tags used by MH-E when composing MIME
970 messages: MML and MH. The option `mh-compose-insertion' controls
971 what type of tags are inserted by MH-E commands. These tags can
972 be converted to MIME body parts by running \\[mh-mh-to-mime] for
973 MH-style directives or \\[mh-mml-to-mime] for MML tags.
975 Options that control this mode can be changed with
976 \\[customize-group]; specify the \"mh-compose\" group.
978 When a message is composed, the hooks `text-mode-hook',
979 `mail-mode-hook', and `mh-letter-mode-hook' are run (in that
982 \\{mh-letter-mode-map}"
984 (make-local-variable 'mh-send-args)
985 (make-local-variable 'mh-annotate-char)
986 (make-local-variable 'mh-annotate-field)
987 (make-local-variable 'mh-previous-window-config)
988 (make-local-variable 'mh-sent-from-folder)
989 (make-local-variable 'mh-sent-from-msg)
991 (unless mh-letter-buttons-init-flag
992 (mh-tool-bar-letter-buttons-init)
993 (setq mh-letter-buttons-init-flag t)))
994 ;; Set the local value of mh-mail-header-separator according to what is
995 ;; present in the buffer...
996 (set (make-local-variable 'mh-mail-header-separator)
998 (goto-char (mh-mail-header-end))
999 (buffer-substring-no-properties (point) (line-end-position))))
1000 (make-local-variable 'mail-header-separator)
1001 (setq mail-header-separator mh-mail-header-separator) ;override sendmail.el
1002 (make-local-variable 'mh-help-messages)
1003 (setq mh-help-messages mh-letter-mode-help-messages)
1004 (setq buffer-invisibility-spec '((vanish . t) t))
1005 (set (make-local-variable 'line-move-ignore-invisible) t)
1007 ;; Enable undo since a show-mode buffer might have been reused.
1008 (buffer-enable-undo)
1009 (set (make-local-variable 'tool-bar-map) mh-letter-tool-bar-map)
1010 (mh-funcall-if-exists mh-tool-bar-init :letter)
1011 (make-local-variable 'font-lock-defaults)
1013 ((or (equal mh-highlight-citation-style 'font-lock)
1014 (equal mh-highlight-citation-style 'gnus))
1015 ;; Let's use font-lock even if gnus is used in show-mode. The reason
1016 ;; is that gnus uses static text properties which are not appropriate
1017 ;; for a buffer that will be edited. So the choice here is either fontify
1018 ;; the citations and header...
1019 (setq font-lock-defaults '(mh-letter-font-lock-keywords t)))
1021 ;; ...or the header only
1022 (setq font-lock-defaults '(mh-show-font-lock-keywords t))))
1023 (easy-menu-add mh-letter-menu)
1024 (setq fill-column mh-letter-fill-column)
1025 ;; If text-mode-hook turned on auto-fill, tune it for messages
1026 (when auto-fill-function
1027 (make-local-variable 'auto-fill-function)
1028 (setq auto-fill-function 'mh-auto-fill-for-letter)))
1030 (defun mh-font-lock-field-data (limit)
1031 "Find header field region between point and LIMIT."
1032 (and (< (point) (mh-letter-header-end))
1034 (let ((end (min limit (mh-letter-header-end)))
1036 data-end data-begin field)
1038 (setq data-end (if (re-search-forward "^[^ \t]" end t)
1041 (goto-char (1- data-end))
1042 (if (not (re-search-backward "\\(^[^ \t][^:]*\\):[ \t]*" nil t))
1043 (setq data-begin (point-min))
1044 (setq data-begin (match-end 0))
1045 (setq field (match-string 1)))
1046 (setq data-begin (max point data-begin))
1047 (goto-char (if (equal point data-end) (1+ data-end) data-end))
1048 (cond ((and field (mh-letter-skipped-header-field-p field))
1049 (set-match-data nil)
1052 (list data-begin data-end data-begin data-end))
1055 (defun mh-letter-header-end ()
1056 "Find the end of the message header.
1057 This function is to be used only for font locking. It works by
1058 searching for `mh-mail-header-separator' in the buffer."
1060 (goto-char (point-min))
1061 (cond ((equal mh-mail-header-separator "") (point-min))
1062 ((search-forward (format "\n%s\n" mh-mail-header-separator) nil t)
1063 (line-beginning-position 0))
1066 (defun mh-auto-fill-for-letter ()
1067 "Perform auto-fill for message.
1068 Header is treated specially by inserting a tab before continuation
1070 (if (mh-in-header-p)
1071 (let ((fill-prefix "\t"))
1075 (defun mh-insert-header-separator ()
1076 "Insert `mh-mail-header-separator', if absent."
1078 (goto-char (point-min))
1080 (if (looking-at "$")
1081 (insert mh-mail-header-separator))))
1084 (defun mh-to-field ()
1085 "Move to specified header field.
1087 The field is indicated by the previous keystroke (the last
1088 keystroke of the command) according to the list in the variable
1089 `mh-to-field-choices'.
1090 Create the field if it does not exist.
1091 Set the mark to point before moving."
1094 (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
1095 mh-to-field-choices)
1096 ;; also look for a char for version 4 compat
1097 (assoc (logior last-input-char ?`)
1098 mh-to-field-choices))))
1099 (case-fold-search t))
1101 (cond ((mh-position-on-field target)
1102 (let ((eol (point)))
1103 (skip-chars-backward " \t")
1104 (delete-region (point) eol))
1105 (if (and (not (eq (logior last-input-char ?`) ?s))
1108 (not (looking-at "[:,]"))))
1112 (if (mh-position-on-field "To:")
1114 (insert (format "%s \n" target))
1115 (backward-char 1)))))
1118 (defun mh-to-fcc (&optional folder)
1119 "Move to \"Fcc:\" header field.
1121 This command will prompt you for the FOLDER name in which to file
1122 a copy of the draft."
1123 (interactive (list (mh-prompt-for-folder
1125 (or (and mh-default-folder-for-message-function
1127 (goto-char (point-min))
1129 mh-default-folder-for-message-function)))
1132 (let ((last-input-char ?\C-f))
1136 (insert (if (mh-folder-name-p folder)
1137 (substring folder 1)
1140 (defun mh-file-is-vcard-p (file)
1141 "Return t if FILE is a .vcf vcard."
1142 (let ((case-fold-search t))
1144 (file-exists-p file)
1145 (or (and (not (mh-have-file-command))
1146 (not (null (string-match "\.vcf$" file))))
1147 (string-equal "text/x-vcard" (mh-file-mime-type file))))))
1150 (defun mh-insert-signature (&optional file)
1151 "Insert signature in message.
1153 This command inserts your signature at the current cursor location.
1155 By default, the text of your signature is taken from the file
1156 \"~/.signature\". You can read from other sources by changing the
1157 option `mh-signature-file-name'.
1159 A signature separator (\"-- \") will be added if the signature block
1160 does not contain one and `mh-signature-separator-flag' is on.
1162 The hook `mh-insert-signature-hook' is run after the signature is
1163 inserted. Hook functions may access the actual name of the file or the
1164 function used to insert the signature with `mh-signature-file-name'.
1166 The signature can also be inserted using Identities (see
1167 `mh-identity-list').
1169 In a program, you can pass in a signature FILE."
1173 (let ((mh-signature-file-name (or file mh-signature-file-name))
1174 (mh-mh-p (mh-mh-directive-present-p))
1175 (mh-mml-p (mh-mml-tag-present-p)))
1177 (narrow-to-region (point) (point))
1179 ((mh-file-is-vcard-p mh-signature-file-name)
1180 (if (equal mh-compose-insertion 'mml)
1181 (insert "<#part type=\"text/x-vcard\" filename=\""
1182 mh-signature-file-name
1183 "\" disposition=inline description=VCard>\n<#/part>")
1184 (insert "#text/x-vcard; name=\""
1185 (file-name-nondirectory mh-signature-file-name)
1186 "\" [VCard] " (expand-file-name mh-signature-file-name))))
1190 (insert "#\n" "Content-Description: Signature\n"))
1192 (mml-insert-tag 'part 'type "text/plain" 'disposition "inline"
1193 'description "Signature")))
1194 (cond ((null mh-signature-file-name))
1195 ((and (stringp mh-signature-file-name)
1196 (file-readable-p mh-signature-file-name))
1197 (insert-file-contents mh-signature-file-name))
1198 ((functionp mh-signature-file-name)
1199 (funcall mh-signature-file-name)))))
1202 (run-hooks 'mh-insert-signature-hook))
1203 (goto-char (point-min))
1204 (when (and (not (mh-file-is-vcard-p mh-signature-file-name))
1205 mh-signature-separator-flag
1206 (> (point-max) (point-min))
1207 (not (mh-signature-separator-p)))
1212 (insert mh-signature-separator))
1213 (if (not (> (point-max) (point-min)))
1214 (message "No signature found")))))
1215 (force-mode-line-update))
1218 (defun mh-check-whom ()
1219 "Verify recipients, showing expansion of any aliases.
1221 This command expands aliases so you can check the actual address(es)
1222 in the alias. A new buffer named \"*MH-E Recipients*\" is created with
1223 the output of \"whom\"."
1225 (let ((file-name buffer-file-name))
1227 (message "Checking recipients...")
1228 (mh-in-show-buffer (mh-recipients-buffer)
1229 (bury-buffer (current-buffer))
1231 (mh-exec-cmd-output "whom" t file-name))
1232 (message "Checking recipients...done")))
1234 (defun mh-tidy-draft-buffer ()
1235 "Run when a draft buffer is destroyed."
1236 (let ((buffer (get-buffer mh-recipients-buffer)))
1238 (kill-buffer buffer))))
1242 ;;; Routines to compose and send a letter.
1244 (defun mh-insert-x-face ()
1245 "Append X-Face, Face or X-Image-URL field to header.
1246 If the field already exists, this function does nothing."
1247 (when (and (file-exists-p mh-x-face-file)
1248 (file-readable-p mh-x-face-file))
1250 (unless (or (mh-position-on-field "X-Face")
1251 (mh-position-on-field "Face")
1252 (mh-position-on-field "X-Image-URL"))
1254 (goto-char (+ (point) (cadr (insert-file-contents mh-x-face-file))))
1255 (if (not (looking-at "^"))
1257 (unless (looking-at "\\(X-Face\\|Face\\|X-Image-URL\\): ")
1258 (insert "X-Face: "))))))
1260 (defvar mh-x-mailer-string nil
1261 "*String containing the contents of the X-Mailer header field.
1262 If nil, this variable is initialized to show the version of MH-E,
1263 Emacs, and MH the first time a message is composed.")
1265 (defun mh-insert-x-mailer ()
1266 "Append an X-Mailer field to the header.
1267 The versions of MH-E, Emacs, and MH are shown."
1268 ;; Lazily initialize mh-x-mailer-string.
1269 (when (and mh-insert-x-mailer-flag (null mh-x-mailer-string))
1270 (setq mh-x-mailer-string
1271 (format "MH-E %s; %s; %sEmacs %s"
1272 mh-version mh-variant-in-use
1273 (if mh-xemacs-flag "X" "GNU ")
1274 (cond ((not mh-xemacs-flag) emacs-version)
1275 ((string-match "[0-9.]*\\( +\([ a-z]+[0-9]+\)\\)?"
1277 (match-string 0 emacs-version))
1278 (t (format "%s.%s" emacs-major-version
1279 emacs-minor-version))))))
1280 ;; Insert X-Mailer, but only if it doesn't already exist.
1282 (when (and mh-insert-x-mailer-flag
1283 (null (mh-goto-header-field "X-Mailer")))
1284 (mh-insert-fields "X-Mailer:" mh-x-mailer-string))))
1286 (defun mh-regexp-in-field-p (regexp &rest fields)
1287 "Non-nil means REGEXP was found in FIELDS."
1289 (let ((search-result nil)
1292 (setq field (car fields))
1293 (if (and (mh-goto-header-field field)
1295 regexp (save-excursion (mh-header-field-end)(point)) t))
1298 (setq fields (cdr fields))))
1302 (defun mh-insert-auto-fields (&optional non-interactive)
1303 "Insert custom fields if recipient is found in `mh-auto-fields-list'.
1305 Sets buffer-local `mh-insert-auto-fields-done-local' if header
1306 fields were added. If NON-INTERACTIVE is non-nil, perform actions
1307 quietly and only if `mh-insert-auto-fields-done-local' is nil.
1309 An `identity' entry is skipped if one was already entered
1312 Return t if fields added; otherwise return nil."
1314 (when (or (not non-interactive)
1315 (not mh-insert-auto-fields-done-local))
1317 (when (and (or (mh-goto-header-field "To:")
1318 (mh-goto-header-field "cc:")))
1319 (let ((list mh-auto-fields-list)
1320 (fields-inserted nil))
1322 (let ((regexp (nth 0 (car list)))
1323 (entries (nth 1 (car list))))
1324 (when (mh-regexp-in-field-p regexp "To:" "cc:")
1325 (setq mh-insert-auto-fields-done-local t)
1326 (setq fields-inserted t)
1327 (if (not non-interactive)
1328 (message "Fields for %s added" regexp))
1329 (let ((entry-list entries))
1331 (let ((field (caar entry-list))
1332 (value (cdar entry-list)))
1334 ((equal ":identity" field)
1335 (when ;;(and (not mh-identity-local)
1336 ;; Bug 1204506. But do we need to be able
1337 ;; to set an identity manually that won't be
1338 ;; overridden by mh-insert-auto-fields?
1339 (assoc value mh-identity-list)
1341 (mh-insert-identity value)))
1343 (mh-modify-header-field field value
1344 (equal field "From")))))
1345 (setq entry-list (cdr entry-list))))))
1346 (setq list (cdr list)))
1347 fields-inserted)))))
1349 (defun mh-modify-header-field (field value &optional overwrite-flag)
1350 "To header FIELD add VALUE.
1351 If OVERWRITE-FLAG is non-nil then the old value, if present, is
1353 (cond ((and overwrite-flag
1354 (mh-goto-header-field (concat field ":")))
1356 (delete-region (point) (line-end-position)))
1357 ((and (not overwrite-flag)
1358 (mh-regexp-in-field-p (concat "\\b" value "\\b") field))
1359 ;; Already there, do nothing.
1361 ((and (not overwrite-flag)
1362 (mh-goto-header-field (concat field ":")))
1363 (insert " " value ","))
1365 (mh-goto-header-end 0)
1366 (insert field ": " value "\n"))))
1368 (defun mh-compose-and-send-mail (draft send-args
1369 sent-from-folder sent-from-msg
1371 annotate-char annotate-field
1373 "Edit and compose a draft message in buffer DRAFT and send or save it.
1374 SEND-ARGS is the argument passed to the send command.
1375 SENT-FROM-FOLDER is buffer containing scan listing of current folder,
1376 or nil if none exists.
1377 SENT-FROM-MSG is the message number or sequence name or nil.
1378 The TO, SUBJECT, and CC fields are passed to the
1379 `mh-compose-letter-function'.
1380 If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of
1381 the message. In that case, the ANNOTATE-FIELD is used to build a
1382 string for `mh-annotate-msg'.
1383 CONFIG is the window configuration to restore after sending the
1385 (pop-to-buffer draft)
1389 (if (and (boundp 'mh-identity-default)
1391 (not mh-identity-local))
1392 (mh-insert-identity mh-identity-default))
1393 (mh-identity-make-menu)
1394 (easy-menu-add mh-identity-menu)
1396 ;; Insert extra fields.
1397 (mh-insert-x-mailer)
1400 (mh-letter-hide-all-skipped-fields)
1402 (setq mh-sent-from-folder sent-from-folder)
1403 (setq mh-sent-from-msg sent-from-msg)
1404 (setq mh-send-args send-args)
1405 (setq mh-annotate-char annotate-char)
1406 (setq mh-annotate-field annotate-field)
1407 (setq mh-previous-window-config config)
1408 (setq mode-line-buffer-identification (list " {%b}"))
1410 (mh-make-local-hook 'kill-buffer-hook)
1411 (add-hook 'kill-buffer-hook 'mh-tidy-draft-buffer nil t)
1412 (if (and (boundp 'mh-compose-letter-function)
1413 mh-compose-letter-function)
1414 ;; run-hooks will not pass arguments.
1415 (let ((value mh-compose-letter-function))
1416 (if (and (listp value) (not (eq (car value) 'lambda)))
1418 (funcall (car value) to subject cc)
1419 (setq value (cdr value)))
1420 (funcall mh-compose-letter-function to subject cc)))))
1422 (defun mh-letter-mode-message ()
1423 "Display a help message for users of `mh-letter-mode'.
1424 This should be the last function called when composing the draft."
1425 (message "%s" (substitute-command-keys
1426 (concat "Type \\[mh-send-letter] to send message, "
1427 "\\[mh-help] for help"))))
1429 (defun mh-ascii-buffer-p ()
1430 "Check if current buffer is entirely composed of ASCII.
1431 The function doesn't work for XEmacs since `find-charset-region'
1432 doesn't exist there."
1433 (loop for charset in (mh-funcall-if-exists
1434 find-charset-region (point-min) (point-max))
1435 unless (eq charset 'ascii) return nil
1439 (eval-when-compile (defvar sendmail-coding-system))
1442 (defun mh-send-letter (&optional arg)
1443 "Save draft and send message.
1445 When you are all through editing a message, you send it with this
1446 command. You can give a prefix argument ARG to monitor the first stage
1447 of the delivery\; this output can be found in a buffer called \"*MH-E
1450 The hook `mh-before-send-letter-hook' is run at the beginning of
1451 this command. For example, if you want to check your spelling in
1452 your message before sending, add the function `ispell-message'.
1454 In case the MH \"send\" program is installed under a different name,
1455 use `mh-send-prog' to tell MH-E the name."
1457 (run-hooks 'mh-before-send-letter-hook)
1458 (if (and (mh-insert-auto-fields t)
1459 mh-auto-fields-prompt-flag
1460 (goto-char (point-min)))
1461 (if (not (y-or-n-p "Auto fields inserted, send? "))
1462 (error "Send aborted")))
1463 (cond ((mh-mh-directive-present-p)
1465 ((or (mh-mml-tag-present-p) (not (mh-ascii-buffer-p)))
1468 (message "Sending...")
1469 (let ((draft-buffer (current-buffer))
1470 (file-name buffer-file-name)
1471 (config mh-previous-window-config)
1472 (coding-system-for-write
1473 (if (and (local-variable-p 'buffer-file-coding-system
1474 (current-buffer)) ;XEmacs needs two args
1475 ;; We're not sure why, but buffer-file-coding-system
1476 ;; tends to get set to undecided-unix.
1477 (not (memq buffer-file-coding-system
1478 '(undecided undecided-unix undecided-dos))))
1479 buffer-file-coding-system
1480 (or (and (boundp 'sendmail-coding-system) sendmail-coding-system)
1481 (and (boundp 'default-buffer-file-coding-system )
1482 default-buffer-file-coding-system)
1484 ;; Adding a Message-ID field looks good, makes it easier to search for
1485 ;; message in your +outbox, and best of all doesn't break threading for
1486 ;; the recipient if you reply to a message in your +outbox.
1487 (setq mh-send-args (concat "-msgid " mh-send-args))
1488 ;; The default BCC encapsulation will make a MIME message unreadable.
1489 ;; With nmh use the -mime arg to prevent this.
1490 (if (and (mh-variant-p 'nmh)
1491 (mh-goto-header-field "Bcc:")
1492 (mh-goto-header-field "Content-Type:"))
1493 (setq mh-send-args (concat "-mime " mh-send-args)))
1495 (pop-to-buffer mh-mail-delivery-buffer)
1497 (mh-exec-cmd-output mh-send-prog t "-watch" "-nopush"
1498 "-nodraftfolder" mh-send-args file-name)
1499 (goto-char (point-max)) ; show the interesting part
1501 (set-buffer draft-buffer)) ; for annotation below
1503 (mh-exec-cmd-daemon mh-send-prog nil "-nodraftfolder" "-noverbose"
1504 mh-send-args file-name)))
1505 (if mh-annotate-char
1506 (mh-annotate-msg mh-sent-from-msg
1509 "-component" mh-annotate-field
1510 "-text" (format "\"%s %s\""
1511 (mh-get-header-field "To:")
1512 (mh-get-header-field "Cc:"))))
1514 (cond ((or (not arg)
1515 (y-or-n-p "Kill draft buffer? "))
1516 (kill-buffer draft-buffer)
1518 (set-window-configuration config))))
1520 (message "Sending...done")
1521 (message "Sending...backgrounded"))))
1524 (defun mh-insert-letter (folder message verbatim)
1527 This command prompts you for the FOLDER and MESSAGE number, which
1528 defaults to the current message in that folder. It then inserts
1529 the message, indented by `mh-ins-buf-prefix' (\"> \") unless
1530 `mh-yank-behavior' is set to one of the supercite flavors in
1531 which case supercite is used to format the message. Certain
1532 undesirable header fields (see
1533 `mh-invisible-header-fields-compiled') are removed before
1536 If given a prefix argument VERBATIM, the header is left intact, the
1537 message is not indented, and \"> \" is not inserted before each line.
1538 This command leaves the mark before the letter and point after it."
1541 (mh-prompt-for-folder "Message from"
1542 mh-sent-from-folder nil))
1544 (if (and (equal folder mh-sent-from-folder)
1545 (numberp mh-sent-from-msg))
1547 (nth 0 (mh-translate-range folder "cur"))))
1549 (read-string (concat "Message number"
1551 (format " (default %d): " default))
1553 (list folder message current-prefix-arg)))
1555 (narrow-to-region (point) (point))
1556 (let ((start (point-min)))
1557 (if (and (equal message "") (numberp mh-sent-from-msg))
1558 (setq message (int-to-string mh-sent-from-msg)))
1559 (insert-file-contents
1560 (expand-file-name message (mh-expand-file-name folder)))
1561 (when (not verbatim)
1562 (mh-clean-msg-header start mh-invisible-header-fields-compiled nil)
1563 (goto-char (point-max)) ;Needed for sc-cite-original
1564 (push-mark) ;Needed for sc-cite-original
1565 (goto-char (point-min)) ;Needed for sc-cite-original
1566 (mh-insert-prefix-string mh-ins-buf-prefix)))))
1568 (defun mh-extract-from-attribution ()
1569 "Extract phrase or comment from From header field."
1571 (if (not (mh-goto-header-field "From: "))
1573 (skip-chars-forward " ")
1575 ((looking-at "\"\\([^\"\n]+\\)\" \\(<.+>\\)")
1576 (format "%s %s " (match-string 1)(match-string 2)))
1577 ((looking-at "\\([^<\n]+<.+>\\)$")
1578 (format "%s " (match-string 1)))
1579 ((looking-at "\\([^ ]+@[^ ]+\\) +(\\(.+\\))$")
1580 (format "%s <%s> " (match-string 2)(match-string 1)))
1581 ((looking-at " *\\(.+\\)$")
1582 (format "%s " (match-string 1)))))))
1585 (defun mh-yank-cur-msg ()
1586 "Insert the current message into the draft buffer.
1588 It is often useful to insert a snippet of text from a letter that
1589 someone mailed to provide some context for your reply. This
1590 command does this by adding an attribution, yanking a portion of
1591 text from the message to which you're replying, and inserting
1592 `mh-ins-buf-prefix' (`> ') before each line.
1594 The attribution consists of the sender's name and email address
1595 followed by the content of the option
1596 `mh-extract-from-attribution-verb'.
1598 You can also turn on the option
1599 `mh-delete-yanked-msg-window-flag' to delete the window
1600 containing the original message after yanking it to make more
1601 room on your screen for your reply.
1603 You can control how the message to which you are replying is
1604 yanked into your reply using `mh-yank-behavior'.
1606 If this isn't enough, you can gain full control over the
1607 appearance of the included text by setting `mail-citation-hook'
1608 to a function that modifies it. For example, if you set this hook
1609 to `trivial-cite' (which is NOT part of Emacs), set
1610 `mh-yank-behavior' to \"Body and Header\" (see URL
1611 `http://shasta.cs.uiuc.edu/~lrclause/tc.html').
1613 Note that if `mail-citation-hook' is set, `mh-ins-buf-prefix' is
1614 not inserted. If the option `mh-yank-behavior' is set to one of
1615 the supercite flavors, the hook `mail-citation-hook' is ignored
1616 and `mh-ins-buf-prefix' is not inserted."
1618 (if (and mh-sent-from-folder
1619 (save-excursion (set-buffer mh-sent-from-folder) mh-show-buffer)
1620 (save-excursion (set-buffer mh-sent-from-folder)
1621 (get-buffer mh-show-buffer))
1623 (let ((to-point (point))
1624 (to-buffer (current-buffer)))
1625 (set-buffer mh-sent-from-folder)
1626 (if mh-delete-yanked-msg-window-flag
1627 (delete-windows-on mh-show-buffer))
1628 (set-buffer mh-show-buffer) ; Find displayed message
1629 (let* ((from-attr (mh-extract-from-attribution))
1630 (yank-region (mh-mark-active-p nil))
1632 (cond ((and yank-region
1633 (or (eq 'supercite mh-yank-behavior)
1634 (eq 'autosupercite mh-yank-behavior)
1635 (eq t mh-yank-behavior)))
1636 ;; supercite needs the full header
1638 (buffer-substring (point-min) (mh-mail-header-end))
1640 (buffer-substring (region-beginning) (region-end))))
1642 (buffer-substring (region-beginning) (region-end)))
1643 ((or (eq 'body mh-yank-behavior)
1644 (eq 'attribution mh-yank-behavior)
1645 (eq 'autoattrib mh-yank-behavior))
1648 (goto-char (point-min))
1649 (mh-goto-header-end 1)
1652 ((or (eq 'supercite mh-yank-behavior)
1653 (eq 'autosupercite mh-yank-behavior)
1654 (eq t mh-yank-behavior))
1655 (buffer-substring (point-min) (point-max)))
1657 (buffer-substring (point) (point-max))))))
1658 (set-buffer to-buffer)
1660 (narrow-to-region to-point to-point)
1661 (insert (mh-filter-out-non-text mh-ins-str))
1662 (goto-char (point-max)) ;Needed for sc-cite-original
1663 (push-mark) ;Needed for sc-cite-original
1664 (goto-char (point-min)) ;Needed for sc-cite-original
1665 (mh-insert-prefix-string mh-ins-buf-prefix)
1666 (when (or (eq 'attribution mh-yank-behavior)
1667 (eq 'autoattrib mh-yank-behavior))
1669 (mh-identity-insert-attribution-verb nil)
1671 ;; If the user has selected a region, he has already "edited" the
1672 ;; text, so leave the cursor at the end of the yanked text. In
1673 ;; either case, leave a mark at the opposite end of the included
1674 ;; text to make it easy to jump or delete to the other end of the
1677 (goto-char (point-max))
1678 (if (null yank-region)
1679 (mh-exchange-point-and-mark-preserving-active-mark)))))
1680 (error "There is no current message")))
1682 (defun mh-filter-out-non-text (string)
1683 "Return STRING but without adornments such as MIME buttons and smileys."
1685 ;; Insert the string to filter
1687 (goto-char (point-min))
1689 ;; Remove the MIME buttons
1690 (let ((can-move-forward t)
1692 (while can-move-forward
1693 (cond ((and (not (get-text-property (point) 'mh-data))
1695 (delete-region (1- (point)) (point))
1696 (setq in-button nil))
1697 ((get-text-property (point) 'mh-data)
1698 (delete-region (point)
1699 (save-excursion (forward-line) (point)))
1701 (t (setq can-move-forward (= (forward-line) 0))))))
1703 ;; Return the contents without properties... This gets rid of emphasis
1705 (buffer-substring-no-properties (point-min) (point-max))))
1707 (defun mh-insert-prefix-string (mh-ins-string)
1708 "Insert prefix string before each line in buffer.
1709 The inserted letter is cited using `sc-cite-original' if
1710 `mh-yank-behavior' is one of 'supercite or 'autosupercite.
1711 Otherwise, simply insert MH-INS-STRING before each line."
1712 (goto-char (point-min))
1713 (cond ((or (eq mh-yank-behavior 'supercite)
1714 (eq mh-yank-behavior 'autosupercite))
1717 (run-hooks 'mail-citation-hook))
1718 (mh-yank-hooks ;old hook name
1719 (run-hooks 'mh-yank-hooks))
1721 (or (bolp) (forward-line 1))
1722 (while (< (point) (point-max))
1723 (insert mh-ins-string)
1725 (goto-char (point-min))))) ;leave point like sc-cite-original
1728 (defun mh-fully-kill-draft ()
1729 "Quit editing and delete draft message.
1731 If for some reason you are not happy with the draft, you can use
1732 this command to kill the draft buffer and delete the draft
1733 message. Use the command \\[kill-buffer] if you don't want to
1734 delete the draft message."
1736 (if (y-or-n-p "Kill draft message? ")
1737 (let ((config mh-previous-window-config))
1738 (if (file-exists-p buffer-file-name)
1739 (delete-file buffer-file-name))
1740 (set-buffer-modified-p nil)
1741 (kill-buffer (buffer-name))
1744 (set-window-configuration config)))
1745 (error "Message not killed")))
1747 (defun mh-current-fill-prefix ()
1748 "Return the `fill-prefix' on the current line as a string."
1751 ;; This assumes that the major-mode sets up adaptive-fill-regexp
1752 ;; correctly such as mh-letter-mode or sendmail.el's mail-mode. But
1753 ;; perhaps I should use the variable and simply inserts its value here,
1754 ;; and set it locally in a let scope. --psg
1755 (if (re-search-forward adaptive-fill-regexp nil t)
1760 (defun mh-open-line ()
1761 "Insert a newline and leave point before it.
1763 This command is similar to the command \\[open-line] in that it
1764 inserts a newline after point. It differs in that it also inserts
1765 the right number of quoting characters and spaces so that the
1766 next line begins in the same column as it was. This is useful
1767 when breaking up paragraphs in replies."
1769 (let ((column (current-column))
1770 (prefix (mh-current-fill-prefix)))
1771 (if (> (length prefix) column)
1772 (message "Sorry, point seems to be within the line prefix")
1775 (while (> column (current-column))
1777 (forward-line -1))))
1779 (mh-do-in-xemacs (defvar mail-abbrevs))
1781 (defmacro mh-display-completion-list-compat (word choices)
1782 "Completes WORD from CHOICES using `display-completion-list'.
1783 Calls `display-completion-list' correctly in older environments.
1784 Versions of Emacs prior to version 22 lacked a COMMON-SUBSTRING
1785 argument which is used to highlight the next possible character you
1786 can enter in the current list of completions."
1787 (if (>= emacs-major-version 22)
1788 `(display-completion-list (all-completions ,word ,choices) ,word)
1789 `(display-completion-list (all-completions ,word ,choices))))
1792 (defun mh-complete-word (word choices begin end)
1793 "Complete WORD at from CHOICES.
1794 Any match found replaces the text from BEGIN to END."
1795 (let ((completion (try-completion word choices))
1796 (completions-buffer "*Completions*"))
1797 (cond ((eq completion t)
1799 (kill-buffer completions-buffer))
1800 (message "Completed: %s" word))
1803 (kill-buffer completions-buffer))
1804 (message "No completion for %s" word))
1805 ((stringp completion)
1806 (if (equal word completion)
1807 (with-output-to-temp-buffer completions-buffer
1808 (mh-display-completion-list-compat word choices))
1810 (kill-buffer completions-buffer))
1811 (delete-region begin end)
1812 (insert completion))))))
1815 (defun mh-beginning-of-word (&optional n)
1816 "Return position of the N th word backwards."
1817 (unless n (setq n 1))
1818 (let ((syntax-table (syntax-table)))
1821 (mh-mail-abbrev-make-syntax-table)
1822 (set-syntax-table mail-abbrev-syntax-table)
1825 (set-syntax-table syntax-table))))
1827 (defun mh-folder-expand-at-point ()
1828 "Do folder name completion in Fcc header field."
1829 (let* ((end (point))
1830 (beg (mh-beginning-of-word))
1831 (folder (buffer-substring beg end))
1832 (leading-plus (and (> (length folder) 0) (equal (aref folder 0) ?+)))
1833 (last-slash (mh-search-from-end ?/ folder))
1834 (prefix (and last-slash (substring folder 0 last-slash)))
1835 (choices (mapcar #'(lambda (x)
1836 (list (cond (prefix (format "%s/%s" prefix x))
1837 (leading-plus (format "+%s" x))
1839 (mh-folder-completion-function folder nil t))))
1840 (mh-complete-word folder choices beg end)))
1842 (defvar mh-letter-complete-function-alist
1843 '((bcc . mh-alias-letter-expand-alias)
1844 (cc . mh-alias-letter-expand-alias)
1845 (dcc . mh-alias-letter-expand-alias)
1846 (fcc . mh-folder-expand-at-point)
1847 (from . mh-alias-letter-expand-alias)
1848 (mail-followup-to . mh-alias-letter-expand-alias)
1849 (mail-reply-to . mh-alias-letter-expand-alias)
1850 (reply-to . mh-alias-letter-expand-alias)
1851 (to . mh-alias-letter-expand-alias))
1852 "Alist of header fields and completion functions to use.")
1854 (defun mh-letter-complete (arg)
1855 "Perform completion on header field or word preceding point.
1857 If the field contains addresses (for example, \"To:\" or \"Cc:\")
1858 or folders (for example, \"Fcc:\") then this command will provide
1859 alias completion. In the body of the message, this command runs
1860 `mh-letter-complete-function' instead, which is set to
1861 `ispell-complete-word' by default. This command takes a prefix
1862 argument ARG that is passed to the
1863 `mh-letter-complete-function'."
1866 (cond ((not (mh-in-header-p))
1867 (funcall mh-letter-complete-function arg))
1868 ((setq func (cdr (assoc (mh-letter-header-field-at-point)
1869 mh-letter-complete-function-alist)))
1871 (t (funcall mh-letter-complete-function arg)))))
1873 (defun mh-letter-complete-or-space (arg)
1874 "Perform completion or insert space.
1876 Turn on the option `mh-compose-space-does-completion-flag' to use
1877 this command to perform completion in the header. Otherwise, a
1878 space is inserted; use a prefix argument ARG to specify more than
1882 (end-of-prev (save-excursion
1883 (goto-char (mh-beginning-of-word))
1884 (mh-beginning-of-word -1))))
1885 (cond ((not mh-compose-space-does-completion-flag)
1886 (self-insert-command arg))
1887 ((not (mh-in-header-p)) (self-insert-command arg))
1888 ((> (point) end-of-prev) (self-insert-command arg))
1889 ((setq func (cdr (assoc (mh-letter-header-field-at-point)
1890 mh-letter-complete-function-alist)))
1892 (t (self-insert-command arg)))))
1894 (defun mh-letter-confirm-address ()
1895 "Flash alias expansion.
1897 Addresses are separated by a comma\; when you press the comma,
1898 this command flashes the alias expansion in the minibuffer if
1899 `mh-alias-flash-on-comma' is turned on."
1901 (cond ((not (mh-in-header-p)) (self-insert-command 1))
1902 ((eq (cdr (assoc (mh-letter-header-field-at-point)
1903 mh-letter-complete-function-alist))
1904 'mh-alias-letter-expand-alias)
1905 (mh-alias-reload-maybe)
1906 (mh-alias-minibuffer-confirm-address))
1907 (t (self-insert-command 1))))
1909 (defvar mh-letter-header-field-regexp "^\\([A-Za-z][A-Za-z0-9-]*\\):")
1911 (defun mh-letter-header-field-at-point ()
1912 "Return the header field name at point.
1913 A symbol is returned whose name is the string obtained by
1914 downcasing the field name."
1917 (and (re-search-backward mh-letter-header-field-regexp nil t)
1918 (intern (downcase (match-string 1))))))
1921 (defun mh-letter-next-header-field-or-indent (arg)
1922 "Cycle to next field.
1924 Within the header of the message, this command moves between
1925 fields that are highlighted with the face
1926 `mh-letter-header-field', skipping those fields listed in
1927 `mh-compose-skipped-header-fields'. After the last field, this
1928 command then moves point to the message body before cycling back
1929 to the first field. If point is already past the first line of
1930 the message body, then this command indents by calling
1931 `indent-relative' with the given prefix argument ARG."
1933 (let ((header-end (save-excursion
1934 (goto-char (mh-mail-header-end))
1937 (if (> (point) header-end)
1938 (indent-relative arg)
1939 (mh-letter-next-header-field))))
1941 (defun mh-letter-next-header-field ()
1942 "Cycle to the next header field.
1943 If we are at the last header field go to the start of the message
1945 (let ((header-end (mh-mail-header-end)))
1946 (cond ((>= (point) header-end) (goto-char (point-min)))
1949 (re-search-forward mh-letter-header-field-regexp
1950 (line-end-position) t)
1952 (beginning-of-line))
1954 (cond ((re-search-forward mh-letter-header-field-regexp header-end t)
1955 (if (mh-letter-skipped-header-field-p (match-string 1))
1956 (mh-letter-next-header-field)
1957 (mh-letter-skip-leading-whitespace-in-header-field)))
1958 (t (goto-char header-end)
1962 (defun mh-letter-previous-header-field ()
1963 "Cycle to the previous header field.
1965 This command moves backwards between the fields and cycles to the
1966 body of the message after the first field. Unlike the command
1967 \\[mh-letter-next-header-field-or-indent], it will always take
1968 point to the last field from anywhere in the body."
1970 (let ((header-end (mh-mail-header-end)))
1971 (if (>= (point) header-end)
1972 (goto-char header-end)
1973 (mh-header-field-beginning))
1974 (cond ((re-search-backward mh-letter-header-field-regexp nil t)
1975 (if (mh-letter-skipped-header-field-p (match-string 1))
1976 (mh-letter-previous-header-field)
1977 (goto-char (match-end 0))
1978 (mh-letter-skip-leading-whitespace-in-header-field)))
1979 (t (goto-char header-end)
1982 (defun mh-letter-skipped-header-field-p (field)
1983 "Check if FIELD is to be skipped."
1984 (let ((field (downcase field)))
1985 (loop for x in mh-compose-skipped-header-fields
1986 when (equal (downcase x) field) return t
1987 finally return nil)))
1989 (defun mh-letter-skip-leading-whitespace-in-header-field ()
1990 "Skip leading whitespace in a header field.
1991 If the header field doesn't have at least one space after the
1992 colon then a space character is added."
1993 (let ((need-space t))
1994 (while (memq (char-after) '(?\t ?\ ))
1996 (setq need-space nil))
1997 (when need-space (insert " "))))
1999 (defvar mh-hidden-header-keymap
2000 (let ((map (make-sparse-keymap)))
2002 (define-key map [mouse-2] 'mh-letter-toggle-header-field-display-button))
2004 (define-key map '(button2)
2005 'mh-letter-toggle-header-field-display-button))
2008 (defun mh-letter-toggle-header-field-display-button (event)
2009 "Toggle header field display at location of EVENT.
2010 This function does the same thing as
2011 `mh-letter-toggle-header-field-display' except that it is
2012 callable from a mouse button."
2014 (mh-do-at-event-location event
2015 (mh-letter-toggle-header-field-display nil)))
2017 (defun mh-letter-toggle-header-field-display (arg)
2018 "Toggle display of header field at point.
2020 Use this command to display truncated header fields. This command
2021 is a toggle so entering it again will hide the field. This
2022 command takes a prefix argument ARG: if negative then the field
2023 is hidden, if positive then the field is displayed."
2024 (interactive (list nil))
2025 (when (and (mh-in-header-p)
2028 (re-search-backward mh-letter-header-field-regexp nil t)))
2029 (let ((buffer-read-only nil)
2030 (modified-flag (buffer-modified-p))
2034 (setq end (1- (if (re-search-forward "^[^ \t]" nil t)
2038 ;; Make it clickable...
2039 (add-text-properties begin end `(keymap ,mh-hidden-header-keymap
2040 mouse-face highlight))
2042 (cond ((or (and (not arg)
2043 (text-property-any begin end 'invisible 'vanish))
2044 (and (numberp arg) (>= arg 0))
2045 (and (eq arg 'long) (> (line-beginning-position 5) end)))
2046 (remove-text-properties begin end '(invisible nil))
2047 (search-forward ":" (line-end-position) t)
2048 (mh-letter-skip-leading-whitespace-in-header-field))
2049 ;; XXX Redesign to make usable by user. Perhaps use a positive
2050 ;; numeric prefix to make that many lines visible.
2053 (mh-letter-truncate-header-field end)
2054 (beginning-of-line))
2056 (mh-letter-truncate-header-field end)
2057 (beginning-of-line)))
2058 (set-buffer-modified-p modified-flag)))))
2060 (defun mh-letter-truncate-header-field (end)
2061 "Replace text from current line till END with an ellipsis.
2062 If the current line is too long truncate a part of it as well."
2063 (let ((max-len (min (window-width) 62)))
2064 (when (> (+ (current-column) 4) max-len)
2065 (backward-char (- (+ (current-column) 5) max-len)))
2066 (when (> end (point))
2067 (add-text-properties (point) end '(invisible vanish)))))
2069 (defun mh-letter-hide-all-skipped-fields ()
2070 "Hide all skipped fields."
2072 (goto-char (point-min))
2074 (narrow-to-region (point) (mh-mail-header-end))
2075 (while (re-search-forward mh-letter-header-field-regexp nil t)
2076 (if (mh-letter-skipped-header-field-p (match-string 1))
2077 (mh-letter-toggle-header-field-display -1)
2078 (mh-letter-toggle-header-field-display 'long))
2079 (beginning-of-line 2)))))
2081 (defun mh-interactive-read-address (prompt)
2083 If `mh-compose-prompt-flag' is non-nil, then read an address with
2085 Otherwise return the empty string."
2086 (if mh-compose-prompt-flag (mh-read-address prompt) ""))
2088 (defun mh-interactive-read-string (prompt)
2090 If `mh-compose-prompt-flag' is non-nil, then read a string with
2092 Otherwise return the empty string."
2093 (if mh-compose-prompt-flag (read-string prompt) ""))
2095 (defun mh-letter-adjust-point ()
2096 "Move cursor to first header field if are using the no prompt mode."
2097 (unless mh-compose-prompt-flag
2098 (goto-char (point-max))
2099 (mh-letter-next-header-field)))
2103 ;;; Build mh-letter-mode keymap
2105 ;; If this changes, modify mh-letter-mode-help-messages accordingly, above.
2106 (gnus-define-keys mh-letter-mode-map
2107 " " mh-letter-complete-or-space
2108 "," mh-letter-confirm-address
2110 "\C-c\C-\\" mh-fully-kill-draft ;if no C-q
2111 "\C-c\C-^" mh-insert-signature ;if no C-s
2112 "\C-c\C-c" mh-send-letter
2113 "\C-c\C-d" mh-insert-identity
2114 "\C-c\C-e" mh-mh-to-mime
2115 "\C-c\C-f\C-a" mh-to-field
2116 "\C-c\C-f\C-b" mh-to-field
2117 "\C-c\C-f\C-c" mh-to-field
2118 "\C-c\C-f\C-d" mh-to-field
2119 "\C-c\C-f\C-f" mh-to-fcc
2120 "\C-c\C-f\C-l" mh-to-field
2121 "\C-c\C-f\C-m" mh-to-field
2122 "\C-c\C-f\C-r" mh-to-field
2123 "\C-c\C-f\C-s" mh-to-field
2124 "\C-c\C-f\C-t" mh-to-field
2125 "\C-c\C-fa" mh-to-field
2126 "\C-c\C-fb" mh-to-field
2127 "\C-c\C-fc" mh-to-field
2128 "\C-c\C-fd" mh-to-field
2129 "\C-c\C-ff" mh-to-fcc
2130 "\C-c\C-fl" mh-to-field
2131 "\C-c\C-fm" mh-to-field
2132 "\C-c\C-fr" mh-to-field
2133 "\C-c\C-fs" mh-to-field
2134 "\C-c\C-ft" mh-to-field
2135 "\C-c\C-i" mh-insert-letter
2136 "\C-c\C-m\C-e" mh-mml-secure-message-encrypt
2137 "\C-c\C-m\C-f" mh-compose-forward
2138 "\C-c\C-m\C-g" mh-mh-compose-anon-ftp
2139 "\C-c\C-m\C-i" mh-compose-insertion
2140 "\C-c\C-m\C-m" mh-mml-to-mime
2141 "\C-c\C-m\C-n" mh-mml-unsecure-message
2142 "\C-c\C-m\C-s" mh-mml-secure-message-sign
2143 "\C-c\C-m\C-t" mh-mh-compose-external-compressed-tar
2144 "\C-c\C-m\C-u" mh-mh-to-mime-undo
2145 "\C-c\C-m\C-x" mh-mh-compose-external-type
2146 "\C-c\C-mee" mh-mml-secure-message-encrypt
2147 "\C-c\C-mes" mh-mml-secure-message-signencrypt
2148 "\C-c\C-mf" mh-compose-forward
2149 "\C-c\C-mg" mh-mh-compose-anon-ftp
2150 "\C-c\C-mi" mh-compose-insertion
2151 "\C-c\C-mm" mh-mml-to-mime
2152 "\C-c\C-mn" mh-mml-unsecure-message
2153 "\C-c\C-mse" mh-mml-secure-message-signencrypt
2154 "\C-c\C-mss" mh-mml-secure-message-sign
2155 "\C-c\C-mt" mh-mh-compose-external-compressed-tar
2156 "\C-c\C-mu" mh-mh-to-mime-undo
2157 "\C-c\C-mx" mh-mh-compose-external-type
2158 "\C-c\C-o" mh-open-line
2159 "\C-c\C-q" mh-fully-kill-draft
2160 "\C-c\C-s" mh-insert-signature
2161 "\C-c\C-t" mh-letter-toggle-header-field-display
2162 "\C-c\C-w" mh-check-whom
2163 "\C-c\C-y" mh-yank-cur-msg
2164 "\C-c\M-d" mh-insert-auto-fields
2165 "\M-\t" mh-letter-complete
2166 "\t" mh-letter-next-header-field-or-indent
2167 [backtab] mh-letter-previous-header-field)
2169 ;; "C-c /" prefix is used in mh-letter-mode by pgp.el and mailcrypt.el.
2174 ;; indent-tabs-mode: nil
2175 ;; sentence-end-double-space: nil
2178 ;; arch-tag: 62865511-e610-4923-b0b5-f45a8ab70a34
2179 ;;; mh-comp.el ends here