After running M-x occur, the commands next-error and previous-error let me navigate between hits.
I would like to be able to M-x compile my program and then keep browsing through the same *Occur* results. But if I compile then next-error and previous-error navigate the compilation errors, which makes perfect sense.
I don't want to run M-x occur again because I'd lose my place. What I want is to navigate occur results independently of compilation results.
How can I define next-occur and previous-occur commands that do this? (Note that this is not occur-next and occur-prev, which operate in the *Occur* buffer. I want to bind these to keys in the buffer that's being searched.)
Bonus: I'd prefer grep to be classified like occur, so I can also navigate grep results independently from compilation errors.