spacemacs/core
Lucius Hu 3bbc7a7d40
core-customization: improved SAFE variable handling (#14679)
* core-customization: improved SAFE variable handling

- SAFE can either be a function or t.
  - When it's t, use a default validation function
    `(lambda (val) (validate-value val TYPE t))`
  - When it's a function, use the supplied function.

* Fixed bugs in go and groovy layer

In almost any cases, it's better to supply `t` instead of a function, to
`SAFE` argument of `spacemacs|defc`.

For example,
```elisp
 (spacemacs|defc go-use-gocheck-for-testing nil
   "If using gocheck for testing when running the tests -check.f will be used instead of -run to specify the test that will be ran. Gocheck is mandatory for testing suites."
  'boolean nil #'booleanp)
```

If its value is nil, it evaluate to `nil`, which means that `nil` is not
a safe value for `go-use-gocheck-for-testing` local variable.

But clearly it is.

* core-customization: improved SAFE variable handling

- Added a function `spacemacs-customization//get-variable-validator`.
  This function is designed to be used with `safe-local-variable`
  property of spacemacs custom variables.
  See details in the docstring.

```elisp
(put 'FOO 'safe-local-variable
     (apply-partially 'spacemacs-customization//get-variable-validator
                      'FOO))
```

- This is better than a lambda since `apply-partially` returns a compiled
  function. (Though the performace gain may be tiny.)
- This is better than simply calling `validate-value`, because it returns
  nil when value is nil. But sometimes nil is a valid value.

Co-authored-by: Lucius Hu <lebensterben@users.noreply.github.com>
2021-04-19 21:34:09 +02:00
..
aprilfool
banners
gnupg
info
libs [bot] Auto-update (#14648) 2021-04-15 22:16:34 +02:00
templates Add missing GPLv3 headers to various files 2021-04-09 20:52:24 +00:00
core-command-line.el
core-compilation.el
core-configuration-layer.el Use the standard elpa gpg homedir 2021-04-12 20:15:46 +00:00
core-custom-settings.el
core-customization.el core-customization: improved SAFE variable handling (#14679) 2021-04-19 21:34:09 +02:00
core-debug.el [helpful] Make layer alias standard describe-functions 2021-04-15 21:14:23 +00:00
core-display-init.el
core-documentation.el
core-dotspacemacs.el [Fix] dotspacemacs/test-dotfile complains error on new custom vars 2021-04-10 09:43:44 +02:00
core-dumper.el
core-early-funcs.el [init] Disable GUI elements in early-init as well (#14559) 2021-04-08 22:25:14 +02:00
core-emacs-backports.el
core-env.el
core-fonts-support.el
core-funcs.el
core-hooks.el
core-jump.el [core] Remove some typos in doc of new jump handlers 2021-04-12 21:13:51 +00:00
core-keybindings.el
core-load-paths.el
core-micro-state.el
core-progress-bar.el
core-release-management.el
core-spacebind.el
core-spacemacs-buffer.el [dotfile] New var: dotspacemacs-startup-buffer-multi-digit-delay 2021-04-08 22:27:54 +02:00
core-spacemacs.el [init] Disable GUI elements in early-init as well (#14559) 2021-04-08 22:25:14 +02:00
core-themes-support.el
core-toggle.el
core-transient-state.el
core-use-package-ext.el
core-versions.el