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

How to open scratch buffer as a popper popup? #36

Open
apoorv569 opened this issue Jun 27, 2022 · 14 comments
Open

How to open scratch buffer as a popper popup? #36

apoorv569 opened this issue Jun 27, 2022 · 14 comments

Comments

@apoorv569
Copy link

I am trying to have my scratch buffer as a popup window, kind of like how Doom Emacs does it. I added this,

  (setq popper-reference-buffers
        (append popper-reference-buffers
                  "^\\*scratch.*\\*$"               initial-major-mode)))     ;scratch buffer as a popup

The scratch buffer does open as a popup, but it doesn't go on the bottom as other popups, instead it opens full screen as a normal buffer.

@karthink
Copy link
Owner

Does it behave as expected (popup at the bottom) after Emacs is done booting up?

@apoorv569
Copy link
Author

Does it behave as expected (popup at the bottom) after Emacs is done booting up?

No, it opens full screen only.

@karthink
Copy link
Owner

karthink commented Jun 28, 2022 via email

@apoorv569
Copy link
Author

I don't follow, so let me clarify my question.

When you boot up Emacs, it's recognized as a popup but it still opens full screen.

Yes.

  1. What happens when you then call popper-toggle-latest? Does the scratch buffer disappear?

If I call popper-toggle-latest the scratch buffer appears on bottom as expected, but I can't close it by pressing q it starts recording macro as I use evil-mode.

  1. What happens when you call popper-toggle-latest again? Does the scratch buffer appear full screen, or in a regular window split, or as a popup at the bottom?

If I call popper-toggle-latest again, it hides/shows the buffer on bottom as expected.

  1. How about on all subsequent calls to popper-toggle-latest or popper-cycle?

Subsequent calls to popper-toggle-latest and/or popper-cycle seems to be working as expected.

I use the dashboard package so my Emacs doesn't open scratch buffer by default on startup, but I think it appears full screen if opened by switch-to-buffer, persp-switch-to-scratch-buffer etc, as there is no other way to open the scratch buffer.

@karthink
Copy link
Owner

karthink commented Jun 28, 2022

Sorry, I still don't understand the problem well.

I use the dashboard package so my Emacs doesn't open scratch buffer by
default on startup

If Emacs doesn't open the scratch buffer by default, and calls to popper-toggle-latest open the scratch buffer at the bottom as expected, what do you mean by

The scratch buffer does open as a popup, but it doesn't go on the bottom as other popups, instead it opens full screen as a normal buffer.

When you boot up Emacs, it's recognized as a popup but it still opens full
screen.

Yes.

I'm trying to figure out what the intended behavior should be when Emacs boots up.

...it appears full screen if opened by switch-to-buffer, persp-switch-to-scratch-buffer etc,

Okay, this makes sense. switch-to-buffer and co bypass the whole display-buffer rules system used to govern how and where windows open. Thus switch-to-buffer will always open a buffer in the window where it's called. It's possible to override this but Popper doesn't do this intentionally. If it did you would have no way of opening a popup buffer in a regular window. Not even with C-x 1 (or the evil-mode version C-w o), at least with Popper's default settings. Doom Emacs' popup system also does not override switch-to-buffer's behavior, possibly for similar reasons..

If you want to change this, you can try setting the window option switch-to-buffer-obey-display-actions.

as there is no other way to open the scratch buffer.

There are many other ways to open the scratch buffer:

  1. Call popper-toggle-latest or popper-cycle
  2. Call display-buffer, bound to C-x 4 C-o by default. Not sure if there's an evil-mode binding too.
  3. Call pop-to-buffer

All of these will open it while obeying the display rules set in your display-buffer-alist, or your shackle configuration, or by popper.

@apoorv569
Copy link
Author

When I first launch Emacs, popper-toggle-latest or popper-cycle doesn't have scratch buffer as a option, I first have to switch to or open scratch buffer manually, then only I can use popper functions. I think the confusion was because I was using switch-to-buffer and all which does opens a buffer full screen.

@karthink
Copy link
Owner

I see. Can you try the following:

  1. Launch Emacs
  2. M-x eval-expression: popper-buried-popup-alist
  3. Turn popper mode off and on.
  4. M-x eval-expression: popper-buried-popup-alist

@apoorv569
Copy link
Author

I see. Can you try the following:

1. Launch Emacs

2. `M-x eval-expression`: `popper-buried-popup-alist`

3. Turn popper mode off and on.

4. `M-x eval-expression`: `popper-buried-popup-alist`

OK, first I time I called popper-buried-popup-alist scratch buffer was not in the list, but after toggling it off then on, scratch buffer was in the list.

From *Messages* buffer.

