Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set text objects only in lispyville-mode #298

Open
meliache opened this issue Aug 23, 2021 · 2 comments
Open

Set text objects only in lispyville-mode #298

meliache opened this issue Aug 23, 2021 · 2 comments

Comments

@meliache
Copy link

I started using the evil-textobj-treesitter package and use it to bind the f to the treesitter function textobject. But treesitter has no emacs lisp support, so there I still rely on the lispyville text objects. Both packages modify the global evil-inner-text-objects-map and evil-outer-text-objects-map maps, so I run into conflicts when using both.

I looked into lispyville.el and found the comment (by @noctuid from 2018):

         ;; TODO only define in `lispyville-mode-map'

So I guess it is a known issue. Any idea how to go about it? I guess this is an issue that every package that adds custom textobjects to emacs which only work in certain major modes has and I'd be interested if anyone has a solution. My idea would be to have custom textobject maps that are toggle via minor modes, but then one should somehow make evil respect those custom maps.

I created an equivalent issue for evil-textobj-treesitter here.

@noctuid
Copy link
Owner

noctuid commented Aug 24, 2021

There is not a perfect solution for this since evil only provides the global text object maps. I have an issue open on some repo or some notes somewhere where I evaluated different workarounds, but I can't seem to find it. I will continue looking. Maybe I could create a lispyville-inner-text-objects-map, for example, that inherits from evil-inner-text-objects-map and bind that in 'operator lispyville-mode-map. I will try that and see if it works. The workaround for now would be to bind the keys yourself to a menu item that selects a different text object depending on whether lispyville-mode is enabled. You can use general-predicate-dispatch to simplify this (it is a small macro you can copy if you do not use general.el).

@meliache
Copy link
Author

Thanks for the tipps and looking into this, this general.el feature looks useful, just now I noticed that you're the dev. So far I've only used general.el occasionally within use-package (mostly via :general) when the built-in :bind wasn't enough and I wanted to configure bindings for specific evil states only, but I'm only aware of a small subset of its features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants