roman / golden-ratio.el

Automatic resizing of Emacs windows to the golden ratio
MIT License
589 stars 38 forks source link

execute golden-ratio at startup of a REPL #56

Closed xin-jin closed 8 years ago

xin-jin commented 9 years ago

Sorry, not really an issue, just I don't know how to do it: I prefer to manually execute golden-ratio by a macro rather than using the golden-ratio-mode, but I would like to automatically execute golden-ratio once when the REPL starts. I have very limited knowledge of elisp, and cannot get it to work by simply add golden-ratio to the inferior-python-mode-hook.

syl20bnr commented 8 years ago

This is due to the wrong usage of golden-ratio-mode variable in golden-ratio, I tried to fight against this change in https://github.com/roman/golden-ratio.el/pull/45 but I did not succeed in convincing the people.

You have to first set golden-ratio-mode variable to non-nil before calling golden-ratio, you should also be able to pass a non-nil argument to the function to force it (not sure about this one, it is not documented).

cc @thierryvolpiatto @tarsius @abo-abo @roman

thierryvolpiatto commented 8 years ago

@xin-jin , try:

(lambda () (golden-ratio 1))

in your hook instead of golden-ratio

syl20bnr commented 8 years ago

@thierryvolpiatto this really should not be necessary but I gave it up, I don't have more time to put into this ;-) Up to you guys, if you prefer a not documented raw argument to fix the bad semantic attributed to golden-ratio-mode, that's OK with me.

xin-jin commented 8 years ago

@thierryvolpiatto Thanks, but it doesn't seem to work. My code:

(add-hook 'inferior-python-mode-hook
          (lambda () (golden-ratio 1)))
thierryvolpiatto commented 8 years ago

xin-jin notifications@github.com writes:

@thierryvolpiatto Thanks, but it doesn't seem to work. My code:

(add-hook 'inferior-python-mode-hook (lambda () (golden-ratio 1)))

Oops, seems that my last post never endup on github. I repost here: The problem is that when your python hook run the window is not ready, so you have to delay the call to golden-ratio, do it like this:

(add-hook 'inferior-python-mode-hook (lambda () (run-with-idle-timer 1 nil (lambda () (golden-ratio 1)))))

Thierry

https://emacs-helm.github.io/helm/

xin-jin commented 8 years ago

@thierryvolpiatto Thanks! Now it works.