I'm using golden-ratio and ediff.

I want golden-ratio-mode turned off when using ediff and turned on after I finish merging with magit.

I cannot figure out a way to evenly balance Ediff's windows (A, B and C).

(use-package ediff
  :ensure nil
  (add-hook 'ediff-before-setup-windows-hook
            (lambda ()
              (golden-ratio-mode -1)
  (add-hook 'ediff-cleanup-hook (lambda () (golden-ratio-mode 1)))
   ediff-split-window-function 'split-window-horizontally))

What am I missing?

  • 1
    Assuming you mean the golden-ratio package on Melpa (please always link to or be otherwise specific about non-core libraries and packages), a quick look suggests that you want to explore the provided user options for disabling that functionality for certain modes and buffers. Note that your approach of disabling the (global) mode when ediff starts and re-enabling it when it exits means that it's disabled for anything else you do in other frames while the ediff frame is active. M-x customize-group RET golden-ratio for starters.
    – phils
    May 23 '16 at 22:50
  • Thank you, I will look into it. About your last note, are you referring to other emacsclient frames for instance? May 24 '16 at 7:50
  • For instance, yes; but more generally any other frames. e.g. C-x 5 2 to create a new frame, if there aren't any others already. Or indeed if you were to change the window configuration in the ediff frame without exiting ediff, and sometime later return to the ediff configuration to finish what you were doing, the same thing would apply -- for the duration that the global mode is disabled, it obviously won't have any effect on any windows.
    – phils
    May 24 '16 at 8:37
  • I've checked golden-ratio-exclude-modes. It seems that the code proposed in the Wiki: github.com/roman/golden-ratio.el/wiki doesn't work (anymore?), the documentation says that it is supposed to work with major modes. However, the 3 buffers A, B and C are in their own major mode. Am I missing something? May 24 '16 at 9:52

In fact the code at https://github.com/roman/golden-ratio.el/wiki for handling ediff mostly worked; I suspect it was just a little out of date with the current version of golden-ratio. It's updated now.

That's using golden-ratio-inhibit-functions to allow arbitrary elisp to determine whether to resize a given window.

In simpler cases than this, one of the following user options would often suffice:

  • golden-ratio-exclude-buffer-names
  • golden-ratio-exclude-buffer-regexp
  • golden-ratio-exclude-modes
  • Yes I've tried what was proposed in the comments of some pull request but it didn't work either. :( Thank you for your code, I'll try this out. May 24 '16 at 11:58
  • Try the wiki again. The approach from there actually seems to work fine -- it just needed a slight update.
    – phils
    May 24 '16 at 12:21
  • I wanted to edit the Wiki to add (balance-windows) in there. If I submit my edit, will it be subject to be reviewed by one of the collaborators or will it be updated directly? I'm asking this because I don't see you in the list of collaborators (and you just updated the Wiki yourself). May 24 '16 at 12:41
  • I browsed the settings of one of my own repository, and it seems that it is an option to have publicly editable Wikis. TIL. Updated the Wiki page, let me know if I pooped over it. May 24 '16 at 12:52
  • Curious that you needed that. In my own tests I found that, with nothing more than the code given, there wasn't a need to explicitly balance the windows. I was testing a simple A/B diff, mind; rather than a merge. Not sure if that's the difference. Glad you got it working, in any case.
    – phils
    May 24 '16 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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