+ :popup -> set-popup-rule! + :popups -> set-popup-rules! + :company-backend -> set-company-backend! + :evil-state -> set-evil-initial-state! I am slowly phasing out the setting system (def-setting! and set!), starting with these. What are autodefs? These are functions that are always defined, whether or not their respective modules are enabled. However, when their modules are disabled, they are replaced with macros that no-op and don't waste time evaluating their arguments. The old set! function will still work, for a while.
107 lines
3.8 KiB
EmacsLisp
107 lines
3.8 KiB
EmacsLisp
;;; ui/popup/autoload/settings.el -*- lexical-binding: t; -*-
|
|
|
|
(defvar +popup--display-buffer-alist nil)
|
|
|
|
(defsubst +popup--rule (args)
|
|
(cl-destructuring-bind (condition &optional alist parameters) args
|
|
(if (eq alist :ignore)
|
|
(list condition nil)
|
|
`(,condition (+popup-buffer)
|
|
,@alist
|
|
(window-parameters ,@parameters)))))
|
|
|
|
(defun +popup--define (condition &optional alist parameters)
|
|
(when after-init-time
|
|
(setq +popup--display-buffer-alist
|
|
(map-delete +popup--display-buffer-alist condition)))
|
|
(push (+popup--rule (list condition alist parameters))
|
|
+popup--display-buffer-alist))
|
|
|
|
;;;###autodef
|
|
(defun set-popup-rule! (condition &optional alist parameters)
|
|
"Define a popup rule.
|
|
|
|
CONDITION can be a regexp string or a function.
|
|
|
|
For ALIST, see `display-buffer' and `display-buffer-alist' for a list of
|
|
possible entries, which instruct the display system how to initialize the popup
|
|
window.
|
|
|
|
ALIST also supports the `size' parameter, which will be translated to
|
|
`window-width' or `window-height' depending on `side'.
|
|
|
|
PARAMETERS is an alist of window parameters. See `+popup-window-parameters' for
|
|
a list of custom parameters provided by the popup module. If certain
|
|
attributes/parameters are omitted, the ones from `+popup-default-alist' and
|
|
`+popup-default-parameters' will be used.
|
|
|
|
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.
|
|
|
|
See `def-popups!' for defining multiple rules in bulk."
|
|
(+popup--define condition alist parameters)
|
|
(when (bound-and-true-p +popup-mode)
|
|
(setq display-buffer-alist +popup--display-buffer-alist))
|
|
+popup--display-buffer-alist)
|
|
|
|
;;;###autodef
|
|
(defun set-popup-rules! (&rest rulesets)
|
|
"Define multiple popup rules. See `def-popup!' for the specifications of each
|
|
individual rule.
|
|
|
|
(set-popup-rules!
|
|
'((\"^ \\*\" ((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
|
|
(\"^\\*\" ((slot . 1) (vslot . -1)) ((select . t)))))"
|
|
(dolist (ruleset rulesets)
|
|
(dolist (rule ruleset)
|
|
(apply #'+popup--define rule)))
|
|
(when (bound-and-true-p +popup-mode)
|
|
(setq display-buffer-alist +popup--display-buffer-alist))
|
|
+popup--display-buffer-alist)
|
|
|
|
|
|
;;
|
|
;; Obsolete
|
|
;;
|
|
|
|
;; FIXME obsolete :popup
|
|
;;;###autoload
|
|
(def-setting! :popup (condition &optional alist parameters)
|
|
"Define a popup rule.
|
|
|
|
CONDITION can be a regexp string or a function.
|
|
|
|
For ALIST, see `display-buffer' and `display-buffer-alist' for a list of
|
|
possible entries, which instruct the display system how to initialize the popup
|
|
window.
|
|
|
|
ALIST also supports the `size' parameter, which will be translated to
|
|
`window-width' or `window-height' depending on `side'.
|
|
|
|
PARAMETERS is an alist of window parameters. See `+popup-window-parameters' for
|
|
a list of custom parameters provided by the popup module. If certain
|
|
attributes/parameters are omitted, the ones from `+popup-default-alist' and
|
|
`+popup-default-parameters' will be used.
|
|
|
|
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.
|
|
|
|
See `def-popups!' for defining multiple rules in bulk."
|
|
:obsolete set-popup-rule!
|
|
`(set-popup-rule! ,condition ,alist ,parameters))
|
|
|
|
;; FIXME obsolete :popups
|
|
;;;###autoload
|
|
(def-setting! :popups (&rest rulesets)
|
|
"Define multiple popup rules. See `def-popup!' for the specifications of each
|
|
individual rule.
|
|
|
|
(set-popup-rules!
|
|
'((\"^ \\*\" ((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))
|
|
(\"^\\*\" ((slot . 1) (vslot . -1)) ((select . t)))))"
|
|
:obsolete set-popup-rules!
|
|
`(set-popup-rules! ,@rulesets))
|