Using popper independently per frame
Hi, I'm seeing some odd behavior that is preventing me from being able to reliably toggle popper across frames using popper-toggle (without the workaround below).
If I hop between frames and run M-x popper-toggle then popper will, as expected, toggle the popup window for the current frame. However, if I bind popper-toggle to a keybinding then I don't get the same results. I suspect that by switching frame and invoking a keybinding (rather than M-x popper-toggle) that popper--update-popups is not called and so popper-open-popup-alist is not updated.
As a workaround, I've added the following to my config to ensure the popper-open-popup-alist is up to date prior to toggling:
(advice-add #'popper-toggle :before (lambda (&rest _) (popper--update-popups)))
This line stood out to me as a potential cause for this behavior as select-frame-hook does not exist for me (currently on Emacs 30):
(add-hook 'select-frame-hook #'popper--update-popups)
This line stood out to me as a potential cause for this behavior as select-frame-hook does not exist for me (currently on Emacs 30):
Huh, it looks like select-frame-hook is gone from Emacs 29.3 as well. There's no direct replacement, it looks like after-focus-change-function is the closest but this is pretty complex, it's not a hook.
When I did a quick search, it seemed that select-frame-hook was an XEmacs thing. I couldn't see any evidence of it existing in Emacs. This comment seems to back that up.
I'm quite new to Emacs Lisp, but I seem to have hit the same problem. I'm trying to customize popper-display-function to make the pop-ups show up in a floating posframe. I found the "POP" in the mode-line in the posframe upon running popper-toggle, but running it again spawns a nested posframe instead of closing the already open pop-up. This seems to be because popper-open-popup-alist is not updated.
FWIW here's the display function I'm using (It's most probably very broken):
(defun my-popper-display-buffer-in-posframe (buf &optional alist)
"Display BUFFER in a posframe. ALIST is ignored."
(posframe-show buf
:poshandler #'posframe-poshandler-frame-center
:width (floor (* (frame-width) 0.8))
:height (floor (* (frame-height) 0.8))
:internal-border-width 1
:internal-border-color "gray50"
:accept-focus t
:cursor 'bar
:respect-mode-line t)
(with-current-buffer buf
(setq-local popper-popup-status 'popup)
;; Return window for popper's reference
(let* ((win (frame-selected-window (buffer-local-value 'posframe--frame buf))))
(select-window win)
win)))
I'm quite new to Emacs Lisp, but I seem to have hit the same problem. I'm trying to customize
popper-display-functionto make the pop-ups show up in a floating posframe. I found the "POP" in the mode-line in the posframe upon runningpopper-toggle, but running it again spawns a nested posframe instead of closing the already open pop-up. This seems to be becausepopper-open-popup-alistis not updated.
Using popper with childframes is tricky. It used to work, but I haven't tried in a couple of years. I think you need to find an appropriate hook in which to run popper--update-popups -- I'm not sure which hook that should be. Your display function looks fine at first glance.
I'm quite new to Emacs Lisp, but I seem to have hit the same problem. I'm trying to customize
popper-display-functionto make the pop-ups show up in a floating posframe. I found the "POP" in the mode-line in the posframe upon runningpopper-toggle, but running it again spawns a nested posframe instead of closing the already open pop-up. This seems to be becausepopper-open-popup-alistis not updated.
Using popper with childframes can be tricky and not fully tested. I'll try to take a look at the code carefully when I have time.