bmag / emacs-purpose

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

Fix recursion in debug advice #184

Closed bmag closed 3 years ago

bmag commented 3 years ago

As reported in https://github.com/bmag/emacs-purpose/pull/182#issuecomment-812232912, there seemed to be some recursion caused by using cl-letf. Should be fixed by using cl-flet.

After invoking the debugger (i.e., M-x toggle-debug-on-entry RET beginning-of-buffer RET followed by M-x beginning-of-buffer RET), repeatedly stepping through (by pressing d) would recurse into our advice every time. I wasn't able to recreate the same recursion (with other test functions) outside of the debugger environment, so there is probably be another mysterious factor in the debugger that triggers the recursion.

wyuenho commented 3 years ago

This unfortunately doesn't work for my use case as we are back to pop-to-buffer not being able to pick a window wide enough again. Judging from the different heights of the windows in every invocation of debug, I don't think this advice has any effect whatsoever. With that said, I think it's best to revert #182 for now. I've since discovered that although it can hand control to purpose to pick a window, it doesn't pick a frame, so if toggle-debug-on-error is turned on and an error is thrown inside a small child frame like those made by company-box, the backtrace buffer is still popped up inside that tiny child frame. Picking a right window from the right frame needs a re-think.

bmag commented 3 years ago

Ok, reverted (in https://github.com/bmag/emacs-purpose/commit/06f727ec1aba07c41cfa397e8f08bca8c29d970d)