Factor out the execution part of modal file visiting macro
Improve modal handling for magit and w3m