I know it sounds very similar, but if you want Gmail to function in Mail.app like it does in Gmail, where you archive most but not all of your mail, there are some unique settings.
Gmail's recommended settings for Mail.app:
(note: for the rest of this message, if Gmail is a link, that's because I can't figure out how to not make hard-brackets not evoke some kind of special message board code.)
Trash:
Move deleted messages to the Trash mailbox > do NOT check
Store deleted messages on the server > do NOT check
* Do NOT save deleted messages on the server. Messages that are deleted from an IMAP folder (except for those in [Gmail]/Spam or [Gmail]/Trash) only have that label removed and still exist in All Mail. Hence, your client doesn't need to store an extra copy of a deleted message.
* Do NOT save deleted messages to your [Gmail]/Trash folder because this will delete a message in all folders.
* Do NOT save deleted messages to your [Gmail]/All Mail folder as some clients will try to empty this folder and ultimately fail. This can lead to delayed mail access or excessive battery consumption on a mobile device.
I can't try your script just now (at work), but I will try it once I get home. It looks like it should work in the most basic scenario.
If I wanted to filter the messages to go into the account specific Trash mailbox, is that a trivial process? Could I:
tell application "Mail"
set theMessages to (get selection)
set theAccount to (get account of theMessages)
move theMessages to mailbox "Trash" of "[Gmail]" of account "theAccount"
end tell
?
That's just my guess at what the Applescript might look like.
Thanks for all your help.