Psalm 4 is usually linked to Psalm 3 (the language does seem to be similar) dealing with Absalom.
v1) The opening is a phrase/idea that we will see consistently throughout the Psalms. “Answer me when I call,” has an urgency within it that seems to reveal that David feels his situation needs quick attention from God or possibly frustration that God is not answering. David goes on to state: O my righteous God OR (in other translations) God of my righteousness. These are very different statements but the verse is clearly David asking God to listen.
v2) David turns his attention to the men who are against him asking them how long this will last. David feels they are unjust in their claims even calling them “delusions!”
v3) He finishes the statement by reminding them that God has set apart the Godly for Himself and tells them that God will hear when he calls to Him. This seems like a bit of a threat, as we’ve seen david is accustomed to using. The irony of the statement is it’s close proximity to the first line when he seems to be a little unsure. I don’t think it’s too unreasonable to ask if David appears to be posturing when, in actuality, he is unsure as to whether God will actually stop the men from harming him. God always hears and He is good but that doesn’t mean He does as we wish – we are, after all, self seeking in our humanity.
4) It’s unclear to me as to who David is directing this statement to. It’s possible he is just reminding himself of the truth in the statement when he may be tempted himself to sin in his anger. The Reader is obviously meant to understand this truth. We see that David identifies the ability to be angry but not sin in it and he gives advice in this situation to search your heart and be silent. Other translations say,” meditate with in your heart on your bed, and be still.”
5) We are to offer right sacrifices and trust in the Lord which is a contrast to those who “love delusions and seek false gods” in verse 2. Going to God (or His alter) with anger in our heart is pointed out as wrong on multiple occasions in the bible.
6) The times have become so dark that it seems those who are around David are desperate to see any kind of “Good.” There have been plenty of times in my life (and even now) that I have felt like evil people were around me all the time. David’s prayer is simple but powerful none the less. “Let the light of Your face shine upon us, O LORD.” This is slightly reminiscent of Moses encounter with God that left him glowing.
7-8) David’s past expiriences have led him to trust in God to the extent that he knows God will honor the prayer and he is filled with greater joy than during times of plenty (and probably celebration)!! Instead of losing sleep over his less than favorable conditions, David rests confidently in the safety of God.