-
-
Save priyadarshan/5408877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun wc/narrow-window () | |
(let (( new-right | |
(max 0 (+ (or (cdr (window-margins)) 0) | |
(- (window-body-width) fill-column))))) | |
(set-window-margins nil (car (window-margins)) new-right) | |
(set-window-fringes nil (car (window-fringes)) 2))) | |
(define-minor-mode wrap-column-mode | |
"Wrap the text at `fill-column'. | |
Works by adjusting the right margin." | |
nil nil nil | |
(if wrap-column-mode | |
(progn | |
(visual-line-mode 1) | |
(add-hook 'window-configuration-change-hook | |
'wc/narrow-window nil t) | |
(wc/narrow-window)) | |
(progn | |
(remove-hook 'window-configuration-change-hook | |
'wc/narrow-window t) | |
(set-window-margins nil (car (window-margins)) nil) | |
(set-window-fringes nil (car (window-fringes)) | |
(car (window-fringes)))))) | |
(provide 'wrap-column) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment