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

Add eat-eshell shim #666

Closed
wants to merge 3 commits into from
Closed

Add eat-eshell shim #666

wants to merge 3 commits into from

Conversation

Haxxflaxx
Copy link
Contributor

eat-eshell is a mode for eat integration for eshell. This lets you run visual commands directly in eshell instead of having it open it in a separate term buffer.

After a visual command has completed and it returns to eshell it doesn't update the cursor so we should do that on the exit-hook.

As it goes from eshell which is effectively running in line-mode, to eat in semi-char-mode, the experience can be a bit jarring. In semi-char-mode you can't really move around. Moving up and down would instead cycle through the command history. By toggling emacs-mode on entering normal mode makes this experience nicer, though as the some work would be needed to make pasting from normal mode working.

I'm not thrilled about relying on eat--eshell-semi-char-mode, maybe this is fragile? This was the only way I could come up with to track which mode we are in.

The rest of eat could probably use a similar shim, but I don't really use the rest so it might be better for someone who do to implement it.

@DogLooksGood
Copy link
Collaborator

DogLooksGood commented Nov 9, 2024

Hey, thanks for the PR. Why don't we use char mode instead of semi-char mode. The char mode supports all terminal keys which seems to be better as we already have normal state with emacs mode.

I have a setup like this

  (defun meomacs-eat-meow-setup ()
    (add-hook 'meow-normal-mode-hook 'eat-emacs-mode nil t)
    (add-hook 'meow-insert-mode-hook 'eat-char-mode nil t))

  (with-eval-after-load "eat"
    (define-key eat-char-mode-map (kbd "C-y") 'eat-yank)
    ;; Replace semi-char mode with emacs mode
    (advice-add 'eat-semi-char-mode :after 'eat-emacs-mode)
    (add-hook 'eat-mode-hook 'meomacs-eat-meow-setup))

@Haxxflaxx
Copy link
Contributor Author

Good point about using char mode instead. The reason is mainly that it defaults to semi char mode.
If we make it go straight to char mode, then switch that on normal/insert-mode, I think that could work great.

That advice you have there, is that to get into eat-emacs-mode?

To solve the pasting from normal mode; can I wrap meow-yank in semi-char-mode then override it in the keymap only for eat-eshell in any convenient way?

@DogLooksGood
Copy link
Collaborator

Yeah, I have this advice to get to eat-emacs-mode + normal state. Otherwise it will be in semi char mode.

Add a hook to meow-normal-mode-hook would be too expensive as this hook runs every time you switch to normal state. I'd rather to have some hook only in eat buffer. I'm not sure if we have more patches like "C-y" needed. Since these term/repl modes may have different behaviors on default keybindings(like "C-y"), the way how meow uses underlying command through keybinding may not work well.

@Haxxflaxx
Copy link
Contributor Author

I don't think it's a great idea to override keys in eat-char-mode as the purpose of it is pretty much to just send the keys as is. I think it would be better instead to temporarily drop into semi char mode do whatever we need to do then go back to emacs mode

Is there something we can do here with your work with lowering the priority of the keymap? This should allow us to have a shim minor mode that grabs certain keys from normal mode.

@DogLooksGood
Copy link
Collaborator

Okay, I think what I said was wrong. Well, the situations in eat and eat-eshell are different. In eat-eshell, it's quite simple, we don't need to rebind anything. But in eat, when the C-y is sent to terminal, it acts as the terminal yank, but only works with those text killed inside the terminal. I bind C-y so I can paste from kill-ring. Well, in this shim, we don't have to overwrite keys, maybe users would prefer C-S-v and C-S-c, and they can do it themselves.

@Haxxflaxx
Copy link
Contributor Author

I've updated with changes so that i runs in char mode. I also changed it so that it doesn't rely on some internal variable for keeping track of state.

It is a bit nicer to use as I no longer need to go into char-mode for handling things like f-keys in htop and the like (which is mostly what I use it for. The only thing I don't really know how to handle is how we should send escape. I don't really do that very often outside of running vim in emacs to show that you can, but maybe it would be good to have the alternative.

You could always press "C-[ C-[" to send escape.

@Haxxflaxx Haxxflaxx deleted the branch meow-edit:master November 11, 2024 18:03
@Haxxflaxx Haxxflaxx closed this Nov 11, 2024
@Haxxflaxx Haxxflaxx deleted the master branch November 11, 2024 18:03
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

Successfully merging this pull request may close these issues.

2 participants