~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-04-01 05:59:45 UTC
  • mfrom: (3322.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080401055945-3pmuiy0q0301axv6
Add mail-mode GNU Emacs mail package as a mail client option (Xavier
        Maillard)

Show diffs side-by-side

added added

removed removed

Lines of Context:
306
306
        return commandline
307
307
 
308
308
 
 
309
class EmacsMailMode(ExternalMailClient):
 
310
    """Call emacsclient in mail-mode.
 
311
    
 
312
    This only work for emacs >= 22.1.
 
313
    """
 
314
    _client_commands = ['emacsclient']
 
315
 
 
316
    def _get_compose_commandline(self, to, subject, attach_path):
 
317
        commandline = ["--eval"]
 
318
        # Ensure we can at least have an empty mail-mode buffer
 
319
        _to = "nil"
 
320
        _subject = "nil"
 
321
 
 
322
        if to is not None:
 
323
            _to = ("\"%s\"" % self._encode_safe(to))
 
324
        if subject is not None:
 
325
            _subject = ("\"%s\"" % self._encode_safe(subject))
 
326
        mmform = "(mail nil %s %s)" % (_to ,_subject)
 
327
 
 
328
        # call mail-mode, move the point to body and insert a new blank line
 
329
        # we *must* force this point movement for the case when To is not passed
 
330
        # with --mail-to. Without this, the patch could be inserted at the wrong place
 
331
        commandline.append(mmform)
 
332
        commandline.append("(mail-text)")
 
333
        commandline.append("(newline)")
 
334
 
 
335
        # ... and put a MIME attachment (if any)
 
336
        if attach_path is not None:
 
337
            ifform = "(attach \"%s\")" % self._encode_path(attach_path,'attachment')
 
338
            commandline.append(ifform)
 
339
        return commandline
 
340
 
 
341
 
309
342
class MAPIClient(ExternalMailClient):
310
343
    """Default Windows mail client launched using MAPI."""
311
344