Ar an seachtú lá is fiche de mí Feabhra, scríobh Hrvoje Nikšić:
Those other places don't expect their respective targets to be
available *by default* -- the user has to specifically request them.
(Although it would be nice for non-existent packages to not be offered
in Customize value menus.)
’zactly. If it’s in the menu, there’s an assumption that it’s there by
default.
> On further examination, is that even possible? The defcustom
> :initialize argument seems to be related, but when I try to use it I
> get a core dump on startup.
AFAIK you can simply use a Lisp expression like this:
(defcustom mail-user-agent (if (locate-library "vm")
'vm-user-agent
'mail-user-agent)
...)
Tried that; it only got evaluated once, at dump time. Here’s something that
works, but it’s horrible:
lisp/ChangeLog addition:
2005-02-27 Aidan Kehoe <kehoea(a)parhasard.net>
* menubar-items.el (default-menubar):
Add an entry for VM in the list of mail composition agents.
* simple.el:
* simple.el (mail-user-agent):
Change the default mail user agent to VM; update the docstring to
give details of VM and cross-reference to the Info docs. Add a
startup hook to revert to sendmail-user-agent if VM isn't available.
* simple.el ('vm-user-agent): New.
Define the vm-user-agent as a mail user agent.
man/ChangeLog addition:
2005-02-27 Aidan Kehoe <kehoea(a)parhasard.net>
* xemacs/sending.texi (Sending Mail): Note that the default user
agent is now VM, that it's compatible with sendmail.el, and
cross-reference to its documentation.
XEmacs Trunk source patch:
Diff command: cvs -q diff -u
Files affected: man/xemacs/sending.texi lisp/simple.el lisp/menubar-items.el
Index: lisp/menubar-items.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/menubar-items.el,v
retrieving revision 1.46
diff -u -u -r1.46 menubar-items.el
--- lisp/menubar-items.el 2005/02/03 05:03:38 1.46
+++ lisp/menubar-items.el 2005/02/27 22:36:57
@@ -886,7 +886,11 @@
:active (boundp 'ps-print-color-p)])
("%_Internet"
("%_Compose Mail With"
- ["Default Emacs Mailer"
+ ["VM mail package"
+ (customize-set-variable 'mail-user-agent 'vm-user-agent)
+ :style radio
+ :selected (eq mail-user-agent 'vm-user-agent)]
+ ["Bare-bones Emacs Mailer"
(customize-set-variable 'mail-user-agent 'sendmail-user-agent)
:style radio
:selected (eq mail-user-agent 'sendmail-user-agent)]
Index: lisp/simple.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/simple.el,v
retrieving revision 1.50
diff -u -u -r1.50 simple.el
--- lisp/simple.el 2005/02/23 22:25:16 1.50
+++ lisp/simple.el 2005/02/27 22:37:01
@@ -3306,16 +3306,20 @@
;; BEGIN SYNCHED WITH FSF 21.2.
-(defcustom mail-user-agent 'sendmail-user-agent
+(defcustom mail-user-agent 'vm-user-agent
"*Your preference for a mail composition package.
Various Emacs Lisp packages (e.g. Reporter) require you to compose an
outgoing email message. This variable lets you specify which
mail-sending package you prefer.
-Valid values include:
-
- `sendmail-user-agent' -- use the default Emacs Mail package.
- See Info node `(emacs)Sending Mail'.
+Valid values may include:
+
+ `vm-user-agent' -- use Kyle Jones' VM, as documented in the `(vm)'
+ Info node. Compatible with `sendmail-user-agent',
+ and can handle attachments and non-ASCII content,
+ which the former can't.
+ `sendmail-user-agent' -- use the former default, bare-bones, Emacs Mail
+ package. See Info node `(xemacs)Sending Mail'.
`mh-e-user-agent' -- use the Emacs interface to the MH mail system.
See Info node `(mh-e)'.
`message-user-agent' -- use the Gnus Message package.
@@ -3329,7 +3333,10 @@
succeeds.
See also `read-mail-command' concerning reading mail."
-:type '(radio (function-item :tag "Default Emacs mail"
+:type '(radio (function-item :tag "VM mail package"
+ :format "%t\n"
+ vm-user-agent)
+ (function-item :tag "Bare-bones Emacs mail"
:format "%t\n"
sendmail-user-agent)
(function-item :tag "Emacs interface to MH"
@@ -3344,6 +3351,10 @@
(function :tag "Other"))
:group 'mail)
+(add-hook 'emacs-startup-hook
+ '(lambda () (unless (locate-library "vm")
+ (setq mail-user-agent 'sendmail-user-agent))))
+
(defun define-mail-user-agent (symbol composefunc sendfunc
&optional abortfunc hookvar)
"Define a symbol to identify a mail-sending package for `mail-user-agent'.
@@ -3385,6 +3396,12 @@
(define-mail-user-agent 'message-user-agent
'message-mail 'message-send-and-exit
'message-kill-buffer 'message-send-hook)
+
+(define-mail-user-agent 'vm-user-agent
+ (function vm-compose-mail) ; compose function
+ (function vm-mail-send-and-exit) ; send function
+ nil ; abort function (kill-buffer)
+ nil) ; hook variable (mail-send-hook)
(defun rfc822-goto-eoh ()
;; Go to header delimiter line in a mail message, following RFC822 rules
Index: man/xemacs/sending.texi
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/man/xemacs/sending.texi,v
retrieving revision 1.4
diff -u -u -r1.4 sending.texi
--- man/xemacs/sending.texi 2001/04/12 18:22:30 1.4
+++ man/xemacs/sending.texi 2005/02/27 22:37:01
@@ -40,6 +40,16 @@
@kbd{C-u C-x m} is another way to switch back to a message in progress:
it will search for an existing, unsent mail message buffer and select it.
+Starting with version 21.5, the default mail composition package in
+XEmacs is VM, which is compatible with `sendmail.el' (the old default,
+as described in this document) and has thorough support for attachments
+and non-ASCII messages. @xref{(vm)}, for the full VM documentation,
+should you want information on these features. XEmacs' package system
+can mean that VM isn't installed---in that case, `sendmail.el' will
+be the fallback. If your mail buffer is called ``*mail*'', then
+you probably don't have VM installed; @pxref{Packages} for information
+on how to install the package.
+
@menu
* Format: Mail Format. Format of the mail being composed.
* Headers: Mail Headers. Details of allowed mail header fields.
--
“I, for instance, am gung-ho about open source because my family is being
held hostage in Rob Malda’s basement. But who fact-checks me, or Enderle,
when we say something in public? No-one!” -- Danny O’Brien