[MERGE] Add mail-mode GNU Emacs mail package as a mail_client option.

Aaron Bentley aaron at aaronbentley.com
Wed Mar 26 05:55:22 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Xavier Maillard wrote:
> This is my second attempt at adding GNU Emacs mail-mode as a
> potentiel mail_client.

I'm rather leery of adding two different ways of sending mail through
Emacs.  Is there no way to support them both?

> This new patch takes care of all the remarks done against my
> previous patch:
> 
> 1. patch are attached now
> 2. config.py has been cleaned up (no deletion of trailing whitespaces)

Thank you.

> === modified file 'bzrlib/mail_client.py'
> --- bzrlib/mail_client.py	2008-03-16 14:41:10 +0000
> +++ bzrlib/mail_client.py	2008-03-25 21:49:50 +0000
> @@ -305,6 +305,37 @@
>                  self._encode_path(attach_path, 'attachment')])
>          return commandline
>  
> +class EmacsMailMode (ExternalMailClient):

^^^ There should be two blank lines between classes.

> +    """Call emacsclient in mail-mode. This only work for emacs >= 22.1"""
> +    _client_commands = ['emacsclient']
> +
> +    def _get_compose_commandline (self, to, subject, attach_path):
> +        commandline = ["--eval"]
> +        """Ensure we can at least have an empty mail-mode buffer"""

^^^ This should be a comment, not a docstring.  i.e.

           # Ensure we can at least have an empty mail-mode buffer


> +        _to = "nil"
> +        _subject = "nil"
> +
> +        if to is not None:
> +            _to = ("\"%s\"" % self._encode_safe(to))
> +        if subject is not None:
> +            _subject = ("\"%s\"" % self._encode_safe(subject))
> +        mmform = "(mail nil %s %s)" %(_to ,_subject)
> +
> +        """
> +        call mail-mode, move the point to body and insert a new blank line
> +        we *must* force this point movement for the case when To is not passed
> +        with --mail-to. Without this, the patch could be inserted at the wrong place
> +        """

^^^^ Comment, not docstring.

> +class TestEmacsMailMode(tests.TestCase):
> +
> +    def test_commandline(self):
> +        eclient = mail_client.EmacsMailMode(None)
> +        commandline = eclient._get_compose_commandline(None, None, 'file%')
> +        self.assertEqual(['--eval', '(mail nil nil nil)', \
> +                              '(mail-text)' , '(newline)', \
> +                              '(attach "file%")'], commandline)

^^^ You do not backslashes when newlines happen within parentheses or
square brackets.  It's considered ugly.  The indenting should either be
4 spaces, or it should line up with the bracket:


> +        self.assertEqual(['--eval', '(mail nil nil nil)',
> +                          '(mail-text)' , '(newline)'
> +                          '(attach "file%")'], commandline)

or

> +        self.assertEqual(['--eval', '(mail nil nil nil)',
> +            '(mail-text)' , '(newline)' '(attach "file%")'],
> +             commandline)

> +        commandline = eclient._get_compose_commandline('jrandom at example.org',
> +                                                     'Hi there!', None)
> +        self.assertEqual(['--eval', '(mail nil "jrandom at example.org" "Hi there!")', \
> +                              '(mail-text)' , '(newline)'], commandline)

Backslash & indenting again.


> +    def test_commandline_is_8bit(self):
> +        eclient = mail_client.EmacsMailMode(None)
> +        commandline = eclient._get_compose_commandline(u'jrandom at example.org',
> +            u'Hi there!', u'file%')
> +        self.assertEqual(['--eval', '(mail nil "jrandom at example.org" "Hi there!")', \
> +                              '(mail-text)' , '(newline)', \
> +                           '(attach "file%")'], commandline)

Backslash & indenting again.

bb:resubmit

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH6eVK0F+nu1YWqI0RAt9hAJwJCjN98AfH4F0VZOkxJ81r5qF64wCeJYgQ
7MEEIPB92slaLUH63q3nF9U=
=HeqZ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list