To complement to VilleNiemi's answer, I'll throw some ideas on gun and cybernetics. Those ideas only really work for active users like soldiers or police officers. They assume that the user is equipped with a special helmet or has cybernetic implants. That equipment could also be part of the weapon package sold to a civilian.
You might want to look at the military rifles from John Scalzi's Old man's war, most of those ideas are inspired by them. Those guns are basically telepathically controlled (from cybernetic technology), the owner must submit an electronic confirmation to shoot or input any command. They have no AI to speak off, but the weapon is completely computer controlled.
This is something Ville already covered. So I will only add that, if cybernetics are in your world, they would be used for that and possibly to access other function.
The gun can monitor how many ammunition are left and signal problems as they happen. Depending on the level of electronic technology available, they could be sent directly in the user's vision. Sent to a portable screen similar to google glasses. Or displayed on the gun itself.
If the communication and camera technology are advanced enough, the scope's image could be sent directly to the shooter's view. Like before, how it is seen depends on the level of cybernetics available.
Multiple ammunition types
If the gun is computerized, it can have more than one firing system or ammunition mechanism. For example, a military rifle could carry both standard rounds for soldiers and explosive rounds for armored targets. A rotating part similar to a revolver's barrel allows switching between them. The command could be a switch on the weapon or a mental command. This would surely quickly increase the weight of the weapon.
About computerized guns.
It might also be a good idea to take a loot at how mobile devices are developing. As more and more electronics are packed around a weapon, I could see the same kind of evolution happening in a much more focussed and utilitarian way. Here's a few ideas I have off the top of my head :
A squad's guns synchronise so that only 1 person is controlling the firing of all of them. I could see each person having to pull the trigger to allow his gun to fire, but all weapons would only fire when the leader orders it.
I am not quite sure how this could be applied in a realistic setting. As the only way I see such a level of synchronisation being needed is for the opening volley against highly armored targets. Or against automated defences. These really depends on your world. This application would probably be limited to military settings.
This is moving slightly away from the weapon themselves. But if the scope is sent to the officer's view directly, the same could be done to another officer's view. This could be used to show a target and to make sure everyone is ready to fire.