Make def-setting! behave more like defmacro

set! used to aggressively evaluate its arguments (at expansion-time),
even if placed inside an after! block. This causes unavoidable errors if
those arguments use functions/variables that don't exist yet.

Fixes #112
This commit is contained in:
Henrik Lissner 2017-06-19 00:22:04 +02:00
parent 27cbd36b69
commit 928812da8a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
12 changed files with 104 additions and 107 deletions

View file

@ -138,16 +138,13 @@ fundamental-mode) for performance sake."
:init
(def-setting! :editorconfig (action value)
":add or :remove an entry in `editorconfig-indentation-alist'."
`(after! editorconfig
,(cond ((eq action :add)
`(push ',value editorconfig-indentation-alist))
((eq action :remove)
(unless (symbolp value)
(error "%s is not a valid major-mode in editorconfig-indentation-alist" value))
`(setq editorconfig-indentation-alist
(delq (assq ',value editorconfig-indentation-alist)
editorconfig-indentation-alist)))
(t (error "%s is an invalid action for :editorconfig" action)))))
(cond ((eq action :add)
`(push ,value editorconfig-indentation-alist))
((eq action :remove)
`(setq editorconfig-indentation-alist
(assq-delete-all ,value editorconfig-indentation-alist)))
(t (error "%s is an invalid action for :editorconfig"
action))))
:config
(add-hook 'doom-init-hook #'editorconfig-mode)