So I'm using Emacs in Windows (Emacs 24.5.1, Windows 10). I've set a default margin width of 20 on both sides for text-mode, but occasionally I like to resize the window in half (Windows+left or right arrow) so that I can quote something from a browser window or the like.
What would be a good way to have Emacs detect this behavior and adjust the margins appropriately (as it is, there's just a thin slit of text when the window is halved), maybe to 5 or 3 characters on each side?
Alternatively, how could I program a function I could issue that would do this manually? I can't even work out how to do it by issuing setq left-margin-width xx from within a running instance. Heeelp.
Here are the relevant parts of my current .emacs:
(add-hook 'text-mode-hook 'visual-line-mode) (defun margins () (setq left-margin-width 20) (setq right-margin-width 20)) (add-hook 'text-mode-hook 'margins)
C-x 3, or something else?
windoware distinct: a frame can display multiple windows.) Two options for what you want: write Emacs commands that resize the frame to the left/right half of the screen and also set the margin. Or you can use the
window-configuration-change-hookwith a function that checks for e.g. the current frame size and sets the margins accordingly. That hook gets called for any window/frame change.