comparison lisp/prim/simple.el @ 195:a2f645c6b9f8 r20-3b24

Import from CVS: tag r20-3b24
author cvs
date Mon, 13 Aug 2007 09:59:05 +0200
parents f53b5ca2e663
children 169c0442b401
comparison
equal deleted inserted replaced
194:2947057885e5 195:a2f645c6b9f8
2936 (if (equal key (downcase (car (car alist)))) 2936 (if (equal key (downcase (car (car alist))))
2937 (setq element (car alist))) 2937 (setq element (car alist)))
2938 (setq alist (cdr alist))) 2938 (setq alist (cdr alist)))
2939 element)) 2939 element))
2940 2940
2941
2942 (defcustom mail-user-agent 'sendmail-user-agent
2943 "*Your preference for a mail composition package.
2944 Various Emacs Lisp packages (e.g. reporter) require you to compose an
2945 outgoing email message. This variable lets you specify which
2946 mail-sending package you prefer.
2947
2948 Valid values include:
2949
2950 sendmail-user-agent -- use the default Emacs Mail package
2951 mh-e-user-agent -- use the Emacs interface to the MH mail system
2952 message-user-agent -- use the GNUS mail sending package
2953
2954 Additional valid symbols may be available; check with the author of
2955 your package for details."
2956 :type '(radio (function-item :tag "Default Emacs mail"
2957 :format "%t\n"
2958 sendmail-user-agent)
2959 (function-item :tag "Gnus mail sending package"
2960 :format "%t\n"
2961 message-user-agent)
2962 (function :tag "Other"))
2963 :group 'mail)
2964
2965 (defun define-mail-user-agent (symbol composefunc sendfunc
2966 &optional abortfunc hookvar)
2967 "Define a symbol to identify a mail-sending package for `mail-user-agent'.
2968
2969 SYMBOL can be any Lisp symbol. Its function definition and/or
2970 value as a variable do not matter for this usage; we use only certain
2971 properties on its property list, to encode the rest of the arguments.
2972
2973 COMPOSEFUNC is program callable function that composes an outgoing
2974 mail message buffer. This function should set up the basics of the
2975 buffer without requiring user interaction. It should populate the
2976 standard mail headers, leaving the `to:' and `subject:' headers blank
2977 by default.
2978
2979 COMPOSEFUNC should accept several optional arguments--the same
2980 arguments that `compose-mail' takes. See that function's documentation.
2981
2982 SENDFUNC is the command a user would run to send the message.
2983
2984 Optional ABORTFUNC is the command a user would run to abort the
2985 message. For mail packages that don't have a separate abort function,
2986 this can be `kill-buffer' (the equivalent of omitting this argument).
2987
2988 Optional HOOKVAR is a hook variable that gets run before the message
2989 is actually sent. Callers that use the `mail-user-agent' may
2990 install a hook function temporarily on this hook variable.
2991 If HOOKVAR is nil, `mail-send-hook' is used.
2992
2993 The properties used on SYMBOL are `composefunc', `sendfunc',
2994 `abortfunc', and `hookvar'."
2995 (put symbol 'composefunc composefunc)
2996 (put symbol 'sendfunc sendfunc)
2997 (put symbol 'abortfunc (or abortfunc 'kill-buffer))
2998 (put symbol 'hookvar (or hookvar 'mail-send-hook)))
2999
3000 (define-mail-user-agent 'sendmail-user-agent
3001 'sendmail-user-agent-compose 'mail-send-and-exit)
3002
3003 (define-mail-user-agent 'message-user-agent
3004 'message-mail 'message-send-and-exit
3005 'message-kill-buffer 'message-send-hook)
3006
3007 (defun sendmail-user-agent-compose (&optional to subject other-headers continue
3008 switch-function yank-action
3009 send-actions)
3010 (if switch-function
3011 (let ((special-display-buffer-names nil)
3012 (special-display-regexps nil)
3013 (same-window-buffer-names nil)
3014 (same-window-regexps nil))
3015 (funcall switch-function "*mail*")))
3016 (let ((cc (cdr (assoc-ignore-case "cc" other-headers)))
3017 (in-reply-to (cdr (assoc-ignore-case "in-reply-to" other-headers))))
3018 (or (mail continue to subject in-reply-to cc yank-action send-actions)
3019 continue
3020 (error "Message aborted"))
3021 (save-excursion
3022 (goto-char (point-min))
3023 (search-forward mail-header-separator)
3024 (beginning-of-line)
3025 (while other-headers
3026 (if (not (member (car (car other-headers)) '("in-reply-to" "cc")))
3027 (insert (car (car other-headers)) ": "
3028 (cdr (car other-headers)) "\n"))
3029 (setq other-headers (cdr other-headers)))
3030 t)))
3031
3032 (define-mail-user-agent 'mh-e-user-agent
3033 'mh-smail-batch 'mh-send-letter 'mh-fully-kill-draft
3034 'mh-before-send-letter-hook)
3035
3036 (defun compose-mail (&optional to subject other-headers continue
3037 switch-function yank-action send-actions)
3038 "Start composing a mail message to send.
3039 This uses the user's chosen mail composition package
3040 as selected with the variable `mail-user-agent'.
3041 The optional arguments TO and SUBJECT specify recipients
3042 and the initial Subject field, respectively.
3043
3044 OTHER-HEADERS is an alist specifying additional
3045 header fields. Elements look like (HEADER . VALUE) where both
3046 HEADER and VALUE are strings.
3047
3048 CONTINUE, if non-nil, says to continue editing a message already
3049 being composed.
3050
3051 SWITCH-FUNCTION, if non-nil, is a function to use to
3052 switch to and display the buffer used for mail composition.
3053
3054 YANK-ACTION, if non-nil, is an action to perform, if and when necessary,
3055 to insert the raw text of the message being replied to.
3056 It has the form (FUNCTION . ARGS). The user agent will apply
3057 FUNCTION to ARGS, to insert the raw text of the original message.
3058 \(The user agent will also run `mail-citation-hook', *after* the
3059 original text has been inserted in this way.)
3060
3061 SEND-ACTIONS is a list of actions to call when the message is sent.
3062 Each action has the form (FUNCTION . ARGS)."
3063 (interactive
3064 (list nil nil nil current-prefix-arg))
3065 (let ((function (get mail-user-agent 'composefunc)))
3066 (funcall function to subject other-headers continue
3067 switch-function yank-action send-actions)))
3068
3069 (defun compose-mail-other-window (&optional to subject other-headers continue
3070 yank-action send-actions)
3071 "Like \\[compose-mail], but edit the outgoing message in another window."
3072 (interactive
3073 (list nil nil nil current-prefix-arg))
3074 (compose-mail to subject other-headers continue
3075 'switch-to-buffer-other-window yank-action send-actions))
3076
3077
3078 (defun compose-mail-other-frame (&optional to subject other-headers continue
3079 yank-action send-actions)
3080 "Like \\[compose-mail], but edit the outgoing message in another frame."
3081 (interactive
3082 (list nil nil nil current-prefix-arg))
3083 (compose-mail to subject other-headers continue
3084 'switch-to-buffer-other-frame yank-action send-actions))
3085
3086
2941 (defun set-variable (var val) 3087 (defun set-variable (var val)
2942 "Set VARIABLE to VALUE. VALUE is a Lisp object. 3088 "Set VARIABLE to VALUE. VALUE is a Lisp object.
2943 When using this interactively, supply a Lisp expression for VALUE. 3089 When using this interactively, supply a Lisp expression for VALUE.
2944 If you want VALUE to be a string, you must surround it with doublequotes. 3090 If you want VALUE to be a string, you must surround it with doublequotes.
2945 3091