Rev 3534: EmacsMail improvements (Christophe Troestler) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 9 06:48:34 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3534
revision-id:pqm at pqm.ubuntu.com-20080709054822-jrzq8pdw4w7ob493
parent: pqm at pqm.ubuntu.com-20080708172503-gl2dtaz3v7fyc2sl
parent: ian.clatworthy at canonical.com-20080709053115-0ldsgfrsob2krmdi
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-07-09 06:48:22 +0100
message:
  EmacsMail improvements (Christophe Troestler)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3533.1.1
    revision-id:ian.clatworthy at canonical.com-20080709053115-0ldsgfrsob2krmdi
    parent: pqm at pqm.ubuntu.com-20080708172503-gl2dtaz3v7fyc2sl
    parent: christophe.troestler at umh.ac.be-20080705141934-7vl7b4zfm3tvfili
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: ianc-integration
    timestamp: Wed 2008-07-09 15:31:15 +1000
    message:
      EmacsMail improvements (Christophe Troestler)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.10
    revision-id:christophe.troestler at umh.ac.be-20080705141934-7vl7b4zfm3tvfili
    parent: christophe.troestler at umh.ac.be-20080701095634-4wsbozl23ms6v0bb
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Sat 2008-07-05 16:19:34 +0200
    message:
      Removed TABS in mail_client.py and added a NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.9
    revision-id:christophe.troestler at umh.ac.be-20080701095634-4wsbozl23ms6v0bb
    parent: christophe.troestler at umh.ac.be-20080630162330-t3h0u027ipusbzho
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Tue 2008-07-01 11:56:34 +0200
    message:
      Mew emacsclient automatically adds a content description and moves the
      cursor at the beginning of the message.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.8
    revision-id:christophe.troestler at umh.ac.be-20080630162330-t3h0u027ipusbzho
    parent: christophe.troestler at umh.ac.be-20080630161722-4a9ieij5wzgplkah
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Mon 2008-06-30 18:23:30 +0200
    message:
      When the Emacs MUA is not supported, the error message encourage to report it.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.7
    revision-id:christophe.troestler at umh.ac.be-20080630161722-4a9ieij5wzgplkah
    parent: christophe.troestler at umh.ac.be-20080630102311-9immox2uy1yi33ep
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Mon 2008-06-30 18:17:22 +0200
    message:
      EmacsMail: sendmail-user-agent: handle gracefully the absence of the
      etach package; removed mail-text which is neither needed nor always
      defined for Gnus.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.6
    revision-id:christophe.troestler at umh.ac.be-20080630102311-9immox2uy1yi33ep
    parent: christophe.troestler at umh.ac.be-20080630093402-o8zcbw15oxn1vfsh
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Mon 2008-06-30 12:23:11 +0200
    message:
      EmacsMail: _prepare_send_function: corrected doc and proper handling of
      attachements for sendmail-user-agent.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.5
    revision-id:christophe.troestler at umh.ac.be-20080630093402-o8zcbw15oxn1vfsh
    parent: christophe.troestler at umh.ac.be-20080621155000-noms4eiymhpqqiqv
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Mon 2008-06-30 11:34:02 +0200
    message:
      Moved "emacsclient" to the `generic options' in `bzr help send'.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3506.1.4
    revision-id:christophe.troestler at umh.ac.be-20080621155000-noms4eiymhpqqiqv
    parent: christophe.troestler at umh.ac.be-20080621153603-u39no0etpcazmww2
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Sat 2008-06-21 17:50:00 +0200
    message:
      Remove the temporary elisp file created for attachments by EmacsMail.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.3
    revision-id:christophe.troestler at umh.ac.be-20080621153603-u39no0etpcazmww2
    parent: christophe.troestler at umh.ac.be-20080621125233-sgi8jvznomr5a75c
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Sat 2008-06-21 17:36:03 +0200
    message:
      Better escaping of To and Subject in the class EmacsMail.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
    ------------------------------------------------------------
    revno: 3506.1.2
    revision-id:christophe.troestler at umh.ac.be-20080621125233-sgi8jvznomr5a75c
    parent: christophe.troestler at umh.ac.be-20080621125020-5fevro5udhwkjvki
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Sat 2008-06-21 14:52:33 +0200
    message:
      Documented the "emacsclient" possibility for the mail_client configuration
      (given in "bzr help send").
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3506.1.1
    revision-id:christophe.troestler at umh.ac.be-20080621125020-5fevro5udhwkjvki
    parent: pqm at pqm.ubuntu.com-20080620010918-64z4xylh1ap5hgyf
    committer: Christophe Troestler <Christophe.Troestler at umh.ac.be>
    branch nick: emacs
    timestamp: Sat 2008-06-21 14:50:20 +0200
    message:
      Handled the MUA "mew" in the class EmacsMail.
    modified:
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
=== modified file 'NEWS'
--- a/NEWS	2008-07-04 07:21:29 +0000
+++ b/NEWS	2008-07-09 05:31:15 +0000
@@ -27,6 +27,10 @@
       to stdout; also ``tar`` and ``tbz2``.
       (Martin Pool)
 
+    * ``bzr send`` documents and better supports ``emacsclient`` (proper
+      escaping of mail headers and handling of the MUA Mew).
+      (Christophe Troestler)
+
     * Remembered locations can be specified by aliases, e.g. :parent, :public,
       :submit.  (Aaron Bentley)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-07-07 21:54:04 +0000
+++ b/bzrlib/builtins.py	2008-07-09 05:31:15 +0000
@@ -4101,7 +4101,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'
--- a/bzrlib/mail_client.py	2008-04-13 11:48:00 +0000
+++ b/bzrlib/mail_client.py	2008-07-05 14:19:34 +0000
@@ -328,31 +328,40 @@
         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))
+            (let* ((nums (mew-syntax-nums))
+                   (syntax (mew-syntax-get-entry mew-encode-syntax nums)))
+              (mew-syntax-set-cd syntax "BZR merge")
+              (mew-encode-syntax-print mew-encode-syntax))
+            (mew-header-goto-body)))
          (t
-          (message "Unhandled MUA")))
+          (message "Unhandled MUA, report it on bazaar at lists.canonical.com")))
       (error "File %s does not exist." file))))
 """
 
@@ -371,9 +380,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 +395,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
 




More information about the bazaar-commits mailing list