bmag / emacs-purpose

Manage Windows and Buffers According to Purposes
GNU General Public License v3.0
498 stars 23 forks source link

Delete popup windows when no longer displaying popup buffer #154

Closed Zulu-Inuoe closed 3 years ago

Zulu-Inuoe commented 5 years ago

Fixes #153

This is a bit of a hacky workaround for the behaviour of quit-window. When we reuse a popup window to display some other popup buffer, and then we quit from that buffer via (quit-window t) or the like, we will be back at our previous popup buffer, and have our quit-restore parameter set to nil.

Unfortunately then, quit-window once more will cause the window to display a random buffer because when quit-restore is nil, quit-window will not actually kill the window because ????

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-64.2%) to 5.804% when pulling 8149459a8d38af179812fe647c7c0c512c65eaa3 on Zulu-Inuoe:fix-reusing-popwin into fb649bb07de63a70ecdace464eadcaafe01e1995 on bmag:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.5%) to 69.442% when pulling d73ec242e5923f9e4ab16d953c2e70c86884c4a3 on Zulu-Inuoe:fix-reusing-popwin into fb649bb07de63a70ecdace464eadcaafe01e1995 on bmag:master.

mfiano commented 5 years ago

Thanks for fixing this. One of my biggest complaints with purpose.

Zulu-Inuoe commented 5 years ago

I see from the tests now that there's errors due to usage of pushnew and some other things. I'll get to work fixing those.

Sorry about the trouble

wyuenho commented 4 years ago

I have something similar that's much simpler to deal with this problem.

(defun purpose-quit-restore-window-advice (orig-func &optional window bury-or-kill)
    (let* ((window (window-normalize-window window t))
           (quit-restore (window-parameter window 'quit-restore)))
      (funcall orig-func window bury-or-kill)
      (when (and (null quit-restore) (window-parent window))
        (ignore-errors (delete-window window)))))
(advice-add 'quit-restore-window :around 'purpose-quit-restore-window-advice)

Works pretty well for the couple of months since I've figured this out. Maybe when the popwin extension is enabled, we could install this advice to quit-restore-window, and uninstall when disabling.

wyuenho commented 3 years ago

Superceded by #177