Currently I have a mode (magit to be precise) when I have clickable text switches buffer to the file. However I'd prefer sometimes to open in new or neighboring window. Is it possible to do it?
PS. By Window I mean Emacs window not Emacs frame.
magit-status buffer you can usually achieve this with
The same usually works for active links in
But there's no generic way to do this in Emacs. As the document you linked to explains, it's left to the major modes' discretion how they respond to actions on clickable text.
The prescription is:
Implementing a link involves three separate steps: (1) indicating clickability when the mouse moves over the link; (2) making or Mouse-2 on that link do something; and (3) setting up a follow-link condition so that the link obeys mouse-1-click-follows-link.
This however is not a required protocol:
A couple of examples where you can readily observe differences in behavior:
magit-status buffers don't respond to mouse clicks at all, only "keyboard clicks" (
info-mode only provides the "open in new window" behavior for "keyboard clicks" but not for mouse clicks.
magit-status only provides this behavior when visiting files, but not when "visiting" commits. Also "visiting" (keyboard clicking) commits has a side-effect of checking them out first and then displaying them.
describe-function buffers the links pointing to source files always open new frame, with no option to do otherwise.
describe-function buffers the links pointing to other functions always load the new contents in the current buffer, with no option to do otherwise.
magit history buffers and
help-mode buffers the
[back]' and[forward]` buttons always update the current buffer.
describe-mode buffers the links to "Enabled minor modes" cross-references just scroll down in the current window.
dired-mode buffers don't highlight active links.
The implementation details of all this is probably pretty intricate but to illustrate there is no real magic there, compare how
info-mode treats mouse clicks and keyboard clicks differently (compare
defun Info-mouse-follow-nearest-node (click) and
defun Info-follow-nearest-node (&optional fork).
Edit: On solution would be to install org-magit package. then, you could use the following command (from OrgMode) to force your link to be open in a new window
Ctrl-u Ctrl-c Ctrl-o
To open files and buffers in new window:
You can open a buffer in a new window with the following command
Ctrl-x 4 b
Note than you can also open a file in a new window with a similar command
Ctrl-x 4 f