mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-03 10:15:47 +01:00
Normalise the definition of :copyto and :moveto.
This commit is contained in:
@@ -112,42 +112,20 @@ function Mail() //{{{
|
|||||||
|
|
||||||
function moveOrCopy(copy, destinationFolder, operateOnThread)
|
function moveOrCopy(copy, destinationFolder, operateOnThread)
|
||||||
{
|
{
|
||||||
if (!destinationFolder)
|
|
||||||
{
|
|
||||||
liberator.echoerr("E471: Argument required");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let folders = mail.getFolders(destinationFolder);
|
let folders = mail.getFolders(destinationFolder);
|
||||||
if (folders.length == 0)
|
if (folders.length == 0)
|
||||||
{
|
return void liberator.echoerr("Exxx: No matching folder for " + destinationFolder);
|
||||||
liberator.echoerr("E94: No matching folder for " + destinationFolder);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (folders.length > 1)
|
else if (folders.length > 1)
|
||||||
{
|
return liberator.echoerr("Exxx: More than one match for " + destinationFolder);
|
||||||
liberator.echoerr("E93: More than one match for " + destinationFolder);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let count = gDBView.selection.count;
|
let count = gDBView.selection.count;
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
return void liberator.beep();
|
||||||
liberator.beep();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copy)
|
(copy ? MsgCopyMessage : MsgMoveMessage)(folders[0]);
|
||||||
{
|
setTimeout(function () {
|
||||||
MsgCopyMessage(folders[0]);
|
liberator.echomsg(count + " message(s) " + (copy ? "copied" : "moved") + " to " + folders[0].prettyName, 1);
|
||||||
setTimeout(function () { liberator.echomsg(count + " message(s) copied to " + folders[0].prettyName, 1); }, 100);
|
}, 100);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MsgMoveMessage(folders[0]);
|
|
||||||
setTimeout(function () { liberator.echomsg(count + " message(s) moved to " + folders[0].prettyName, 1); }, 100);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parentIndex(index)
|
function parentIndex(index)
|
||||||
@@ -679,21 +657,22 @@ function Mail() //{{{
|
|||||||
"Select a folder",
|
"Select a folder",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let count = args.count;
|
let count = Math.max(0, args.count - 1)
|
||||||
args = args.string || "Inbox";
|
let arg = args.literalArg || "Inbox";
|
||||||
count = count > 0 ? (count - 1) : 0;
|
|
||||||
|
|
||||||
let folder = mail.getFolders(args, true, true)[count];
|
let folder = mail.getFolders(arg, true, true)[count];
|
||||||
if (!folder)
|
if (!folder)
|
||||||
liberator.echoerr("Folder \"" + args + "\" does not exist");
|
liberator.echoerr("Exxx: Folder \"" + arg + "\" does not exist");
|
||||||
else if (liberator.forceNewTab)
|
else if (liberator.forceNewTab)
|
||||||
MsgOpenNewTabForFolder(folder.URI);
|
MsgOpenNewTabForFolder(folder.URI);
|
||||||
else
|
else
|
||||||
SelectFolder(folder.URI);
|
SelectFolder(folder.URI);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
argCount: "?",
|
||||||
completer: function (context) getFolderCompletions(context),
|
completer: function (context) getFolderCompletions(context),
|
||||||
count: true
|
count: true,
|
||||||
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["m[ail]"],
|
commands.add(["m[ail]"],
|
||||||
@@ -730,13 +709,21 @@ function Mail() //{{{
|
|||||||
|
|
||||||
commands.add(["copy[to]"],
|
commands.add(["copy[to]"],
|
||||||
"Copy selected messages",
|
"Copy selected messages",
|
||||||
function (args) { moveOrCopy(true, args.string); },
|
function (args) { moveOrCopy(true, args.literalArg); },
|
||||||
{ completer: function (context) getFolderCompletions(context) });
|
{
|
||||||
|
argCount: 1,
|
||||||
|
completer: function (context) getFolderCompletions(context),
|
||||||
|
literal: 0
|
||||||
|
});
|
||||||
|
|
||||||
commands.add(["move[to]"],
|
commands.add(["move[to]"],
|
||||||
"Move selected messages",
|
"Move selected messages",
|
||||||
function (args) { moveOrCopy(false, args.string); },
|
function (args) { moveOrCopy(false, args.literalArg); },
|
||||||
{ completer: function (context) getFolderCompletions(context) });
|
{
|
||||||
|
argCount: 1,
|
||||||
|
completer: function (context) getFolderCompletions(context),
|
||||||
|
literal: 0
|
||||||
|
});
|
||||||
|
|
||||||
commands.add(["empty[trash]"],
|
commands.add(["empty[trash]"],
|
||||||
"Empty trash of the current account",
|
"Empty trash of the current account",
|
||||||
|
|||||||
Reference in New Issue
Block a user