1

I have 2 windows open: One is the magit-diff of the current repo, the other is just source codes from that repo. In source codes (the right window), I have a file opened, say "sample.txt". In magit-diff (the left window), I can see all of the deletion and insertion that occur for "sample.txt". In other words, it looks like this:

    | magit-diff                    | "sample.txt  |
    | modified sample.txt           |              |
    | + text I added                |              | 
    | - text I removed              |              |

Now, if I press enter on the line "+ text I removed", then I would be taken straight to "sample.txt" at the exact line where the insertion/deletion happens. The only problem is that this would open another buffer that overlays the current magit-diff buffer. The original window for "sample.txt" does not change. In other words:

    | "sample.txt"                                    | "sample.txt" |
    | cursor at line of inseration/deletion           |              |
    |                                                 |              | 
    |                                                 |              |

I do not want this to happen. What I want is once I press enter in magit-diff, I would like the other window (the right window with "sample.txt" already opened) to jump to the line of insertion/deletion. If "sample.txt" is not already opened yet, then just open the file in another window. In other words, after pressing enter:

    | magit-diff                    | "sample.txt"                                     |
    | modified sample.txt           |  cursor at line of insertion/deletion            |
    | + text I added                |                                                  | 
    | - text I removed              |                                                  |

Is there a way to do this within emacs? Please let me know and thank you for your help.

1 Answer 1

1

The option magit-display-buffer allows you to control in great detail how buffers are displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.