2

This should do it. (defun foo () (interactive) (add-hook 'next-error-hook 'toto) (let ((thisbuf (current-buffer))) (next-error) (switch-to-buffer thisbuf)) (remove-hook 'next-error-hook 'toto)) (defun toto () (message "Current buffer: %s" (current-buffer)) (org-store-link nil)) It fixes three problems: (current-buffer) ...


2

Doing all the preparation to be able to do that is going to be more work than it is worth: you have to write special functions to use the buffer(s) of interest and then bind them to keys. I think it would be simpler to rename-uniquely the various grep/compile/etc buffers you create (so you would have *grep*<2>, *grep*<3> etc buffers, one for each ...


Only top voted, non community-wiki answers of a minimum length are eligible