Comments (6)
Well with (setq general-default-keymaps 'evil-normal-state-map)
(general-define-key "U" 'redo)
;; is the equivalent of
(general-define-key :keymaps 'evil-normal-state-map "U" 'redo)
;; or
(general-nmap "U" 'redo)
I don't think the problem you're describing should be happening. Generally, you wouldn't (need to) define keys for states in the global map (maybe read this part of the readme if you haven't already).
Then U is undefined in dired. However, if I define :states 'normal instead of using general-default-keymaps, all my bindings are available like I want.
Does this happen for other modes (I've never experienced this)? Does this also happen if you do the following?
(define-key evil-normal-state-map "U" 'undo)
(evil-define-key 'normal dired-mode-map
<mappings>)
To clarify, you're saying that U
is completely unbound (and not bound to dired-unmark-all-marks
)? And this only happens if you also use general-evil-define-key
for the mode?
from general.el.
To clarify, you're saying that
U
is completely unbound (and not bound todired-unmark-all-marks
)? And this only happens if you also usegeneral-evil-define-key
for the mode?
Sorry, that was bad wording on my part. By "U is undefined in dired" I meant that U
is bound to dired-unmark-all-marks
instead of my custom mapping for normal-state.
However after doing further testing, I think that this was happening because of evil-make-overriding-map
. It's applied to dired-mode-map
(via evil-integration.el
) and occur-mode-map
(via my config), so they simply had higher precedence than my other mappings.
But now I'm wondering, is there a difference between
(evil-define-key :states 'normal "U" 'undo)
and
(evil-define-key :keymaps 'evil-normal-state-map "U" 'undo)
Because only the former would allow me to use U
in Dired despite evil-make-overriding-map
.
from general.el.
However after doing further testing, I think that this was happening because of evil-make-overriding-map
Yeah that was my guess. I talk a little about ways around this in the last paragraph here if you don't want dired-mode-map
to have a higher precedence. The best way is to prevent the code in integration.el from being run. Defining in the global-map for normal state also gets around it.
As for the difference between states and keymaps here, evil-normal-state-map
is a global keymap. With something like (evil-define-key 'normal dired-mode-map ...)
, evil-get-auxiliary-map
is used to create a new keymap. (general-define-key :states 'normal ...)
is the same as (evil-define-key 'normal (current-global-map) ...)
. The global evil-normal-state-map
is what is overriden in integration.el, so keys bound in the global-map with evil-define-key
are not affected.
You can keep using this as a solution to prevent your keys from being overridden if you want to. It may be a good solution; I'm just not sure if there might be downsides since I haven't tried this out myself. One thing to note is that this will only work for keys you define yourself (keys you leave the same will still be overridden). If you'd rather not use general-default-states
and like the general-nmap
-like commands, I could add an option or argument to have them be created to define in the global-map for a state instead.
from general.el.
The best way is to prevent the code in integration.el from being run.
I just advise it [
evil-make-overriding-map
] into non-existences (with:around (lambda (orig-func))
).
Could you elaborate more on how to this? I can't really figure out the documentation for add-advice
/add-function
.
I could add an option or argument to have them be created to define in the global-map for a state instead.
That would be pretty cool to have as an option and I'd use it. I do like the shorter names and their similarity to Vim.
from general.el.
To prevent a function from ever being run, you can advise it before it is created like this:
(advice-add 'evil-make-overriding-map
:around (defun my-kill-overriding-maps (_ &rest _)))
The :around
keyword will cause the function you provide to replace the function you are advising. The original function and arguments are passed in as arguments to the new function. In this case, the original function is just ignored and nothing ever happens when it is called.
If you want to use evil-make-overriding-map
yourself afterwards, you will need to get rid of the advice (I'd recommend doing it just after loading evil):
(advice-remove 'evil-make-overriding-map #'my-kill-overriding-maps)
That would be pretty cool to have as an option and I'd use it.
Okay, I've made a new issue for it. Would you prefer that it be an argument when creating them (e.g. (general-evil-setup _ <arg to decide>)
) or something that could be toggled after creating them (either with a global variable or with a keyword argument to general-nmap
)? If you don't have a preference, I think I'll implement it as a global variable.
from general.el.
Hooray, I feel like I have total control over my bindings with evil-make-overriding-map
disabled!
(e.g. (general-evil-setup _ ))
This seems pretty sensible and fits as an extra option like SHORT-NAMES
.
Thanks for all the info and help. Evil + general + the helpful community is really making Emacs into a perfect editor (for me) that I can easily configure and adapt.
from general.el.
Related Issues (20)
- Add an option to disable autoloading a command in `use-package` integration HOT 1
- Miscompilation of a `:general` form if binding in Evil's insert mode HOT 3
- Key sequence starts with non-prefix key. HOT 2
- Leader key only works in messages buffer after changing modes (EVIL) HOT 4
- Overriding mapping in minor modes HOT 3
- Rewrite HOT 16
- having seeing latex keys in org mode HOT 1
- How to pass a command list to `general-define-key` HOT 1
- Optimizing for speed: do's and don'ts HOT 9
- Prefix is not working with local leader definer HOT 1
- which-key labels not shown in prefix-command keymaps HOT 1
- General.el byte-compile warning HOT 2
- using multi evil states/keymaps in single general-def
- keymaps not activating keymap during major-mode treemacs HOT 2
- `general-def` is not defined when used in `pre-` or `post-command-hook` HOT 1
- general is not working correctly for emacs-lisp-mode HOT 1
- Using general.el with meow HOT 4
- binding "TAB" in company-active-map to company-complete-selection problem HOT 2
- Creating a toggle to activate/deactivate keybindings HOT 3
- How to use custom definer in use-package definition? HOT 7
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 general.el.