Almost everything you choose to consume will directly or indirectly affect your brain. Obviously, some things we consume affect us more than others. I'm going to assume that spices, plants, animal parts, drugs of any kind, coffee, tea, nicotine and chocolate are all just food and define food as anything we take into our bodies whether it's nutritious or not. In order to better understand how foods affect the brain it will be helpful to divide them into three categories.
First, those foods we consume in high doses with acute dosing: for example, coffee, sugar, heroin, alcohol, nicotine, marijuana, some spices and a few psychoactive plants and mushrooms. Their effects are almost immediate and depend upon how much reaches the brain. In this class, the most important consideration is getting enough of the chemical from within the food to its site of action in our brain to actually produce some kind of effect that we can notice and associate with consuming that particular food. Most of the time, this simply does not happen. For example, consider nutmeg: low doses will be on pies next month and most of us will not notice that it contains two chemicals that our bodies convert into the popular street drug Ecstasy. Yet, if we consumed the entire canister of the spice our guts will notice (with a terrible diarrhea) and there is a good chance that we will hallucinate for about 48 hours! According to my students, the experience is quite unpleasant.
Secondly are those foods that affect our brain slowly over a period of a few days to weeks. This is usually called "precursor-loading" and would include many different amino acids (tryptophan and lysine are good examples), carbohydrates that have a high glycemic index such as potatoes, bagels and rice, fava beans, some minerals (iron and magnesium in particular), lecithin-containing products such as donuts, eggs and cakes, chocolate and the water-soluble vitamins. Their purpose is to bias the function of a specific transmitter system; usually to enhance its function in the brain. For example, scientists once thought that drinking a glass of warm milk before bed or eating a large meal of protein made us drowsy because of tryptophan loading - the current evidence does not support this but the claim makes my major point: we must get enough of any particular nutrient/chemical to the right place and at the right dose in our brain in order for us to notice any effects. Unfortunately, tryptophan has difficulty getting across the blood-brain barrier into our brain.
So, what's the scientific evidence for considering the cognitive effects of these foods? Mostly, it's related to what happens when we do not get enough of them. For example, studies have shown that consuming too little tryptophan makes us depressed and angry and has been blamed for multiple wars and acts of cannibalism. Too little sugar or water-soluble vitamins (the B's and C) will induce changes in brain function that we will notice after a few days of deprivation. Many authors jump to the conclusion that giving high doses of such nutrients will rapidly improve our mood or thinking: sadly, this is rarely the case. Ordinarily the foods in this category require far more time to affect our brains than do those foods in the first category.
The third category includes the slow acting, life-time dosing nutrients that have been popular topics in the press recently. This category includes the anti-oxidant rich foods such as colorful fruits and vegetables, fish and olive oils, fruit juices, anti-inflammatory plants and drugs such as aspirin, some steroids, cinnamon and some other spices, nicotine, caffeine and chocolate, the fat-soluble vitamins, nuts, legumes, beer and red wine. People who eat these foods do not report acute changes in their thoughts or moods (depending upon how much they consume!) but certainly benefit from consuming them regularly over their life span. In general, the benefit comes from the fact that all of these foods provide our brains with some form of protection against the most deadly thing we expose ourselves to every day - Oxygen. Because we consume food, we must consume oxygen. Because we consume oxygen, we age. Thus, people who live the longest tend to each food rich in anti-oxidants or simply eat a lot less food. Recent studies suggest that nicotine and caffeine may prevent the toxic actions of oxygen in our brain which is why I've included them here.
You can see that depending upon how you frame the question about foods and the brain you get a different list of foods and a different reason for consuming them. If you wish to alter your current brain function or slow your brain's aging you need to consume foods that target specific chemical processes. In truth, no one ever considers these distinctions when eating - we just eat what tastes good. Sadly, our brains powerfully reward us when we eat sugar, fat and salt; thus there is an oncoming epidemic of obesity-related illnesses. Food has both negative and positive effects and it all depends upon what you consume, how much you consume and for how long.
See also: Marijuana and Coffee are good for the brain. http://www.youtube.com/watch?v=2uVXs6CY2ps