commit 8a770191de37c62b1b264c0d99ad8ee11adee03c parent b52be6ec545a064e29601fd2a728317f629307d7 Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com> Date: Sat, 10 Jan 2026 15:44:11 +0100 Remove my/centered-mode Have not used it in a while; probably stopped feeling the need after re-arranging gnus-buffer-configuration. Diffstat:
| M | .config/emacs/init.el | | | 57 | +-------------------------------------------------------- |
1 file changed, 1 insertion(+), 56 deletions(-)
diff --git a/.config/emacs/init.el b/.config/emacs/init.el @@ -105,60 +105,6 @@ (set-variable 'tab-width new-width) (message "changed from %s to %s" old-width new-width))) -(defvar-local my/centered-width 'fill-column) -(defvar-local my/centered-set-right-margin nil) - -(defun my/centered--before-split (&optional _size window-to-split) - (let ((windows (if (frame-root-window-p window-to-split) - (window-list) - (list window-to-split)))) - (dolist (w windows) - (when (buffer-local-value 'my/centered-mode (window-buffer w)) - (set-window-margins w nil nil))))) - -(defun my/centered--around-splittable (splittable window &optional horizontal) - (if (and horizontal - (buffer-local-value 'my/centered-mode (window-buffer window))) - (let ((margins (window-margins window))) - (set-window-margins window nil nil) - (prog1 - (funcall splittable window horizontal) - (apply 'set-window-margins window margins))) - (funcall splittable window horizontal))) - -(advice-add 'split-window-right :before 'my/centered--before-split) -(advice-add 'window-splittable-p :around 'my/centered--around-splittable) - -(define-minor-mode my/centered-mode - "Update margins to keep content centered." - :init-value nil - (if my/centered-mode - (progn - (add-hook 'window-state-change-functions 'my/centered-set-margins nil t) - (dolist (win (get-buffer-window-list)) - (my/centered-set-margins win))) - (remove-hook 'window-state-change-functions 'my/centered-set-margins t) - (dolist (win (get-buffer-window-list)) - (set-window-margins win nil)))) - -(defun my/centered-set-margins (window) - (with-current-buffer (window-buffer window) - (let* ((target-body-width - (cond - ((symbolp my/centered-width) - (symbol-value my/centered-width)) - ((integerp my/centered-width) - my/centered-width))) - (adjustable-width - (- (window-total-width window) - (+ (fringe-columns 'left) (fringe-columns 'right)))) - (left-margin - (when (> adjustable-width target-body-width) - (/ (- adjustable-width target-body-width) 2))) - (right-margin (and my/centered-set-right-margin - left-margin))) - (set-window-margins window left-margin right-margin)))) - (defun my/auto-hscroll-toggle () (interactive) ;; Use indices to avoid confusing `if-let*' with nil. @@ -294,8 +240,7 @@ list and require no escaping." (my/define-prefix-command my/display-map "Keymap for display-related commands." - '(("c" my/centered-mode) - ("h" my/auto-hscroll-toggle) + '(("h" my/auto-hscroll-toggle) ("l" hl-line-mode) ("n" display-line-numbers-mode) ("t" toggle-truncate-lines)