Showing posts with label gmail. Show all posts
Showing posts with label gmail. Show all posts

Sunday, November 12, 2006

Gmail and Top Posting

I know many have bitched about this in the past, so I won't go off on a rant now. I am curious though if Google has addressed this anywhere that I haven't seen. As in, have they so much as acknowledged the complaints at all? Even if there were some FAQ entry somewhere that said something lame like "We at Google have decided that top posting is best practise and have no plans to support bottom posters." that would provide a feeling of closure. Instead, each time the New Features indicator appears I jump all over it hoping that today is the day. It never is.

Admittedly, I do feel like a bit of a knob even complaining or mentioning this at all. It's not that big of a deal to delete the space at the top, trim the replied text, and add my reply to the bottom. Also, I understand that Windows users are the majority and that Google probably doesn't wish to confuse them. But at least acknowledge good form and provide a non-default setting so that the geeks of the world who do give a shit feel loved too.

Am I alone here?

Tuesday, October 10, 2006

Send a Gmail Message from Vim

Using Gmail on my laptop through the web interface can be quite time consuming. I use the Linux version of Firefox, and it's not exactly known around the world for its great speed. Anyways, sometimes I just want to shoot off a quick email, and it would take just as long to load the Gmail compose form as it would to type the email content. For these times I wrote a little vim-python script as follows:

" Make sure the Vim was compiled with +python before loading the script...
if !has("python")
        finish
endif

:command! -nargs=? GMSend :call GMailSend("<args>")

function! GMailSend(args)
python << EOF
import vim
to = vim.eval('a:args')
GSend(to)
EOF
endfunction

python << EOF
########### BEGIN USER CONFIG ##########
account = 'MY_GMAIL_ACCOUNT'
password = 'MY_GMAIL_PASSWORD'
########### END USER CONFIG ###########


def GSend(to):
    """
    Send the current buffer as a Gmail message to a given user.
    """
    import libgmail

    subject = vim.current.buffer[0]
    body = '\n'.join(vim.current.buffer[2:])

    ga = libgmail.GmailAccount(account, password)
    try:
        ga.login()
    except libgmail.GmailLoginFailure:
        print "Login failed. (Wrong username/password?)"

    gmsg = libgmail.GmailComposedMessage(to, subject, body)

    if ga.sendMessage(gmsg):
        print "Message sent `%s` successfully." % subject
    else:
        print "Could not send message."

EOF

It's a really simple script, and it uses Python so it will only work if your Vim was compiled with the +python option. Of course, you'll also need to edit the script to put in your own Gmail user name and password (lines 18 and 19).

Installation

Drop the above script (or download it from here) into your ~/.vim/plugin/ directory. Reload Vim or source the file with :so ~/.vim/gmail.vim.

Usage

It's even easier to use. The first line in the buffer is the email's subject, and the rest is the body. Once the email is composed in this fashion, type :GMSend <dest> where <dest> is the email address that you want to send this message to. If all is well, you'll see a message at the bottom of your Vim window indicating that all is well, and that the message was sent successfully.

Hopefully somebody out there will find this useful. The version I am actually using is a little more complex. I've extended the script to download messages by folder or label and stick the id, subject, and author in an active buffer. From there I can select one of the shown messages and the script will display the body in the same buffer. I've kept the rest to myself as I'm not real thrilled with the UI part, and I'm not sure it will work as expected for everyone. If you are interested, leave a comment. I'm pretty confident that the script posted above (the one that just sends mail) will work as expected. Enjoy!