all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andrea Cardaci <cyrus.and@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Zoom: a window management minor mode -- best practices and questions
Date: Wed, 2 May 2018 20:41:38 +0200	[thread overview]
Message-ID: <CACMsj9N_1NhujXZ5r6kAxm6X+4bOTnpjroD2wHaw5jG5vtEFvw@mail.gmail.com> (raw)
In-Reply-To: <83muxioten.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3863 bytes --]

Thanks for the answer.

> I understand why you need to hook select-window, but not why you need
> the other hook.  Is it because there are too many functions that could
> modify the window size, and you didn't want to hook all of them?

The handler should be triggered in these cases:
- a window is resized;
- a window is selected;
- a window is created (this is actually included in the "a window is resized"
case);
- a window changes its buffer (because it's possible to exclude certain
windows from zooming so the layout should be updated accordingly).

So yes, instead of trying to figure out what the functions that cause such
events are (probably way too many) I simply tried to hook on the effects of
such actions.

> Did you try to use pre-redisplay-functions instead?

Not yet, but a quick test shows that it gets called *very* often, even when
Emacs is idle. I should really implement some additional guard if I decide
to go that way to avoid incurring in performance issues.

Also it seems to not work well with the `track-mouse` variable that I use
to delay the re-layout if there is some mouse selection in progress.

Besides, doesn't this in principle suffer of the same
do-something-that-triggers-the-hook-inside-such-hook problem like
`window-size-change-functions`?

> Alternatively, we could provide some control to disable resizing of
> the selected window

Please elaborate on this point. How can it help this situation?

On 2 May 2018 at 19:32, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Andrea Cardaci <cyrus.and@gmail.com>
> > Date: Wed, 2 May 2018 18:31:11 +0200
> > Cc: Eli Zaretskii <eliz@gnu.org>
> >
> > Zoom (https://github.com/cyrus-and/zoom) aims to enforce a fixed window
> layout so that the selected window
> > is always *big enough*. I think the screencast at the project page is
> quite clear about the usage.
>
> I've seen the screencast before asking the question, but couldn't
> grasp the intent well enough, probably because the display in
> screencast switches windows too quickly, and it's hard to understand
> what Zoom attempts to do.
>
> > The implementation is very simple, every time a window change is
> *detected* the following happens:
> > 1. `balance-windows` is called;
> > 2. the selected window is resized.
> >
> > This, in practice, has the effect of disabling the manual resizing of
> windows.
> >
> > The problem is that to implement the "every time a window change is
> detected" part I currently hook several
> > functions, specifically:
> >
> >     (add-hook 'window-size-change-functions #'zoom--handler)
> >     (advice-add #'select-window :after #'zoom--handler)
>
> I understand why you need to hook select-window, but not why you need
> the other hook.  Is it because there are too many functions that could
> modify the window size, and you didn't want to hook all of them?
>
> Did you try to use pre-redisplay-functions instead?  That doesn't
> necessarily tell you that the selected window is going to change or
> its dimensions are about to change, but determining that for a single
> window shouldn't be too expensive, right?
>
> Alternatively, we could provide some control to disable resizing of
> the selected window -- would that be enough, in addition to hooking
> select-widnow using the method suggested by martin?
>
> > My knowledge of the Emacs internals is quite limited but at the highest
> level of abstraction what AFAIK is
> > missing is a way to enforce custom window layouts and manage the windows
> size. This part seems quite
> > fragile / extremely hard to work with (just look at the implementation
> of `balance-windows`). In addition to that
> > there are some features that further complicate the situation, e.g.,
> side windows and not resizable windows.
>
> Maybe Martin will suggest a good way of doing that using the existing
> facilities, if they are enough.
>

[-- Attachment #2: Type: text/html, Size: 5392 bytes --]

  reply	other threads:[~2018-05-02 18:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 16:31 Zoom: a window management minor mode -- best practices and questions Andrea Cardaci
2018-05-02 17:32 ` Eli Zaretskii
2018-05-02 18:41   ` Andrea Cardaci [this message]
2018-05-02 18:58     ` Eli Zaretskii
2018-05-03  7:11       ` martin rudalics
2018-05-03  9:50         ` Andrea Cardaci
2018-05-03  9:46       ` Andrea Cardaci
2018-05-03  7:11     ` martin rudalics
2018-05-03  9:47       ` Andrea Cardaci
2018-05-07 12:32         ` Andrea Cardaci
2018-05-07 18:19           ` Eli Zaretskii
2018-05-08 10:40             ` Andrea Cardaci
2018-05-08 14:53               ` Noam Postavsky
2018-05-08 15:03                 ` Andrea Cardaci
2018-05-09 12:33                 ` Stefan Monnier
2018-05-08 17:52               ` Eli Zaretskii
2018-05-09  7:00           ` martin rudalics
2018-05-09 16:06             ` Andrea Cardaci
2018-05-10  6:27               ` martin rudalics
2018-05-10 10:11                 ` Andrea Cardaci
2018-05-10 10:27                   ` martin rudalics
2018-05-10 10:34                     ` Andrea Cardaci
2018-05-10 10:37                       ` martin rudalics

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=CACMsj9N_1NhujXZ5r6kAxm6X+4bOTnpjroD2wHaw5jG5vtEFvw@mail.gmail.com \
    --to=cyrus.and@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@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.