Could I have some commentary on this? I think the mechanism for changing
defaults based on packages’ presence is reasonable, but there is a penalty
at startup, which makes me consider caching path and file presence
information in a file in ~/.xemacs/ and comparing timestamps on startup
before re-initialising it on every startup.
lisp/ChangeLog addition:
2005-03-20 Aidan Kehoe <kehoea(a)parhasard.net>
* menubar-items.el (default-menubar): Add an entry for VM, rename
the entry for sendmail-user-agent to better describe it.
* packages.el (package-presence-default-tweaks): New. List of
libraries and functions to be called with information on their
presence at startup.
* simple.el (mail-user-agent): Update the docstring and Customize
init information to mention VM.
* simple.el (packages): Require it.
* simple.el (initialize-mua-to-vm-if-available): New. Function
that initializes mail-user-agent to 'vm-user-agent if the VM
package is available.
* simple.el ('vm-user-agent): New. Previously available in the VM
package.
* startup.el (normal-top-level): Loop through
package-presence-default-tweaks, looking for the library specified
in the car of each element, and calling the function specified as
the second slot of that element with the result of that lookup.
man/ChangeLog addition:
2005-03-20 Aidan Kehoe <kehoea(a)parhasard.net>
* xemacs/sending.texi (Sending Mail): Describe that we've changed
the default to VM, cross reference to its docs.
2005-03-20 Aidan Kehoe <kehoea(a)parhasard.net>
* lispref/packaging.texi (Dumped defaults): Describe and cross
reference the package-presence-default-tweaks.
XEmacs Trunk source patch:
Diff command: cvs -q diff -u
Files affected: man/xemacs/sending.texi man/lispref/packaging.texi lisp/startup.el
lisp/simple.el lisp/packages.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/03/20 11:35: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/packages.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/packages.el,v
retrieving revision 1.53
diff -u -u -r1.53 packages.el
--- lisp/packages.el 2005/02/03 23:56:53 1.53
+++ lisp/packages.el 2005/03/20 11:35:57
@@ -518,6 +518,19 @@
package-load-path)
(reverse *files*)))
+(defvar package-presence-default-tweaks nil
+ "Library names and functions to call with their presence, on startup.
+A list of lists, of the form:
+
+ '((\"library-name\" 'function))
+
+Before the user's initialization files are loaded, but after the packages
+load path has been worked out, XEmacs calls `(locate-library
+\"library-name\")', and passes its result to `function', for each
element of
+`package-presence-default-tweaks'. The intention is that `function'
+initializes some, dumped, XEmacs default based on the runtime presence of
+some package. ")
+
(provide 'packages)
;;; packages.el ends here
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/03/20 11:36:01
@@ -3312,10 +3312,14 @@
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 preferred, 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,19 @@
(function :tag "Other"))
:group 'mail)
+(require 'packages)
+
+;; VM's composition package is compatible with sendmail-user-agent, and it
+;; supports MIME, so we should prefer it as a default if it's available.
+(defun initialize-mua-to-vm-if-available (path)
+ "If `path' is non-nil, make VM be XEmacs' default `mail-user-agent'.
+This should be called from `startup.el' by means of the
+`package-presence-default-tweaks' mechanism. "
+ (when path (setq mail-user-agent 'vm-user-agent)))
+
+(pushnew '("vm" initialize-mua-to-vm-if-available)
+ package-presence-default-tweaks)
+
(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 +3405,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: lisp/startup.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/startup.el,v
retrieving revision 1.53
diff -u -u -r1.53 startup.el
--- lisp/startup.el 2005/01/26 04:56:18 1.53
+++ lisp/startup.el 2005/03/20 11:36:02
@@ -562,6 +562,13 @@
auto-save-list-file-prefix
(emacs-pid)
(system-name)))))
+ ;; Some of XEmacs' default settings--initially the mail composition
+ ;; agent--depend on the presence of a given package at startup.
+ (require 'packages)
+ (dolist (lib-presence package-presence-default-tweaks)
+ (apply (second lib-presence)
+ (locate-library (car lib-presence))
+ nil))
(run-hooks 'emacs-startup-hook)
(and term-setup-hook
(run-hooks 'term-setup-hook))
Index: man/lispref/packaging.texi
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/man/lispref/packaging.texi,v
retrieving revision 1.11
diff -u -u -r1.11 packaging.texi
--- man/lispref/packaging.texi 2003/10/10 12:39:34 1.11
+++ man/lispref/packaging.texi 2005/03/20 11:36:03
@@ -61,6 +61,7 @@
@c * Frequently Asked Questions:: Questions and answers from the mailing list.
Internals and Package Release Engineering:
+* Dumped defaults:: Dumped code can check for packages.
* Issues::
@end menu
@@ -1322,7 +1323,7 @@
directory, then an entry in @code{package-name-to-directory} is also
necessary, or requires will fail, leading to the problems just described.
-@node Documenting Packages, Issues, Creating Packages, Packaging
+@node Documenting Packages, Dumped defaults, Creating Packages, Packaging
@comment node-name, next, previous, up
@cindex documenting packages
@heading Documenting Packages:
@@ -1357,7 +1358,26 @@
Do maintain a detailed ChangeLog.
-@node Issues, , Documenting Packages, Packaging
+@node Dumped defaults, Issues, Documenting Packages, Packaging
+@section Dumped defaults
+
+Since the best options for many defaults within XEmacs involve packages
+that are not necessarily present at runtime, we provide a mechanism for
+dumped code to check for packages' presence at startup and to initialize
+these defaults as appropriate.
+
+This is accomplished using @code{package-presence-default-tweaks},
+defined in @file{lisp/packages.el}. This is a list of lists, with the
+first element of each entry the name of a Lisp library to be checked
+for, and the second element a function symbol to be called with the
+result of @code{locate-library} on the Lisp library. These checks are
+done after the packages load path is initialized.
+
+See the documentation for @code{package-presence-default-tweaks}, and
+the check for the presence of VM and consequent default mailer change in
+(a)file{lisp/simple.el}.
+
+@node Issues, , Dumped defaults, Packaging
@section Issues
To be completed.
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/03/20 11:36:04
@@ -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.
cvs server: cannot find modules/ldap/configure
--
“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