summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs29
1 files changed, 15 insertions, 14 deletions
diff --git a/.emacs b/.emacs
index 53f79e1..ed70f21 100644
--- a/.emacs
+++ b/.emacs
@@ -140,20 +140,21 @@
(set-window-margins win nil))))
(defun my/centered-set-margins (window)
- (let* ((target-body-width
- (cond
- ((symbolp my/centered-width)
- (buffer-local-value my/centered-width (window-buffer window)))
- ((integerp my/centered-width)
- my/centered-width)))
- (adjustable-width
- (- (window-total-width window)
- (+ (fringe-columns 'left) (fringe-columns 'right))))
- (target-margin
- (when (> adjustable-width target-body-width)
- (/ (- adjustable-width target-body-width) 2))))
- ;; Only set left margin, so that long lines are not truncated.
- (set-window-margins window target-margin)))
+ (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))))
+ (target-margin
+ (when (> adjustable-width target-body-width)
+ (/ (- adjustable-width target-body-width) 2))))
+ ;; Only set left margin, so that long lines are not truncated.
+ (set-window-margins window target-margin))))
(defun my/kill (stuff)
(kill-new stuff)