Make god-mode-all able to not only toggle god-mode by also strictly activate or deactivate it #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I started using Emacs server and I want to make sure that god-mode is turned on globally every time a new frame is created. However,
god-mode-allis only capable of toggling the mode, and I needed it to enforce the mode to be turned on, otherwise the following happens:god-mode-allfromafter-make-frame-functionsand it turns off.god-mode-allfromafter-make-frame-functionsand it turns off because it was left on.If in (4) god-mode is off, then it will be turned on when I create a new frame, as I want it to be. But then I would need to remember to turn it off manually or put
god-mode-allindelete-frame-functions, and that would only work if I deleted the frame while it was on. Now one can see the way it is right nowgod-mode-allis not the proper function for this task.To achieve what I wanted, I added an optional argument to
god-mode-allwhich controls whether the function toggles god-mode, or strictly activates or deactivates it. To ensure backwards compatibility, I made sure to make nil as the value for toggling the mode, and as for the positive and negative values for turning it on or off, I followed the convention ofdefine-minor-mode.In the new function, I could have bypassed
mapcbased on thegod-global-modevariable, but this value is not consistent. What I mean is that god-mode could have various states for different buffers, andgod-global-modewas not capable of reliably indicating whether all buffers had god-mode on or off, therefore the only way the newgod-mode-allfunction would work properly is by not relying on this value.As a side note, if all goes well, I will probably create other pull requests with improvements I had made for myself that I think others might also benefit from.