[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing side margins in specific mode changes side margins for all
From: |
Stefan Monnier |
Subject: |
Re: Changing side margins in specific mode changes side margins for all buffers |
Date: |
Mon, 15 Jun 2015 21:13:03 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> (add-hook 'window-configuration-change-hook (lambda () (set-window-margins
> (car (get-buffer-window-list (current-buffer) nil t)) 29 29)))
Your code is unreadable. For your own sake, lay it out clearly:
(add-hook 'window-configuration-change-hook
(lambda ()
(set-window-margins (car (get-buffer-window-list
(current-buffer) nil t))
29 29)))
Which sets up a global hook, and then
> (add-hook 'window-configuration-change-hook (lambda () (set-window-margins
> (car (get-buffer-window-list (current-buffer) nil t)) 29 29))
> 'make-it-local)
turns into
(add-hook 'window-configuration-change-hook
(lambda ()
(set-window-margins (car (get-buffer-window-list
(current-buffer) nil t))
29 29))
'make-it-local)
where you see that you pass `make-it-local' as third argument. And if
you check `C-h f add-hook RET' you'll see that the third arg is called
APPEND, and it's the *fourth* arg which is called LOCAL. So you just
need to add a nil as third argument.
BTW, where did you get (car (get-buffer-window-list (current-buffer) nil t))?
`C-h v window-configuration-change-hook' says:
The buffer-local part is run once per window, with the relevant window
selected; while the global part is run only once for the modified frame,
so since "the relevant window" is already selected, you don't need to
look for it. You can either use (selected-window) or more simply nil
since the default for set-window-margins is to use the selected window.
IOW:
(add-hook 'window-configuration-change-hook
(lambda () (set-window-margins nil 29 29))
nil 'local)
-- Stefan