There seem to be a lot of situations, where a command changes the cursor location (point), but no mark is pushed, making navigating back by popping the mark with
C-u SPC impossible.
For isolated use-cases, I can fix this with e.g.
advice-add on the affected command, or other ad-hoc fixes (see e.g. Set mark when jumping from emacsclient). I have however found, that it affects just too many situations to manually track down where to put the advice, and maintain that advice as the functions change -- quite often the suitable function is a package-private function like
Examples, where this makes issues, include:
- Latex forward/inverse search
Is there some better, cleaner way to achieve more comprehensive "mark-pushing"?
Workflow and Workarounds
Given a setup
+--EmacsFrame----------------------+ | | | | FileBuffer | NavigationBuffer | | FileWindow | NavigationWindow | | | | | | | +----------------------------------+
Where NavigationBuffer is associated e.g. with the
occur feature, I may either:
- Switch to NavigationWindow with a keyboard command, and activate a command, that causes the point in
FileBufferto change, or
- Click somewhere in NavigationWindow to the same effect.
Case (2) can be covered the same way for left-click and right-click events. Many modes however default to reacting only to middle-button clicks; In this case,
current-buffer remain the same before and after the command.
While I can probably find a workaround for the middle-click case, the solution seems like a messy workaround at this point; A cleaner solution would be preferable.
 RichieHH's Answer: In this case, there is
xref-pop-marker-stack, but setting the mark would still be nice for consistency.