Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better integration of window manipulation commands #1130

Merged
merged 2 commits into from Dec 30, 2019

Conversation

nnicandro
Copy link
Contributor

Commands like evil-window-rotate-upwards and evil-window-move-very-top only
consider the buffer in each window when manipulating the window tree, but if a
window has specific window properties that need to be maintained (like those in
window-persistent-parameters) that information is lost.

Refactor the window manipulation commands to use window-state-get and
window-state-put to retrieved and restore the state of the window tree so
that window properties in each window are maintained.

Also integrate the window manipulation commands with side windows, i.e. windows
with a non-nil window-side window parameter, by only manipulating the part of
the window tree that are not side windows.

  • Add the macro evil-save-side-windows which removes all side windows on
    entering the macro environment and restores the side windows leaving.

  • Add the function evil-move-window which does the work of
    evil-window-move-far-left, evil-window-move-very-top,
    evil-window-move-far-right, and evil-window-move-very-bottom. These
    functions were all identical, the only difference being which window was used
    to restore the selected-window.

  • Use window-state-(get|put) to get the window tree and to restore it. This
    makes evil-get-buffer-tree and evil-restore-window-tree unnecessary and
    they are removed. Note that window-state-(get|put) also handles window
    parameters.

  • In addition to ignoring side windows when moving a window, ignore them in
    evil-window-rotate-downwards and evil-window-rotate-upwards.

evil-commands.el Outdated
(window-toggle-side-windows))
,@body
(when ,sides
(window-toggle-side-windows)))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this macro use a condition-case block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup your right there does need to be some error handling.

Commands like `evil-window-rotate-upwards` and `evil-window-move-very-top` only
consider the buffer in each window when manipulating the window tree, but if a
window has specific window properties that need to be maintained (like those in
`window-persistent-parameters`) that information is lost.

Refactor the window manipulation commands to use `window-state-get` and
`window-state-put` to retrieved and restore the state of the window tree so
that window properties in each window are maintained.

Also, integrate the window manipulation commands with side windows, i.e. windows
with a non-nil `window-side` window parameter, by only manipulating the part of
the window tree that are not side windows.

* Add the macro `evil-save-side-windows` which removes all side windows on
  entering the macro environment and restores the side windows leaving.

* Add the function `evil-move-window` which does the work of
  `evil-window-move-far-left`, `evil-window-move-very-top`,
  `evil-window-move-far-right`, and `evil-window-move-very-bottom`. These
  functions were all identical, the only difference being which window was used
  to restore the `selected-window`.

* Use `window-state-(get|put)` to get the window tree and to restore it. This
  makes `evil-get-buffer-tree` and `evil-restore-window-tree` unnecessary and
  they are removed. Note that `window-state-(get|put)` also handles window
  parameters.

* In addition to ignoring side windows when moving a window, ignore them in
  `evil-window-rotate-downwards` and `evil-window-rotate-upwards`.
@TheBB
Copy link
Member

TheBB commented Dec 20, 2019

Thanks! I rebased this on master and the tests seem to pass fine.

I'm assuming this is needed for your jumplist refactoring work? Would you be willing to PR that at some point?

Will probably merge this soon.

@TheBB TheBB merged commit 30e951f into emacs-evil:master Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants