reddit / emacs

How to cause a line to be fully visible after shrinking then enlarging the window

bhrgunatha · 2022-05-05 10:20
I have a couple of functions to enlarge and shrink the current window when there are two windows left | right of each other. (defun b/enlarge-window-horizontally (times) "Enlarge window horizontally by 10 columns instead of 1. Using prefix argument to multiply the effect." (interactive "p") (enlarge-window-horizontally (* (or times 1) 10))) (defun b/shrink-window-horizontally (times) "Shrink window horizontally by 10 columns instead of 1. Using prefix argument to multiply the effect." (interactive "p") (shrink-window-horizontally (* (or times 1) 10))) For argument let's say the point is at the end of the line. If I shrink too much, the point remains visible (which I like) and I get little arrows in the gutter indicating the text is truncated "off screen" to the left. That's good. If I enlarge the window again though, the point remains fixed, those arrows remain and the text is still "off screen". Now If move to the beginning of the line, then back to the end of the line, the full text is visible once again and the arrows are gone. I've tried getting my functions to do that last part for me but it's failing: (defun b/enlarge-window-horizontally (times) "Enlarge window horizontally by 10 columns instead of 1. Using prefix argument to multiply the effect." (interactive "p") (enlarge-window-horizontally (* (or times 1) 10)) (let ((saved (point))) (beginning-of-line) (goto-char saved))) (defun b/shrink-window-horizontally (times) "Shrink window horizontally by 10 columns instead of 1. Using prefix argument to multiply the effect." (interactive "p") (shrink-window-horizontally (* (or times 1) 10)) (let ((saved (point))) (beginning-of-line) (goto-char saved))) Those additions have no effect on the arrows or the text truncated off-screen. Why don't those additions to my functions force the off-screen text to come back into view again - like when I do that manually? More importantly how can I get them to do that for me?
Hamilton950B · 2022-05-05 15:49
Maybe the disabled functions scroll-left and scroll-right would help.