From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Changing side margins in specific mode changes side margins for all buffers
Date: Mon, 15 Jun 2015 21:13:03 -0400 [thread overview]
Message-ID: <jwvfv5sihqh.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: mailman.5065.1434407365.904.help-gnu-emacs@gnu.org
> (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
next prev parent reply other threads:[~2015-06-16 1:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.5065.1434407365.904.help-gnu-emacs@gnu.org>
2015-06-15 23:04 ` Changing side margins in specific mode changes side margins for all buffers Emanuel Berg
2015-06-16 1:13 ` Stefan Monnier [this message]
2015-06-17 0:58 ` Emanuel Berg
2015-06-15 22:29 hack writer
2015-06-16 21:47 ` hack writer
[not found] ` <mailman.5129.1434491234.904.help-gnu-emacs@gnu.org>
2015-06-16 22:35 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvfv5sihqh.fsf-monnier+gnu.emacs.help@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.