feature/popup: general refactor

This commit is contained in:
Henrik Lissner 2018-04-02 06:25:30 -04:00
parent cc658beb9e
commit 06acb2f3cf
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 50 additions and 49 deletions

View file

@ -1,6 +1,12 @@
;;; feature/popup/autoload.el -*- lexical-binding: t; -*-
(defvar +popup--populate-wparams (not EMACS26+))
(defvar +popup--inhibit-transient nil)
(defvar +popup--display-buffer-alist nil)
(defvar +popup--old-display-buffer-alist nil)
(defvar +popup--remember-last t)
(defvar +popup--last nil)
(defvar-local +popup--timer nil)
(defun +popup--remember (windows)
"Remember WINDOWS (a list of windows) for later restoration."
@ -175,11 +181,48 @@ Uses `shrink-window-if-larger-than-buffer'."
(unless (= (- (point-max) (point-min)) 0)
(shrink-window-if-larger-than-buffer window)))
;;;###autoload
(defun +popup-define (condition &optional alist parameters)
"Define a popup rule.
The buffers of new windows displayed by `pop-to-buffer' and `display-buffer'
will be tested against CONDITION, which is either a) a regexp string (which is
matched against the buffer's name) or b) a function that takes no arguments and
returns a boolean.
If CONDITION is met, the buffer will be displayed in a popup window with ALIST
and window PARAMETERS. See `display-buffer-alist' for details on what ALIST may
contain and `+popup-window-parameters' for what window parameters that the popup
module supports.
ALIST also supports the `size' parameter, which will be translated to
`window-width' or `window-height' depending on `side'.
If certain attributes/parameters are omitted, the ones from
`+popup-default-alist' and `+popup-default-parameters' will be used."
(declare (indent 1))
(push (if (eq alist :ignore)
(list condition nil)
`(,condition
(+popup-buffer)
,@alist
(window-parameters ,@parameters)))
+popup--display-buffer-alist))
;;
;; Minor mode
;;
;;;###autoload
(defvar +popup-mode-map (make-sparse-keymap)
"Active keymap in a session with the popup system enabled. See
`+popup-mode'.")
;;;###autoload
(defvar +popup-buffer-mode-map (make-sparse-keymap)
"Active keymap in popup windows. See `+popup-buffer-mode'.")
;;;###autoload
(define-minor-mode +popup-mode
"Global minor mode for popups."