dotfiles/emacs-lisp/popper.org
Magic_RB f0d8a8f722
Disable motion-mode for popper windows
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2023-05-28 12:49:59 +02:00

2.7 KiB

Popper

#

Enable popper, a better version of popwin, which might actually work. It groups popups by context and allows you to specify their exact positioning, or even a custom display function. It also seems to be better at restoring the previous layout.

  (use-package popper
    :straight (popper :type git :host github :repo "karthink/popper")
    :config
    (setq popper-reference-buffers
          '("\\*Messages\\*"
            "\\*Warnings\\*"
            "\\*Error\\*"
            "Output\\*$"
            "\\*HS-Error\\*"
            "\\*lsp-help\\*"
            "^\\*Ement compose.*\\*$"
            haskell-interactive-mode
            help-mode
            compilation-mode
            rustic-compilation-mode
            tex-shell))
    (popper-mode +1))

Add a consult source for popped buffers.

    (with-eval-after-load 'consult
      (setq magic_rb/consult-source-popper
            `(:name "popper"
              :narrow ?P
              :category buffer
              :face     consult-buffer
              :history  buffer-name-history
              :state    consult--buffer-state
              :items
              (lambda ()
                (let ((group-name (when popper-group-function
                                    (with-current-buffer buf (funcall popper-group-function)))))
                  (mapcar #'buffer-name
                          (append
                           (mapcar #'cdr (alist-get group-name popper-buried-popup-alist))
                           (mapcar #'cdr (alist-get group-name popper-open-popup-alist))))))))

      (add-to-list 'consult-buffer-sources 'magic_rb/consult-source-popper 'append))

Force user buffer switching to also obey display-buffer-alist.

  (setq switch-to-buffer-obey-display-actions t)

Set almost all popups to meow-motion-mode, except for Org Mode popups and Vterm.

  (defun magic_rb/popper-meow-motion (buf &optional _act)
    (with-current-buffer buf
      (when
          (and (popper-popup-p buf)
               (not (equal major-mode 'vterm-mode))
               (not ement-room-compose-buffer))
        (meow-normal-mode) (meow-motion-mode))))

  (advice-add 'popper-display-control-p :after 'magic_rb/popper-meow-motion)