this post was submitted on 18 Oct 2023
1 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I have a bunch of one off functions to do frame/window layout. But an issue I run into is that if I do, say

(set-frame-size (selected-frame) 255 80)
(some-other-function-that-looks-at-frame-size-to-split-windows)

Half the time the resize hasn't finished by the time the split function runs, and so it splits incorrectly. I'm assuming the resize happens asynchronously, but I don't see a hook or event I can make use of to make sure I'm splitting after the fact. Is there something I'm missing? Sleeping doesn't seem to fix it because that just delays the resize as well.

top 3 comments
sorted by: hot top controversial new old
[–] JDRiverRun@alien.top 1 points 1 year ago

Set a window-configuration-change-hook temporarily, see if the (selected-frame) matches. If so do the split, and remove the hook.

[–] alanthird@alien.top 1 points 1 year ago (1 children)

I think you can do (sit-for 0) which will force a redisplay, after which, hopefully, your frame will be resized.

[–] jsadusk@alien.top 1 points 1 year ago

That worked! This is the easy answer, I really appreciate it.