Expose initial evil state as defcustom#161
Conversation
|
Context on why this matters to me, in case it's useful for the design discussion: I prefer defaulting new ghostel buffers to
Possible I'm using the package against its intended grain; happy to hear if there's a more canonical way. Either way, the defcustom lets both workflows coexist without config-side advice tricks. |
`evil-ghostel-mode' hard-coded `(evil-set-initial-state 'ghostel-mode 'insert)' inside its activation body. Since the minor mode is wired to `ghostel-mode-hook', that call fires on every ghostel buffer creation — and runs before `evil-initialize' reads the initial state via `after-change-major-mode-hook'. Any user override (customize, setq, or direct `evil-set-initial-state' call) was silently clobbered on the next ghostel buffer. Replace the hard-coded call with `evil-ghostel-initial-state', a defcustom whose `:set' re-runs `evil-set-initial-state'. Apply the current value once at package load to cover the `setq-before-require' path where `defcustom' preserves the value without invoking `:set'. The evil registry is last-writer-wins, so users who prefer the raw API can still call `evil-set-initial-state' directly from `:config' without knowing about the option. Default remains `insert' to preserve existing behaviour. Add tests covering: load-time registration, customize-set updates, and activation not clobbering the initial-state setting (regression guard).
d64e400 to
5fcbb19
Compare
|
Thanks again ❤️
Personally I'm not a evil user. I just added this package because a few users requested it and it's very popular. |
Problem
evil-ghostel-modehard-codes(evil-set-initial-state 'ghostel-mode 'insert)inside its activation body (evil-ghostel.el:337). Wired toghostel-mode-hookper the README:the call fires on every ghostel buffer creation, running before
evil-initializereads the initial state viaafter-change-major-mode-hook. User overrides (Customize,setq, directevil-set-initial-state) survive until the next new ghostel buffer opens, then get clobbered.Change
evil-ghostel-default-statedefcustom.:setre-runsevil-set-initial-stateso Customize /setopttake effect immediately. Direct calls toevil-set-initial-statealso keep working — the registry is last-writer-wins.(setq ... )beforerequire, wheredefcustompreserves the value without calling:set.Default stays
'insert; no behaviour change for existing users.Tests
Three new ERT cases in
test/evil-ghostel-test.el:default-state-load-applied— value is registered at load.default-state-custom-set-updates-registry— Customize propagates.mode-activation-preserves-initial-state— regression guard: activation no longer clobbers the registry.