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

Disabled delete-other-window #2

Open
holgerschurig opened this issue Jul 6, 2023 · 2 comments
Open

Disabled delete-other-window #2

holgerschurig opened this issue Jul 6, 2023 · 2 comments

Comments

@holgerschurig
Copy link

Hi FrostyX,

Yesterday I installed your package and like it so far. I however noted that you add an advice to simply override delete-other-window. Which is bound to M-x 1.

This is very unfortunate, because SOMETIMES I deliberately want to windows and later delete them again. I even bound this to my F5 key:

(defun my-explode-window ()
  "If there is only one window displayed, act like C-x2. If there
are two windows displayed, act like C-x1:"
  (interactive)
  (if (one-window-p t)
      (progn
        (split-window-vertically)
        (other-window 1)
        (my-zoom-next-buffer2)
        (other-window -1))
    (delete-other-windows)))

Can you perhaps do this trick:

  • advice org-agenda & org-capture with an before and after form
  • the before form adds your advice that makes delete-other-window a no-op
  • the after form removes your advice to delete-other-window

This would have the effect that for these both org features, delete-other-window would be "gone". But for the rest of Emacs, not so much.

@holgerschurig
Copy link
Author

Addendum: this advice with before and after might not be possible, what you would need is some buffer-local advice (local to the org-agenda).

If you look up advice-add, you see that it used add-function. And add-function in turn has this helptext snippet:

If PLACE is a symbol, its default-value will be affected.
Use (local 'SYMBOL) if you want to apply FUNCTION to SYMBOL buffer-locally.

And I think advice-add will inherit this. So maybe you somehow can advice-add away delete-other-window while the org-agenda buffer is already shown? With a buffer-local advice? That would delete the function there, but not everywhere if I'm not mistaken.

@FrostyX
Copy link
Owner

FrostyX commented Jul 6, 2023

Thank you for the feedback @holgerschurig and for the suggestions on how to fix the issue. Much appreciated.
The solution sounds quite complicated and I don't know if I will be able to implement it. Please feel free to send a PR.

As a workaround, maybe you can define something like

(defun delete-other-windows-unadvised ()
  (advice-remove 'delete-other-windows nil)
  (delete-other-windows)
  (advice-add
   'delete-other-windows
   :override #'current-window-only--delete-other-windows))

and then call it from your custom function instead of delete-other-windows?

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

No branches or pull requests

2 participants