Comments (5)
Knowing how to do it without it being built into god-mode is just as good in my opinion. I was thinking that someone like yourself might have some idea of how to do it.
I prefer to explicitly call a function that disables god mode and performs some related key-command. However, I think that advice tip is huge. I don't yet understand what advice actually does, but I'm going to dig into it.
Thanks @darth10
from god-mode.
That advice tip is super cool. I was able to create a silly "insert-ahead" keybind for forward/backward motions that let me move 1 character in the correct direction and exit god-local-mode
. This makes spamming forward-word/symbol or backward-word/symbol more useful because sometimes where I want to be is just after some word/symbol separator.
It looks like the :around
option for advice-add
is probably the way to go for these M-RET functions, as I would be able to capture the called function and execute it inside the body of my advice function 😎
from god-mode.
No worries!
I can also suggest a few improvements to your ELisp snippet there:
(defun disable-god-mode (&rest _)
(god-local-mode -1))
(advice-add 'org-meta-return :after #'disable-god-mode
(function 'god/insert-after-org-meta-return))
(advice-add 'org-insert-todo-heading :after #'disable-god-mode
(function 'god/insert-after-org-new-heading))
from god-mode.
That's an interesting idea, but this sounds more like user-level customisation to me.
There are a couple ways to achieve this:
- Use
god-execute-with-current-bindings
, which enables God mode for a single command, executes the command for a key binding, and disables God mode. If God mode is already enabled, thengod-execute-with-current-bindings
simply executes a command and disables God mode. - Use advice functions. For example:
A potential problem that I see with this approach is that common functions like
(defun disable-god-mode (&rest _) (god-local-mode -1)) (advice-add 'end-of-line :after #'disable-god-mode) (advice-add 'back-to-indentation :after #'disable-god-mode) (advice-add 'org-insert-todo-heading :after #'disable-god-mode) ;; ...
end-of-line
may be called by other packages, which would disable God mode without the user intending to do so.
Does that help @trev-dev?
from god-mode.
Meh, rather than try to hook into "Meta Return" I took the simpler route with advice as well.
(advice-add 'org-meta-return :after
#'(lambda (&rest args) (god-local-mode -1))
'(( name . "god/insert-after-org-meta-return")))
(advice-add 'org-insert-todo-heading :after
#'(lambda (&rest args) (god-local-mode -1))
'(( name . "god/insert-after-org-new-heading")))
This works great. Thanks again for the tip @darth10
from god-mode.
Related Issues (20)
- The function "my-god-mode-update-modeline" does not work reliably HOT 4
- Fix mode line suggested in README resulting in unreadable mode line HOT 3
- God mode does not work in Transient UI HOT 8
- god-mode-all doesn't work in shell-mode HOT 4
- Keybinds recommendation
- Use Eldev HOT 1
- Add customisation to disable sticky `god-literal-key` HOT 10
- Idea: One-shot god-mode HOT 3
- Have a discussion page for this project? HOT 1
- Extending god-mode system wide outside of Emacs HOT 13
- feature request: make describe-key work with god-mode HOT 10
- Make ESC just enter god-mode HOT 3
- Conflict with lispy-mode HOT 3
- Shifted key translation HOT 5
- Customize option to disable head icon showing on mode-line HOT 7
- god-mode doesn't work in *scratch* buffer
- god-mode does not work with "un-initialized" `projectile-mode-map` HOT 17
- binding for <C-tab> doesn't work in god-mode HOT 10
- Org-mode header navigation. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from god-mode.