diff --git a/init.example.el b/init.example.el index 52f037831..1de3bf544 100644 --- a/init.example.el +++ b/init.example.el @@ -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 diff --git a/modules/feature/popup/+hacks.el b/modules/ui/popup/+hacks.el similarity index 99% rename from modules/feature/popup/+hacks.el rename to modules/ui/popup/+hacks.el index 9132fbc44..34ff826be 100644 --- a/modules/feature/popup/+hacks.el +++ b/modules/ui/popup/+hacks.el @@ -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 diff --git a/modules/feature/popup/README.org b/modules/ui/popup/README.org similarity index 100% rename from modules/feature/popup/README.org rename to modules/ui/popup/README.org diff --git a/modules/feature/popup/autoload.el b/modules/ui/popup/autoload.el similarity index 95% rename from modules/feature/popup/autoload.el rename to modules/ui/popup/autoload.el index 7ad2d2177..8b33d7d91 100644 --- a/modules/feature/popup/autoload.el +++ b/modules/ui/popup/autoload.el @@ -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 diff --git a/modules/feature/popup/config.el b/modules/ui/popup/config.el similarity index 81% rename from modules/feature/popup/config.el rename to modules/ui/popup/config.el index 2c2940563..62c201748 100644 --- a/modules/feature/popup/config.el +++ b/modules/ui/popup/config.el @@ -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 diff --git a/modules/ui/popup/init.el b/modules/ui/popup/init.el new file mode 100644 index 000000000..8b6b99f16 --- /dev/null +++ b/modules/ui/popup/init.el @@ -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))