dotfiles

🎜 Clone'em, tweak'em, stick'em in your $HOME 🎝
git clone https://git.kevinlegouguec.net/dotfiles
Log | Files | Refs | README

commit 86c0a058e54df4673a6dc6d0ac733076537d8c99
parent 42c21026e4de5b3673626fec28572117eac5da5c
Author: KΓ©vin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Sat,  1 Oct 2022 11:28:17 +0200

Fix buffer-local value lookup

Couple of mistakes there:

* buffer-local-value was called too late,
* the symbol wasn't quoted, so buffer-local-value ended up taking a
  peek at fill-column directly, because that's what my/centered-width
  defaults to.

Just wrap the whole thing in with-current-buffer.  That'll make it
easier to introduce new buffer-local variables set via mode hooks.

Diffstat:
M.emacs | 29+++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)

diff --git 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)