doomemacs / doomemacs/core

+popup/raise with a prefix raises popup into a... popup

Open
#6,294 1 comment 0 reactions 0 assignees View on GitHub
is:bug needs-triage
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### What did you expect to happen?

With a single non-popup window and a popup window, `C-u +popup/raise` splits the frame into two non-popup windows. The second window displays the buffer from the deleted popup window.

### What actually happened?

The popup window is deleted, then replaced with an identical popup window. In other words, nothing changes.

### Describe your attempts to resolve the issue

I modified `+popup/diagnose` to return the relevant element of `display-buffer-alist` instead of using it in a message:

```
(defun +popup/diagnose2 ()
"Reveal what popup rule will be used for the current buffer."
(if-let (rule (cl-loop with bname = (buffer-name)
for (pred . action) in display-buffer-alist
if (and (functionp pred) (funcall pred bname action))
return (cons pred action)
else if (and (stringp pred) (string-match-p pred bname))
return (cons pred action)))
rule
nil))
```
Using the above, I modified `+popup/raise` to temporarily remove this element from `display-buffer-alist` before `+popup/close` and `pop-to-buffer` are called:

```
(defun +popup/raise (window &optional arg)
"Raise the current popup window into a regular window and
return it. If prefix ARG, raise the current popup into a new
window and return that window."
(interactive
(list (selected-window) current-prefix-arg))
(cl-check-type window window)
(unless (+popup-window-p window)
(user-error "Cannot raise a non-popup window"))
(let ((buffer (current-buffer))
(display-buffer-alist (remove (+popup/diagnose2) display-buffer-alist))
(+popup--inhibit-transient t)
+popup--remember-last)
(+popup/close window 'force)
(if arg
(pop-to-buffer buffer)
(switch-to-buffer buffer))
(selected-window)))
```
Et voila!

### Steps to reproduce

1. Enable the +popup module and `doom sync`.
2. Open Emacs with a single window.
3. Open any popup.
4. Select the popup window.
5. C-u +popup/raise.

### System Information

https://pastebin.com/h0FMwPrv

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.