Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ If you want the echo-area hints, turn on =popper-echo-mode=.
:bind (("C-`" . popper-toggle)
("M-`" . popper-cycle)
("C-M-`" . popper-toggle-type))
:custom
(popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
"\\*Async Shell Command\\*"
help-mode
compilation-mode))
:init
(setq popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
"\\*Async Shell Command\\*"
help-mode
compilation-mode))
(popper-mode +1)
(popper-echo-mode +1)) ; For echo area hints
#+END_SRC
Expand All @@ -111,13 +112,13 @@ See the Customization section for details on specifying buffer types as popups.
** Without =use-package=
#+BEGIN_SRC emacs-lisp
(require 'popper)
(setq popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
"\\*Async Shell Command\\*"
help-mode
compilation-mode))
(global-set-key (kbd "C-`") 'popper-toggle)
(setopt popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
"\\*Async Shell Command\\*"
help-mode
compilation-mode))
(global-set-key (kbd "C-`") 'popper-toggle)
(global-set-key (kbd "M-`") 'popper-cycle)
(global-set-key (kbd "C-M-`") 'popper-toggle-type)
(popper-mode +1)
Expand All @@ -139,11 +140,11 @@ To get started, customize this variable:
Example:

#+BEGIN_SRC emacs-lisp
(setq popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
help-mode
compilation-mode))
(setopt popper-reference-buffers
'("\\*Messages\\*"
"Output\\*$"
help-mode
compilation-mode))
#+END_SRC

Will treat the following as popups: The Messages buffer, any buffer ending in "Output*", and all help and compilation buffers.
Expand All @@ -152,25 +153,25 @@ To get started, customize this variable:

#+BEGIN_SRC emacs-lisp
;; 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
)))
(setopt 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
)))
#+END_SRC

As of v0.40, Popper also supports classifying a buffer as a popup based on any user supplied predicate. This predicate (function) is called with the buffer as argument and returns =t= if it should be considered a popup. Here is an example with a predicate:

#+BEGIN_SRC emacs-lisp
(setq popper-reference-buffers
'("\\*Messages\\*"
help-mode
(lambda (buf) (with-current-buffer buf
(and (derived-mode-p 'fundamental-mode)
(< (count-lines (point-min) (point-max))
10)))))))
(setopt popper-reference-buffers
'("\\*Messages\\*"
help-mode
(lambda (buf) (with-current-buffer buf
(and (derived-mode-p 'fundamental-mode)
(< (count-lines (point-min) (point-max))
10)))))))
#+END_SRC

This list includes the the Messages and =help-mode= buffers from before, along with a predicate: any buffer derived from the major mode =fundamental-mode= that has fewer than 10 lines will be considered a popup.
Expand Down Expand Up @@ -265,11 +266,11 @@ This is generally useful to keep buffers that are created as a side effect from
To specify popups to auto-hide, use a cons cell with the =hide= symbol when specifying =popup-reference-buffers=:

#+begin_src emacs-lisp
(setq popper-reference-buffers
'(("Output\\*$" . hide)
(completion-list-mode . hide)
occur-mode
"\\*Messages\\*"))
(setopt popper-reference-buffers
'(("Output\\*$" . hide)
(completion-list-mode . hide)
occur-mode
"\\*Messages\\*"))
#+end_src

This assignment will suppress all buffers ending in =Output*= and the Completions buffer. The other entries are treated as normal popups.
Expand Down
27 changes: 17 additions & 10 deletions popper.el
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ buffers will be suppressed when they are first created."
(cons (choice (regexp :tag "Buffer name regexp")
(symbol :tag "Major mode")
(function :tag "Predicate function"))
(const :tag "Hide" hide)))))
(const :tag "Hide" hide))))
:set (lambda (sym val)
(set-default sym val)
(when (bound-and-true-p popper-mode)
(popper--set-reference-vars)
(popper--find-buried-popups)
(popper--update-popups))))

(defcustom popper-mode-line '(:eval (propertize " POP" 'face 'mode-line-emphasis))
"String or sexp to show in the mode-line of popper.
Expand Down Expand Up @@ -657,7 +663,14 @@ This should run after `popper--update-popups' in
(popper--update-popups))))

(defun popper--set-reference-vars ()
"Unpack `popper-reference-buffers' to set popper--reference- variables."
"Unpack `popper-reference-buffers' to set popper--reference- variables.
Clears existing values first, making it safe to call repeatedly."
(setq popper--reference-names nil
popper--reference-modes nil
popper--reference-predicates nil
popper--suppressed-names nil
popper--suppressed-modes nil
popper--suppressed-predicates nil)
(cl-labels ((popper--classify-type
(elm) (pcase-exhaustive elm
((pred stringp) 'name)
Expand Down Expand Up @@ -715,15 +728,9 @@ types as popups."
(cl-loop for (_ . win-buf-alist) in popper-buried-popup-alist do
(popper--restore-mode-lines win-buf-alist))
(popper--restore-mode-lines popper-open-popup-alist)
;; TODO: Clean this up
(setq popper-buried-popup-alist nil
popper-open-popup-alist nil
popper--reference-names nil
popper--reference-modes nil
popper--reference-predicates nil
popper--suppressed-names nil
popper--suppressed-modes nil
popper--suppressed-predicates nil)
popper-open-popup-alist nil)
(popper--set-reference-vars)
(setq display-buffer-alist
(cl-remove 'popper-display-control-p
display-buffer-alist
Expand Down