From: Joost Kremers <joostkremers@fastmail.fm>
To: emacs-devel@gnu.org
Cc: martin rudalics <rudalics@gmx.at>, Eli Zaretskii <eliz@gnu.org>,
Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Adding olivetti to GNU ELPA
Date: Tue, 14 May 2019 18:05:15 +0200 [thread overview]
Message-ID: <877eat58ec.fsf@fastmail.fm> (raw)
In-Reply-To: <m2sgth39a7.fsf@paulwrankin.com>
On Tue, May 14 2019, Paul W. Rankin wrote:
> (cond ((<= emacs-major-version 24)
> (add-hook 'window-configuration-change-hook
> 'olivetti--??? t t))
> ((<= emacs-major-version 26)
> (add-hook 'window-configuration-change-hook
> 'olivetti--??? t t)
> (add-hook 'window-size-change-functions
> 'olivetti--??? t t))
> ((<= 27 emacs-major-version)
> (add-hook 'window-size-change-functions
> 'olivetti--??? t t)))
I have no idea if this helps (I'm not entirely sure if I correctly
understand the issues you're facing), but FWIW, this is what I do
in `visual-fill-column-mode`
<https://github.com/joostkremers/visual-fill-column>, which must
solve essentially the same problem:
```
(defun visual-fill-column-mode--enable ()
"Set up `visual-fill-column-mode' for the current buffer."
(add-hook 'window-configuration-change-hook
#'visual-fill-column--adjust-window 'append 'local)
(if (>= emacs-major-version 26)
(add-hook 'window-size-change-functions
#'visual-fill-column--adjust-frame 'append))
(visual-fill-column--adjust-window))
```
So I use `window-configuration-change-hook` in every Emacs version
and `window-size-change-functions` in Emacs >= 26. ISTR that it's
not possible to forego `window-configuration-change-hook` in Emacs
26, but I can't remember why...
I have at least one report of this working on Emacs 27, but I must
admit that I'm running Emacs 26 myself, so perhaps there are
problems this particular user doesn't care about.
`visual-fill-column--adjust-frame simply calls
`visual-fill-column--adjust-window` for every window on the
relevant frame. In Emacs 27, this function must be in the global
part of `window-size-change-functions`, because Emacs 27 changed
the way the local part is called. `visual-fill-column-mode` could
of course be adapted to use the local part of the hook, but there
are more hooks involved with window size/config changes in Emacs
27 and I haven't looked into which ones I should use.
`visual-fill-column--adjust-window` does the following:
```
(defun visual-fill-column--adjust-window ()
"Adjust the window margins and fringes."
;; Only run when we're really looking at a buffer that has
v-f-c-mode enabled. See #22.
(when (buffer-local-value 'visual-fill-column-mode
(window-buffer (selected-window)))
(set-window-fringes (get-buffer-window (current-buffer)) nil
nil visual-fill-column-fringes-outside-margins)
(if (>= emacs-major-version 25)
(set-window-parameter (get-buffer-window (current-buffer))
'split-window #'visual-fill-column-split-window))
(visual-fill-column--set-margins)))
```
So it has additional code for Emacs >= 25 to set the window
parameter `split-window` to `visual-fill-column-split-window`,
which unsets the margins before calling `split-window`.
In addition, there is a function
`visual-fill-column-split-window-sensibly`, which can be used as
the value of `split-window-preferred-function`. It handles virtual
splitting of windows with wide margins.
HTH
--
Joost Kremers
Life has its moments
next prev parent reply other threads:[~2019-05-14 16:05 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 8:32 Adding olivetti to GNU ELPA Paul W. Rankin
2019-04-25 8:56 ` Eli Zaretskii
2019-04-25 12:32 ` Paul W. Rankin
2019-04-25 12:43 ` Eli Zaretskii
2019-04-25 13:01 ` Paul W. Rankin
2019-04-25 14:30 ` Eli Zaretskii
2019-05-08 4:07 ` Paul W. Rankin
2019-05-08 6:20 ` Eli Zaretskii
2019-05-09 6:54 ` Paul W. Rankin
2019-05-09 7:53 ` Eli Zaretskii
2019-05-09 8:14 ` martin rudalics
2019-05-09 13:30 ` Stefan Monnier
2019-05-10 8:00 ` martin rudalics
2019-05-14 5:16 ` Paul W. Rankin
2019-05-14 7:04 ` Paul W. Rankin
2019-05-14 12:22 ` Stefan Monnier
2019-05-15 8:26 ` Paul W. Rankin
2019-05-14 16:05 ` Joost Kremers [this message]
2019-05-14 16:50 ` Stefan Monnier
2019-05-14 21:56 ` Joost Kremers
2019-05-15 1:29 ` Stefan Monnier
2019-05-20 8:24 ` martin rudalics
2019-05-20 13:14 ` Paul W. Rankin
2019-05-21 7:32 ` martin rudalics
2019-05-21 7:38 ` Paul W. Rankin
2019-05-21 7:45 ` martin rudalics
2019-05-21 9:05 ` Paul W. Rankin
2019-05-21 10:04 ` martin rudalics
2019-05-22 1:47 ` Paul W. Rankin
2019-05-22 8:32 ` martin rudalics
2019-05-22 9:14 ` Paul W. Rankin
2019-05-08 14:07 ` Stefan Monnier
2019-05-08 15:45 ` Stephen Leake
2019-05-08 17:50 ` Eli Zaretskii
2019-04-26 1:17 ` Richard Stallman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877eat58ec.fsf@fastmail.fm \
--to=joostkremers@fastmail.fm \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rudalics@gmx.at \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).