[MERGE] EmacsMail improvements

Christophe TROESTLER Christophe.Troestler+bzr at umh.ac.be
Mon Jun 30 17:39:39 BST 2008


Hi,

On Mon, 30 Jun 2008 08:23:47 +0100, Bojan Nikolic wrote:
> 
> I think people agree that emacsclient should be listed as one of the
> generic options in the help of "bzr send" command.

Done.

> I don't have mew so haven't tested this but Gnus continues to work
> fine. 
> 
> One small item is that the message part with the patch and bundle
> seems to be marked "inline" rather than "attachment". I think
> "attachment" is preferred by people on this list.

This is strange because 1. I did not modify the code written for RMail
and Gnus and 2. I tested with Gnus and the disposition is indeed
attachment.  However, since the discussion indicates that "inline" is
preferred, I have changed it.  I also removed the mail-text because it
may not be defined (if gnus has not be launched before bzr send is
issued) and does not seem to be needed (I tested it).

In the attached bundle the code for RMail also changed because
etach-attach does not come with Emacs 22 (it is a separate package),
so in case it does not exists, mail-attach-file is used instead (which
includes the bundle inside the message but it is better than failing).

> >> 4) The temporary elisp file was not removed (as noted in a FIXME in
> >> the function _prepare_send_function).
> 
> Also seems fine, but could you update the comment of
> _prepare_send_function to replace the FIXME paragraph with a note that
> the temporary file is deleted from elisp?

Done.

New patch attached.

Regards,
Christophe
-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: christophe.troestler at umh.ac.be-20080630162330-\
#   t3h0u027ipusbzho
# target_branch: ../bzr.dev/
# testament_sha1: f128bd7ea37ad2054483244d1836c92d0b5a5e50
# timestamp: 2008-06-30 18:25:44 +0200
# base_revision_id: pqm at pqm.ubuntu.com-20080620010918-64z4xylh1ap5hgyf
# 
# Begin patch
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	2008-06-17 03:55:49 +0000
+++ bzrlib/builtins.py	2008-06-30 09:34:02 +0000
@@ -4168,7 +4168,8 @@
     To use a specific mail program, set the mail_client configuration option.
     (For Thunderbird 1.5, this works around some bugs.)  Supported values for
     specific clients are "evolution", "kmail", "mutt", and "thunderbird";
-    generic options are "default", "editor", "mapi", and "xdg-email".
+    generic options are "default", "editor", "emacsclient", "mapi", and
+    "xdg-email".
 
     If mail is being sent, a to address is required.  This can be supplied
     either on the commandline, by setting the submit_to configuration

=== modified file 'bzrlib/mail_client.py'
--- bzrlib/mail_client.py	2008-04-13 11:48:00 +0000
+++ bzrlib/mail_client.py	2008-06-30 16:23:30 +0000
@@ -328,31 +328,35 @@
         This temporary file will be loaded at runtime in
         _get_compose_commandline function.
 
-        FIXME: this function does not remove the file. That's a wanted
+        This function does not remove the file.  That's a wanted
         behaviour since _get_compose_commandline won't run the send
         mail function directly but return the eligible command line.
         Removing our temporary file here would prevent our sendmail
-        function to work.
-
-        A possible workaround could be to load the function here with
-        emacsclient --eval '(load temp)' but this is not robust since
-        emacs could have been stopped between here and the call to
-        mail client.
+        function to work.  (The file is deleted by some elisp code
+        after being read by Emacs.)
         """
 
         _defun = r"""(defun bzr-add-mime-att (file)
-  "Attach FILe to a mail buffer as a MIME attachment."
+  "Attach FILE to a mail buffer as a MIME attachment."
   (let ((agent mail-user-agent))
-    (mail-text)
-    (newline)
     (if (and file (file-exists-p file))
         (cond
          ((eq agent 'sendmail-user-agent)
-          (etach-attach file))
+          (progn
+	    (mail-text)
+	    (newline)
+	    (if (functionp 'etach-attach)
+	      (etach-attach file)
+	      (mail-attach-file file))))
          ((or (eq agent 'message-user-agent)(eq agent 'gnus-user-agent))
-          (mml-attach-file file "text/x-patch" "BZR merge" "attachment"))
+          (progn
+	    (mml-attach-file file "text/x-patch" "BZR merge" "inline")))
+	 ((eq agent 'mew-user-agent)
+	  (progn
+	    (mew-draft-prepare-attachments)
+	    (mew-attach-link file (file-name-nondirectory file))))
          (t
-          (message "Unhandled MUA")))
+          (message "Unhandled MUA, report it on bazaar at lists.canonical.com")))
       (error "File %s does not exist." file))))
 """
 
@@ -371,9 +375,10 @@
         _subject = "nil"
 
         if to is not None:
-            _to = ("\"%s\"" % self._encode_safe(to))
+            _to = ("\"%s\"" % self._encode_safe(to).replace('"', '\\"'))
         if subject is not None:
-            _subject = ("\"%s\"" % self._encode_safe(subject))
+            _subject = ("\"%s\"" %
+                        self._encode_safe(subject).replace('"', '\\"'))
 
         # Funcall the default mail composition function
         # This will work with any mail mode including default mail-mode
@@ -385,11 +390,14 @@
         # Try to attach a MIME attachment using our wrapper function
         if attach_path is not None:
             # Do not create a file if there is no attachment
-            lmmform = '(load "%s")' % self._prepare_send_function()
+            elisp = self._prepare_send_function()
+            lmmform = '(load "%s")' % elisp
             mmform  = '(bzr-add-mime-att "%s")' % \
                 self._encode_path(attach_path, 'attachment')
+            rmform = '(delete-file "%s")' % elisp
             commandline.append(lmmform)
             commandline.append(mmform)
+            commandline.append(rmform)
 
         return commandline
 

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWVVgcL4ADK9/gFVwBABT5///
f+YelP////BgEQ4Cvo0MiCgooAAAFRABEiSBIBQUAFAA01CR4qaZPUNqY9RGnoQPUDCaGEZBppiN
BxkyaGIxNGARgJhAGAmmjTI0AxxkyaGIxNGARgJhAGAmmjTI0AwkSEAKbQmTTSemppPMk1J6J6Ef
qRiY0mh+po0hxkyaGIxNGARgJhAGAmmjTI0AwVKTQAmmppkCBpqegCBGkybU09IaA002pRDgiI1E
RUlP4CyVEJYgsVIQYwNIMJ8oRMb6dJSFr9Rz9VR+t9/5n4SeJP4k/g3gOHYRmBgcrLaflEVcpSHo
ji+rSBpAUgBgLcA0lfIt3XX7eVTGzF2/negVGAj00SwwFGESlIxuJCsAwnLfSc59llqUppeoSSLT
uSGmMS0w9mVOBD6YOQ6QQTgPcyROfIfoB7io7f2kY4Xbs5XAHcBqAYk2NtibbG0xho9gC4bzGoC0
DbvgUhdQrAiVJEbpwwte9lzrdGrGb4ijK2Vu2qK2DKjOIWGBzQk9YiK9QoSycO3kJtw0RM4xVrMA
F2qqdQKtj+0KdlQT83Y/jjR3FZnWBpxpXXTmT1MvZ8bo1jKOGLKt/tFgr879c5rl7ts4Ya++13YX
f6M9hkLMqmfsV26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