Code Monkey home page Code Monkey logo

Comments (22)

justbur avatar justbur commented on June 11, 2024

It's possible somehow I'm sure but there is a conflict with y so I'd probably want it to be optional. Are you familiar with C-w I think it is? Is that what you are trying to do?

from evil-magit.

cmlaverdiere avatar cmlaverdiere commented on June 11, 2024

I wasn't familiar with C-w but that looks like the correct behavior. Having y optionally map to magit-copy-section-value would be great.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

Easy enough. What would you like to do with magit-show-refs-popup
(currently bound to y)?

On Thu, Dec 10, 2015 at 1:52 PM Chris Laverdiere [email protected]
wrote:

I wasn't familiar with C-w but that looks like the correct behavior.
Having y optionally map to magit-copy-section-value would be great.


Reply to this email directly or view it on GitHub
#11 (comment).

from evil-magit.

cmlaverdiere avatar cmlaverdiere commented on June 11, 2024

I don't use show-refs often, so your call.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

4a8b52a

Set evil-magit-use-y-for-yank to t and you will get

yy => magit-copy-section-value
yb => magit-copy-buffer-revision
yr => magit-show-refs

Let me know what you think. I'm happy to make changes

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

Another solution would be to make y work only in visual mode so magit-show-refs-popup is still available when nothing is selected.

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

Forget my proposition, I didn't see that it was available under yr. The OP asked for yanking selection though.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

@syl20bnr technically there's no visual mode in evil-magit anyway

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

@justbur Do you think this is possible to have a visual state ?
If this is consistent with raw magit in emacs state then I guess it is OK.
TBH I find this a bit disappointing, I often use visual state in evilified magit especially while writing commit message, I go to the diff on the side to copy some stuff.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

@syl20bnr I keep everything in motion state just to avoid headaches with switching states. You can select with "v", but in evil-magit this uses set-mark-command instead of changing states. If you want the ability to copy text linewise, I can do that without visual state, and linewise operations are what default magit supports (C-f is not forward-char for example). If you want the ability to copy arbitrary chunks of text, that's a little more involved.

I just didn't think about copying text in magit buffers (I'd just pop open the file if I was going to do that), but it sounds like people do so I'll add the option.

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

@justbur I disagree with this design choice, this is evil-magit not hybrid-magit, OTOH magit design prevents forward char so... :-)
Maybe the best is to wait and see if other users request a visual state when they have yy and yb.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

@syl20bnr in magit you have operations that you perform after selecting text if you enter visual state you have to make sure those operations are still available (not shadowed by visual state commands). What does evilification do about this? Doesn't it only affect evilified-state?

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

This is solved in evilified state by emptying the whole keymap of visual state and rebind only y to evil-yank and ESC.
Corresponding code is here: https://github.com/syl20bnr/spacemacs/blob/develop/layers/+distribution/spacemacs-base/local/evil-evilified-state/evil-evilified-state.el#L85-L87

from evil-magit.

syl20bnr avatar syl20bnr commented on June 11, 2024

@justbur but this is a bit trickier actually, the keys passing through the visual state keymap are intercepted by a pre-command-hook to redirect the key to evilified state map. I have a feeling that with your expertise and smart heriarchy of keymaps I could remove this hook.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

Interesting. Magit changes the behavior of M-w if the region is active magit/magit#1958

from evil-magit.

justbur avatar justbur commented on June 11, 2024

Actually... That means that vjjyy will select and copy text as I currently have it without further changes. It's not exactly vim because there are two "y"s, but it's pretty close. I could make that 1 "y" if people really wanted that...

@claverdiere Sorry for all of the spam. Let me know what you think about the current behavior and we can look into changes.

from evil-magit.

cmlaverdiere avatar cmlaverdiere commented on June 11, 2024

The yy behavior is good, though just y to yank from a selection would be nicer, as it's closer to the usual evil behavior. I do like @syl20bnr's suggestion that this mapping would only apply in visual mode, as not to shadow the show-refs binding. If getting visual mode to work with evil-magit is too cumbersome though, I'm happy with what you've implemented.

As for the current set-mark-command behavior, I notice that when using C-w to copy (I assume the new yy works the same way), the last line in the selection isn't copied. Is this meant to happen or is it just on my end?

from evil-magit.

justbur avatar justbur commented on June 11, 2024

Just to be clear, I consider this feature experimental at this point, but I've introduced visual state (linewise only still v does exactly what you'd expect V to do in vim), and the new bindings are

yy => yank line
yr => magit-show-refs-popup
ys => magit-copy-section-value
yb => magit-copy-buffer-revision

In visual state
s => stage
u => unstage
...
y => evil-yank

from evil-magit.

cmlaverdiere avatar cmlaverdiere commented on June 11, 2024

This is fantastic! Works exactly as expected. Thank you!

Unrelated, but I noticed while testing that '/' is mapped to evil-search-forward, but '?' isn't mapped to evil-search-backward. This would be a good remap since 'h' already opens the help menu.

from evil-magit.

justbur avatar justbur commented on June 11, 2024

I went back and forth on ? but I think you're right. I'll change it when I get a chance

from evil-magit.

justbur avatar justbur commented on June 11, 2024

@claverdiere I changed ? to search backward and then I changed my mind again and put it back to the help popup. My reasoning is that h is not obvious enough for help to vim users. To compensate I added instructions to the readme to show how to add ? for search backward.

from evil-magit.

cmlaverdiere avatar cmlaverdiere commented on June 11, 2024

Agreed, thanks for the option.

from evil-magit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.