Implement priority based clearsnippets.

Implement priority-based clearsnippets and add corresponding test cases (#335).
I do not understand why you need the __inner function here in the first place. It is not recursing, so why not inline it?