From 67dab988596ef9a3eec47753625b77756fde887b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 14 May 2018 20:54:57 +0200 Subject: [PATCH] Improve idempotency of Doom config (in case of reloading) --- core/core-packages.el | 2 +- modules/completion/helm/config.el | 2 +- modules/completion/ivy/config.el | 8 ++++---- modules/feature/evil/config.el | 23 ++++++++++++----------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index 0f9bf507f..6f2234f42 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -1020,7 +1020,7 @@ Do not use this for configuring Doom core." (defun ,fn ,arglist ,docstring ,@forms) - (cl-pushnew ',(cons keyword fn) doom-settings :test #'eq :key #'car)))) + (map-put doom-settings ,keyword #',fn)))) (defmacro set! (keyword &rest values) "Set an option defined by `def-setting!'. Skip if doesn't exist. See diff --git a/modules/completion/helm/config.el b/modules/completion/helm/config.el index 0c7d32611..d407459f2 100644 --- a/modules/completion/helm/config.el +++ b/modules/completion/helm/config.el @@ -15,7 +15,7 @@ :config (helm-mode +1) ;; helm is too heavy for find-file-at-point - (add-to-list 'helm-completing-read-handlers-alist '(find-file-at-point . nil))) + (map-put helm-completing-read-handlers-alist 'find-file-at-point nilk)) (def-package! helm diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 222982a2a..eb60b5789 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -48,7 +48,7 @@ immediately runs it on the current candidate (ending the ivy session)." ivy-use-selectable-prompt t) (after! magit (setq magit-completing-read-function #'ivy-completing-read)) - (after! yasnippet (push #'+ivy-yas-prompt yas-prompt-functions)) + (after! yasnippet (cl-pushnew #'+ivy-yas-prompt yas-prompt-functions :test #'eq)) (map! [remap switch-to-buffer] #'ivy-switch-buffer [remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer @@ -202,13 +202,13 @@ immediately runs it on the current candidate (ending the ivy session)." 'ivy-posframe-display-at-window-bottom-left 'ivy-posframe-display-at-window-center '+ivy-display-at-frame-center-near-bottom)) - (push (list fn :cleanup 'ivy-posframe-cleanup) ivy-display-functions-props)) + (map-put ivy-display-functions-props fn '(:cleanup ivy-posframe-cleanup))) - (push '(t . +ivy-display-at-frame-center-near-bottom) ivy-display-functions-alist) + (map-put ivy-display-functions-alist 't '+ivy-display-at-frame-center-near-bottom) ;; posframe doesn't work well with async sources (dolist (fn '(swiper counsel-rg counsel-ag counsel-pt counsel-grep counsel-git-grep)) - (push (cons fn nil) ivy-display-functions-alist)) + (map-put ivy-display-functions-alist fn nil)) (setq ivy-height 16 ivy-fixed-height-minibuffer nil diff --git a/modules/feature/evil/config.el b/modules/feature/evil/config.el index 280c1563a..bf107e1cc 100644 --- a/modules/feature/evil/config.el +++ b/modules/feature/evil/config.el @@ -220,12 +220,12 @@ (cons (format "(%s " (or (read-string "(") "")) ")")) ;; Add escaped-sequence support to embrace - (push (cons ?\\ (make-embrace-pair-struct - :key ?\\ - :read-function #'+evil--embrace-escaped - :left-regexp "\\[[{(]" - :right-regexp "\\[]})]")) - (default-value 'embrace--pairs-list))) + (map-put (default-value 'embrace--pairs-list) + ?\\ (make-embrace-pair-struct + :key ?\\ + :read-function #'+evil--embrace-escaped + :left-regexp "\\[[{(]" + :right-regexp "\\[]})]"))) (def-package! evil-escape @@ -307,11 +307,11 @@ the new algorithm is confusing, like in python or ruby." ;; Add custom commands to whitelisted commands (dolist (fn '(doom/backward-to-bol-or-indent doom/forward-to-last-non-comment-or-eol doom/backward-kill-to-bol-and-indent)) - (push (cons fn '((:default . evil-mc-execute-default-call))) - evil-mc-custom-known-commands)) + (map-put evil-mc-custom-known-commands + fn '((:default . evil-mc-execute-default-call)))) ;; disable evil-escape in evil-mc; causes unwanted text on invocation - (push 'evil-escape-mode evil-mc-incompatible-minor-modes) + (cl-pushnew 'evil-escape-mode evil-mc-incompatible-minor-modes :test #'eq) (defun +evil|escape-multiple-cursors () "Clear evil-mc cursors and restore state." @@ -380,8 +380,9 @@ the new algorithm is confusing, like in python or ruby." evil-forward-arg evil-backward-arg evil-jump-out-args) :config - (push "<" evil-args-openers) - (push ">" evil-args-closers)) + (unless (member "<" evil-args-openers) + (push "<" evil-args-openers) + (push ">" evil-args-closers))) (def-package! evil-indent-plus