[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding olivetti to GNU ELPA

From: Joost Kremers
Subject: Re: Adding olivetti to GNU ELPA
Date: Tue, 14 May 2019 18:05:15 +0200
User-agent: mu4e 1.3.2; emacs 26.2

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

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

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.


Joost Kremers
Life has its moments

reply via email to

[Prev in Thread] Current Thread [Next in Thread]