I just followed Jeff Schuette’s ace guide on how to set up Gmail with Apple Mail - the proper way. It’s a little out of date now, and US-specific (I had to change the IMAP path prefix to [Google Mail] instead of [Gmail], for example), but for the most part it works far better than Gmail and Apple’s own guidelines for getting the two in sync. Check it out.