doom-def-setting => def-setting!

This commit is contained in:
Henrik Lissner 2017-02-04 21:09:33 -05:00
parent 7703fc56f4
commit 5549e141a7
3 changed files with 44 additions and 45 deletions

View file

@ -36,25 +36,24 @@
map) map)
"Active keymap in popup windows.") "Active keymap in popup windows.")
(def-setting! :popup (&rest rule)
"Prepend a new popup rule to `shackle-rules'."
(let ((pattern (car rule))
(plist (cdr rule)))
;; Align popups by default (error if this doesn't happen)
(unless (plist-member plist :align)
(plist-put plist :align t))
;; Select popups by default
(unless (or (plist-member plist :select)
(plist-member plist :noselect))
(plist-put plist :select t))
(push (cons pattern plist) shackle-rules)))
;; ;;
;; Bootstrap ;; Bootstrap
;; ;;
(doom-def-setting :popup
(lambda (&rest rule)
(let ((pattern (car rule))
(plist (cdr rule)))
;; Align popups by default (error if this doesn't happen)
(unless (plist-member plist :align)
(plist-put plist :align t))
;; Select popups by default
(unless (or (plist-member plist :select)
(plist-member plist :noselect))
(plist-put plist :select t))
(push (cons pattern plist) shackle-rules)))
"Prepend a new popup rule to `shackle-rules'.")
(package! shackle :demand t (package! shackle :demand t
:init :init
(setq shackle-default-alignment 'below (setq shackle-default-alignment 'below
@ -67,24 +66,25 @@
;; :noesc and :modeline are custom settings and are not part of shackle. See ;; :noesc and :modeline are custom settings and are not part of shackle. See
;; `doom*popup-init' and `doom-popup-buffer' for how they're used. ;; `doom*popup-init' and `doom-popup-buffer' for how they're used.
(set! :popup (set! :popup
("^ ?\\*doom:.+\\*$" :size 40 :modeline t :regexp t) ("^ ?\\*doom:.+\\*$" :size 40 :modeline t :regexp t)
("^ ?\\*doom .+\\*$" :size 30 :noselect t :regexp t) ("^ ?\\*doom .+\\*$" :size 30 :noselect t :regexp t)
("^\\*.+-Profiler-Report .+\\*$" :size 0.3 :regexp t) ("^\\*.+-Profiler-Report .+\\*$" :size 0.3 :regexp t)
("*esup*" :size 0.4 :noselect t :noesc t) ("*esup*" :size 0.4 :noselect t :noesc t)
("*minor-modes*" :size 0.5 :noselect t) ("*minor-modes*" :size 0.5 :noselect t)
("*eval*" :size 16 :noselect t) ("*eval*" :size 16 :noselect t)
("*Pp Eval Output*" :size 0.3) ("*Pp Eval Output*" :size 0.3)
("*Apropos*" :size 0.3) ("*Apropos*" :size 0.3)
("*Backtrace*" :size 25 :noselect t) ("*Backtrace*" :size 25 :noselect t)
("*Help*" :size 16) ("*Help*" :size 16)
("*Messages*" :size 10) ("*Messages*" :size 10)
("*Warnings*" :size 10 :noselect t) ("*Warnings*" :size 10 :noselect t)
("*command-log*" :size 28 :noselect t :align right) ("*command-log*" :size 28 :noselect t :align right)
(compilation-mode :size 15 :noselect t :noesc t) ("*Shell Command Output*" :size 20 :noselect t)
(ivy-occur-grep-mode :size 25 :noesc t) (compilation-mode :size 15 :noselect t :noesc t)
(eww-mode :size 30) (ivy-occur-grep-mode :size 25 :noesc t)
(comint-mode :noesc t) (eww-mode :size 30)
(tabulated-list-mode :noesc t)) (comint-mode :noesc t)
(tabulated-list-mode :noesc t))
(define-minor-mode doom-popup-mode (define-minor-mode doom-popup-mode
"Minor mode for pop-up windows." "Minor mode for pop-up windows."

View file

@ -9,20 +9,19 @@
"An alist of settings, mapping setting keywords to setter functions, which can "An alist of settings, mapping setting keywords to setter functions, which can
be a lambda or symbol.") be a lambda or symbol.")
(defun doom-def-setting (keyword setter-fn &optional docstring) (defmacro def-setting! (keyword arglist &optional docstring &rest forms)
"Define a setting macro. Takes the same arguments as `defmacro'. This should "Define a setting macro. Takes the same arguments as `defmacro'. This should
return forms, which will be run when `set!' is used to call this setting." return forms, which will be run when `set!' is used to call this setting."
(declare (indent defun)) (declare (indent defun) (doc-string 3))
(unless (keywordp keyword) (unless (keywordp keyword)
(error "Not a valid property name: %s" keyword)) (error "Not a valid property name: %s" keyword))
(unless (or (symbolp setter-fn) `(push (list ,keyword
(functionp setter-fn)) :source ,(__FILE__)
(error "Not a valid setting function for %s" keyword)) :docstring ,docstring
(push (list keyword :fn (lambda ,arglist
:source load-file-name ,docstring
:docstring docstring ,@forms))
:fn setter-fn) doom-settings))
doom-settings))
(defmacro set! (keyword &rest rest) (defmacro set! (keyword &rest rest)
"Set an option defined by `def-setting!'. Skip if doesn't exist." "Set an option defined by `def-setting!'. Skip if doesn't exist."

View file

@ -9,15 +9,15 @@
(defvar +evil-localleader "\\" (defvar +evil-localleader "\\"
"The <localleader> key, used by the `map!' macro for :localleader bindings.") "The <localleader> key, used by the `map!' macro for :localleader bindings.")
(def-setting! :evil-state (mode state)
"Set the initialize STATE of MODE using `evil-set-initial-state'."
(evil-set-initial-state mode state))
;; ;;
;; evil-mode ;; evil-mode
;; ;;
(doom-def-setting :evil-state
'evil-set-initial-state
"Set the initialize STATE of MODE using `evil-set-initial-state'.")
(use-package! evil :demand t (use-package! evil :demand t
:init :init
(setq evil-want-C-u-scroll t (setq evil-want-C-u-scroll t