Created
June 23, 2020 19:50
-
-
Save randomwangran/8faa505341deb1291ecc95f7d3bfbdf1 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 center-window (window) "" | |
(let* ((current-extension (file-name-extension (or (buffer-file-name) "foo.unknown"))) | |
(filename (buffer-file-name (current-buffer))) | |
(max-text-width 80) | |
(margin (max 0 (/ (- (window-width window) max-text-width) 2)))) | |
(if (and (not (string-match-p (expand-file-name org-roam-directory) (format "%s" filename))) | |
(not (string= current-extension "org"))) | |
;; Do nothing if this isn't an .md or .txt file. | |
() | |
(set-window-margins window margin margin)))) | |
;; Adjust margins of all windows. | |
(defun center-windows () "" | |
(walk-windows (lambda (window) (center-window window)) nil 1)) | |
;; Listen to window changes. | |
(add-hook 'window-configuration-change-hook 'center-windows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment