Hi,
I added today a :message command which opens a new compose window. It
takes a few arguments, which will be filled in the new compose window.
The command takes the following arguments, where all recipients are
filled into the to header, all attachments are added, of course only if
they exist, and the body text can also be preset.
:m[essage] [-subject="hello world"] [-bcc=...] [-cc=] [-attachment
file,file] [-text="hello\n\nbye"] [EMAIL PROTECTED] [EMAIL PROTECTED]
I also mapped `m', so that it opens a command line ":message ", the
really new mapping `M', which opened a new composing window, with the
sender of the marked message as receiver, was also mapped, that it opens
only a command line (e.g. `:message [EMAIL PROTECTED]')
It would IMHO also be really cool, to open the compose window as a tab,
but i searched the thunderbird source and I don't found out, how this
works ( I've really little experience in writing thunderbird/firefox code ).
I think i will work on an addressbook completion for :message the next
days, if i find the time for it.
greetz didi
>From a76f5e9440ab4c5ab0f3fb14b447655bcfdaee3d Mon Sep 17 00:00:00 2001
From: Christian Dietrich <[EMAIL PROTECTED]>
Date: Wed, 28 May 2008 18:45:49 +0000
Subject: [PATCH] Added :m[essage] command and mapped m/M to it
---
content/mail.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/content/mail.js b/content/mail.js
index b04a999..fa63f6d 100644
--- a/content/mail.js
+++ b/content/mail.js
@@ -175,7 +175,8 @@ liberator.Mail = function () //{{{
params.composeFields = Components.classes["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Components.interfaces.nsIMsgCompFields);
- if (args) {
+ if (args)
+ {
if (args.originalMsg)
params.originalMsgURI = args.originalMsg;
if (args.to)
@@ -188,7 +189,30 @@ liberator.Mail = function () //{{{
params.composeFields.newsgroups = args.newsgroups;
if (args.subject)
params.composeFields.subject = args.subject;
+ if (args.body)
+ params.composeFields.body = args.body;
+ while (args.attachments.length > 0)
+ {
+ var url = args.attachments.pop();
+
+ // Check if the file really exists
+ var file = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ file.initWithPath(url);
+
+ if (!file.exists())
+ {
+ liberator.echoerr("Exxx: Could attach file `" + url + "'", liberator.commandline.FORCE_SINGLELINE);
+ continue;
+ }
+ attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"]
+ .createInstance(Components.interfaces.nsIMsgAttachment);
+ attachment.url = "file://" + url;
+ params.composeFields.addAttachment(attachment);
+ }
+
}
+
params.type = Components.interfaces.nsIMsgCompType.New
@@ -319,7 +343,7 @@ liberator.Mail = function () //{{{
// SENDING MESSAGES
liberator.mappings.add(modes, ["m"],
"Compose a new message",
- function () { composeNewMail(); });
+ function () { liberator.commandline.open(":", "message ", liberator.modes.EX); });
liberator.mappings.add(modes, ["M"],
"Compose a new message to the sender of selected mail",
@@ -327,9 +351,8 @@ liberator.Mail = function () //{{{
{
try
{
- var args = new Object();
- args.to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
- composeNewMail(args);
+ var to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
+ liberator.commandline.open(":", "message \"" + to + "\"", liberator.modes.EX);
}
catch (e) { liberator.beep(); }
});
@@ -613,6 +636,38 @@ liberator.Mail = function () //{{{
completer: function (filter) { return liberator.completion.mail(filter); }
});
+ liberator.commands.add(["m[essage]"],
+ "Write a new message",
+ function (args, special, count)
+ {
+ var res = liberator.commands.parseArgs(args, this.args);
+ if (!res)
+ return;
+
+ var mailargs = new Object();
+
+ mailargs.subject = liberator.commands.getOption(res.opts, "-subject", undefined);
+ mailargs.bcc = liberator.commands.getOption(res.opts, "-bcc", undefined);
+ mailargs.cc = liberator.commands.getOption(res.opts, "-cc", undefined);
+ mailargs.body = liberator.commands.getOption(res.opts, "-text", undefined);
+ mailargs.attachments = liberator.commands.getOption(res.opts, "-attachment", []);
+
+ if (res.args.length > 0)
+ {
+ mailargs.to = res.args.join(", ");
+
+ }
+
+ composeNewMail(mailargs);
+ },
+ {
+ args: [[["-subject", "-s"], liberator.commands.OPTION_STRING],
+ [["-attachment", "-a"], liberator.commands.OPTION_LIST],
+ [["-bcc", "-b"], liberator.commands.OPTION_STRING],
+ [["-cc", "-c"], liberator.commands.OPTION_STRING],
+ [["-text", "-t"], liberator.commands.OPTION_STRING]]
+ });
+
liberator.commands.add(["copy[to]"],
"Copy selected messages",
function (args, special) { moveOrCopy(true, args); },
--
1.5.5.1
_______________________________________________
Muttator mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/muttator