emacs-devel
[Top][All Lists]
Advanced

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

Re: Adding olivetti to GNU ELPA


From: Paul W. Rankin
Subject: Re: Adding olivetti to GNU ELPA
Date: Thu, 09 May 2019 16:54:48 +1000
User-agent: mu4e 1.2.0; emacs 26.2


On Wed, May 08 2019, Eli Zaretskii wrote:

From: "Paul W. Rankin" <address@hidden>
Cc: address@hidden
Date: Wed, 08 May 2019 14:07:24 +1000

I'm sorry to say but this goes a bit over my head... From Emacs 24 - 27 there seem to be three hooks that have shifting/overlapping capabilities. The hooks are:

- window-configuration-change-hook
- post-command-hook
- window-size-change-functions

When I first created the minor mode, window-configuration-change-hook was enough for all situations I encountered.

I agree that we have a royal mess with these hooks.  And if you think
the above 3 are all of it, then, unfortunately, they aren't: there are
also pre-redisplay-functions and window-scroll-functions -- those may
be necessary if your mode needs to pay attention to when the screen
space used by line numbers changes, either because the buffer is
scrolled past the point where the line numbers need more or less
digits than before, or because the user customizes the line-number
face in a way which changes the font used by the face, with your mode
already active.

I'd like to try to help you, but I'm not sure I understand the problem
well enough.  Are you asking whether what you did could be simplified
by using less hooks?  Or are you saying that the current code doesn't
yet handle well some situations?  In the latter case, could you please
describe those problematic situations?

I think there are three separate but perhaps related problems. At its most basic, olivetti is really just a single main function, which could be distilled to:

   (set-window-margins
     (current-window) (/ 2 (- (window-width) olivetti-body-width)))

There are some other ancillary functions, but really it's just a case of running this function in all windows displaying the current buffer when olivetti-body-width changes or when the window width changes.

For compatibility with changes in Emacs 25.x, we also reset the margins to 0 before any window splitting, to prevent the combined window width being too large to split.

So the three problems I'm running into are:

1. Some users have complained of lagging input, which seems to be due to olivetti setting the margins too often, i.e. on too many hooks. So using the minimal number of hooks is preferable.

2. But I've experienced olivetti failing to set the margins during a few common cases, e.g.:
 - splitting window with icomplete "*Completions*" buffer
 - splitting window with ispell-word "*Choices*" buffer
 - splitting window with magit-status
- splitting window vertically with any buffers in a side-window in the same frame (which results in window being too large to split -- I think this is a separate issue)

It would be nice to achieve consistency with these.

3. Issues scrolling with display-line-numbers-mode, but I don't mind about this.

I *think* what is needed is a way to apply the hooks contingent on emacs-major-version <= 24 and <= 25 or 26(?) and <= 27.

Yes, and there's nothing wrong with that for a package that wants to
support multiple Emacs versions.

My difficulty is that I don't understand enough how these hooks have changed from 24 -> 27. Stefan tried to explain it to me, but... I still didn't get it :(

--
https://www.paulwrankin.com



reply via email to

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