((nil (nil . #<buffer *Messages*>)))
Popper mode disabled
Popper mode enabled
((nil (nil . #<buffer *Messages*>) (nil . #<buffer *scratch*>)))

@karthink
Copy link
Owner

I can't reproduce this. Can you paste your popper-mode config here?

@apoorv569
Copy link
Author

I can't reproduce this. Can you paste your popper-mode config here?

Sure,

  (use-package popper
  :straight t ; or :straight t
  :bind (("C-`"   . popper-toggle-latest)
         ("M-`"   . popper-cycle)
         ("C-M-`" . popper-toggle-type))
  :init
  (setq popper-reference-buffers
        '("\\*Messages\\*"
          "\\*Warnings\\*"
          "Output\\*$"
          "\\*Async Shell Command\\*"
          help-mode
          compilation-mode))
  ;; Match eshell, shell, term and/or vterm buffers
  (setq popper-reference-buffers
        (append popper-reference-buffers
                '("^\\*eshell.*\\*$"                eshell-mode               ;eshell as a popup
                  "^\\*shell.*\\*$"                 shell-mode                ;shell as a popup
                  "^\\*term.*\\*$"                  term-mode                 ;term as a popup
                  "^\\*vterm.*\\*$"                 vterm-mode                ;vterm as a popup
                  "^\\*flycheck-list-errors.*\\*$"  flycheck-error-list-mode  ;flycheck error list as a popup
                  "^\\*ibuffer.*\\*$"               ibuffer-mode              ;ibuffer as a popup
                  "^\\*helpful-comand.*\\*$"        helpful-mode              ;helpful command as a popup
                  "^\\*helpful-variable.*\\*$"      helpful-mode              ;helpful variable as a popup
                  "^\\*helpful-callable.*\\*$"      helpful-mode              ;helpful callable as a popup
                  "^\\*scratch.*\\*$"               initial-major-mode)))     ;scratch buffer as a popup
  (setq popper-window-height 15)
  (setq popper-mode-line '(:eval (propertize " POP " 'face 'mode-line-emphasis)))
  (popper-mode +1)
  (popper-echo-mode +1))                ; For echo area hints

@karthink
Copy link
Owner

karthink commented Jul 1, 2022

This looks fine. Do you use anything besides the dashboard package that influences the Emacs' startup? I'll try installing them.

@apoorv569
Copy link
Author

This looks fine. Do you use anything besides the dashboard package that influences the Emacs' startup? I'll try installing them.

Note sure.. But here is my entire config https://gitlab.com/apoorv569/dotfiles/-/blob/master/.emacs.d/Emacs.org

karthink added a commit that referenced this issue Jul 9, 2022
Note: This problem is caused by Emacs' startup customizations not triggering
`window-configuration-change-hook`, leading to buffers missing Popper's net and
fail to be classified as popups. The hacky solution (until I can think of a
better way) is to schedule `popper--find-buried-popups` after Emacs' init
process.
@karthink
Copy link
Owner

karthink commented Jul 9, 2022

Thanks @apoorv569, that's helpful.

I've pushed a fix on the catch-init branch of this repo. Since you're using straight, can you switch to it and test?

recipe:

(use-package popper
  :straight (:host github :repo "karthink/popper"
             :branch "catch-init")
  ;; Rest of the config
  )

Specifically, I'd like to know if you notice any lag immediately after Emacs boots up.


Notes:

This problem is caused by Emacs' startup customizations not triggering window-configuration-change-hook when burying/showing buffers, leading to buffers missing Popper's net and failing to be classified as popups. The hacky solution (until I can think of a better way) is to schedule popper--find-buried-popups to recast the net after Emacs' init process.

@apoorv569
Copy link
Author

apoorv569 commented Jul 12, 2022

Thanks @apoorv569, that's helpful.

I've pushed a fix on the catch-init branch of this repo. Since you're using straight, can you switch to it and test?

recipe:

(use-package popper
  :straight (:host github :repo "karthink/popper"
             :branch "catch-init")
  ;; Rest of the config
  )

Specifically, I'd like to know if you notice any lag immediately after Emacs boots up.

Notes:

This problem is caused by Emacs' startup customizations not triggering window-configuration-change-hook when burying/showing buffers, leading to buffers missing Popper's net and failing to be classified as popups. The hacky solution (until I can think of a better way) is to schedule popper--find-buried-popups to recast the net after Emacs' init process.

I added the recipe, but I don't see any difference, I still can't find the scratch buffer in the popper list.

I didn't notice lag after Emacs boots up.

EDIT:
After launching Emacs 4-5 times, I start to see the scratch buffer in the popper list. I think this works.

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