nonsequitur / git-gutter-plus

146 stars 17 forks source link

Add 'git-gutter+-show-hunk-at-point' #24

Closed rocher closed 8 years ago

rocher commented 9 years ago

Please find here a new function to show hunk at point 'at point', very useful for short changes involving few lines. The hunk is shown momentarily: press any key and it disappears. It is possible to take actions depending on the key pressed. For example, it would be possible to revert the hunk or to commit it. Currently this key is just discarded.

Hope you like it ! -- Francesc Rocher

stardiviner commented 9 years ago

Seems git-gutter+ already has function git-gutter+-show-hunk.

nonsequitur commented 9 years ago

Thanks, Francesc! Could you explain how your new function improves the existing function git-gutter+-show-hunk-at-point?

rocher commented 9 years ago

@nonsequitur I cannot find the existing function git-gutter+-show-hunk-at-point you mentioned. The only I've found is git-gutter+-show-hunk, which "Show hunk at point in another window". My proposed new function git-gutter+-show-hunk-at-point is quite similar to the existing one, with the difference that the hunk is momentarily displayed not in another window, but near to the current point. Anyone tried this new function?

stardiviner commented 9 years ago

@rocher I tested this function, I like this way. great idea to show diff in this way. Hope will be merged.

rocher commented 9 years ago

@stardiviner Thanks for your feedback. Hope will be merged too!

nonsequitur commented 8 years ago

@rocher I've cleaned up the code a bit. Currently, it's here in a temp branch.

What's the reason for the final (discard-input)? Is it really needed?

rocher commented 8 years ago

@nonsequitur Nice job, really!

The final (discard-input) is probably not needed. When momentary-string-display is inside a loop and a key is held pressed down for a long time, then there is a high probability that, after the loop finishes, some input characters are still in the queue waiting to be processed by momentary-string-display, so its better to discard them. As there is no loop, I think it can be safely removed.

stardiviner commented 8 years ago

seems not merged yet, I found git-gutter+-awhen in @rocher's code example is void now. I've been using it for many times, is there another function to replace it temporary? @nonsequitur

nonsequitur commented 8 years ago

@rocher Thank you! The code is now live on master, without the final (discard-input).

@stardiviner Yes, use --when-let from dash, it's equivalent to git-gutter+-awhen.

rocher commented 8 years ago

@stardiviner The function has been renamed to git-gutter+-show-hunk-inline-at-point.