Move feature/popup => ui/popup

And move settings to ui/popup/init.el
This commit is contained in:
Henrik Lissner 2018-05-14 01:20:53 +02:00
parent 40bd1da5a5
commit 83118dc65c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
6 changed files with 68 additions and 67 deletions

View file

@ -2,9 +2,6 @@
;; Copy me to ~/.doom.d/init.el or ~/.config/doom/init.el, then edit me!
(doom! :feature
(popup ; tame sudden yet inevitable temporary windows
+all ; catch all popups that start with an asterix
+defaults) ; default popup rules
;debugger ; FIXME stepping through code, to help you add bugs
eval ; run code, run (also, repls)
(evil +everywhere); come to the dark side, we have cookies
@ -30,6 +27,9 @@
+childframe) ; uses childframes for popups (Emacs 26+ only)
:ui
(popup ; tame sudden yet inevitable temporary windows
+all ; catch all popups that start with an asterix
+defaults) ; default popup rules
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
doom-modeline ; a snazzy Atom-inspired mode-line

View file

@ -1,4 +1,4 @@
;;; feature/popup/+hacks.el -*- lexical-binding: t; -*-
;;; ui/popup/+hacks.el -*- lexical-binding: t; -*-
;; What follows are all the hacks needed to get various parts of Emacs and other
;; plugins to cooperate with the popup management system. Essentially, it comes

View file

@ -1,9 +1,8 @@
;;; feature/popup/autoload.el -*- lexical-binding: t; -*-
;;; ui/popup/autoload.el -*- lexical-binding: t; -*-
(defvar +popup--populate-wparams (not EMACS26+))
(defvar +popup--inhibit-transient nil)
(defvar +popup--inhibit-select nil)
(defvar +popup--display-buffer-alist nil)
(defvar +popup--old-display-buffer-alist nil)
(defvar +popup--remember-last t)
(defvar +popup--last nil)
@ -183,34 +182,6 @@ 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

View file

@ -1,9 +1,9 @@
;;; feature/popup/config.el -*- lexical-binding: t; -*-
;;; ui/popup/config.el -*- lexical-binding: t; -*-
(defconst +popup-window-parameters
'(transient quit select modeline popup)
"A list of custom parameters to be added to `window-persistent-parameters'.
Modifying this has no effect, unless done before feature/popup loads.
Modifying this has no effect, unless done before ui/popup loads.
(transient . CDR)
CDR can be t, an integer, nil or a function that returns one of these. It
@ -85,37 +85,6 @@ a brief description of some native window parameters that Emacs uses:
"The default time-to-live for transient buffers whose popup buffers have been
deleted.")
;;
(def-setting! :popup (condition &optional alist parameters)
"Register a popup rule.
CONDITION can be a regexp string or a function. See `display-buffer' for a list
of possible entries for ALIST, which tells the display system how to initialize
the popup window. PARAMETERS is an alist of window parameters. See
`+popup-window-parameters' for a list of custom parameters provided by the popup
module.
ALIST supports one custom parameter: `size', which will resolve to
`window-height' or `window-width' depending on `side'."
`(progn
(+popup-define ,condition ,alist ,parameters)
(when (bound-and-true-p +popup-mode)
(setq display-buffer-alist +popup--display-buffer-alist))
+popup--display-buffer-alist))
(def-setting! :popups (&rest rules)
"Register multiple popup rules with :popup setting (`doom--set:popup'). For
example:
(set! :popups
(\"^ \\*\" '((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
(\"^\\*\" '((slot . 1) (vslot . -1)) '((select . t))))"
`(progn
,@(cl-loop for rule in rules collect `(+popup-define ,@rule))
(when (bound-and-true-p +popup-mode)
(setq display-buffer-alist +popup--display-buffer-alist))
+popup--display-buffer-alist))
;;
;; Default popup rules & bootstrap

61
modules/ui/popup/init.el Normal file
View file

@ -0,0 +1,61 @@
;;; ui/popup/init.el -*- lexical-binding: t; -*-
(defvar +popup--display-buffer-alist nil)
(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))
;;
(def-setting! :popup (condition &optional alist parameters)
"Register a popup rule.
CONDITION can be a regexp string or a function. See `display-buffer' for a list
of possible entries for ALIST, which tells the display system how to initialize
the popup window. PARAMETERS is an alist of window parameters. See
`+popup-window-parameters' for a list of custom parameters provided by the popup
module.
ALIST supports one custom parameter: `size', which will resolve to
`window-height' or `window-width' depending on `side'."
`(progn
(+popup-define ,condition ,alist ,parameters)
(when (bound-and-true-p +popup-mode)
(setq display-buffer-alist +popup--display-buffer-alist))
+popup--display-buffer-alist))
(def-setting! :popups (&rest rules)
"Register multiple popup rules with :popup setting (`doom--set:popup'). For
example:
(set! :popups
(\"^ \\*\" '((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
(\"^\\*\" '((slot . 1) (vslot . -1)) '((select . t))))"
`(progn
,@(cl-loop for rule in rules collect `(+popup-define ,@rule))
(when (bound-and-true-p +popup-mode)
(setq display-buffer-alist +popup--display-buffer-alist))
+popup--display-buffer-alist))