checking the ID would be better.
No, actually checking `id` is essential. I didn't really realise how much until now. Consider for example the sequence:
1. Geany function gets `doc` pointer 2. does something that results in a signal 3. plugin callback is called by signal and it closes the document Geany's `doc` points to 4. plugin opens a new document and it happens to reuse the document object that Geany's `doc` points to 5. signal returns to Geany
So now, unless Geany checks both `valid` and `id` it will not know its `doc` points to something different to what it thinks.
After finding `id` is different it probably shouldn't do anything.
And of course the sequence above is just one way for it to happen.
But I suspect a lot of Geany doesn't check `id`, maybe IS_VALID should take id as a parameter. And even better it can be made a function not an EVIL macro!!!