-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Use posframe or popup to show the current hunk #147
Use posframe or popup to show the current hunk #147
Conversation
the right thing to do with a posframe)
diff-hl-show-hunk-posframe.el
Outdated
@@ -159,6 +159,9 @@ to scroll in the posframe") | |||
|
|||
(set-frame-parameter diff-hl-show-hunk--frame 'drag-internal-border t) | |||
(set-frame-parameter diff-hl-show-hunk--frame 'drag-with-header-line t) | |||
|
|||
;; Dedicate window | |||
(set-window-dedicated-p (window-main-window diff-hl-show-hunk--frame) t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like posframe already does this in posframe--create-posframe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I will undo this change
Hi! Sorry for the late reply. I like this in principle, but we'll need to discuss some details. And also it would be nice to have a review from the target audience (perhaps @deadtrickster would like to take a look?).
Do you want them there always or only when one of the new minor modes is enabled?
Yeah, the current screenshots here don't reflect the theme I'm using now either. I can redo them. Or we could standardize on the default Emacs theme. No dark themes, please. Though we could add some extra (dark) screenshots in a directory inside, and link to them.
Please see these instructions: https://code.orgmode.org/bzg/org-mode/raw/master/request-assign-future.txt (Keep the answer to the first question that's written there, "Emacs"). That will let you contribute to Emacs itself later, as well as other packages in GNU ELPA. Other notesTwo new modes is a good, conservative choice, considering some other feature might want to use the fringe/margin as well, and there is no existing way for such features to cooperate. Since Whenever you have several empty lines in a row (in the code), you can replace them with just one. The new files need the appropriate license and copyright blurbs, as well as the author header (if it stumps you, I can add those later). What about the default width? Will it often be shorter than the diff inside? If we're emulating a feature from some other editor, could you link to some screenshot, so we can compare the behavior? On the screenshots, I see the popups showing more than just one hunk. Is that intentional? I wonder what the users prefer in general. |
Awesome, I will try it soon! |
Perhaps it should be added (and removed on disable) by
Yes, sure. We'll do that at the end, after everything else is taken care of.
The counterpart for variables is just
When the diff is narrower than the current window, I suppose it's okay. But if it's wider, it would be better to use the width of the current window, I think. Either way, perhaps we can do without
Ok.
Not exactly. Or, at least, while it is functionally the same,
So Eclipse was your inspiration? |
- Whenever you have several empty lines in a row (in the code), you can replace them with just one. - he new files need the appropriate license and copyright blurbs, as well as the author header - we probably need a bunch of declare-function declarations to clean up the byte compilation warnings.
diff-hl-show-hunk-popup.el
Outdated
;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
|
||
;; Author: Dmitry Gutov <dgutov@yandex.ru> | ||
;; Álvaro González <alvarogonzalezsotillo@gmail.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more correct to put just you as the author of this and other files here.
diff-hl-show-hunk-popup.el
Outdated
|
||
;; Author: Dmitry Gutov <dgutov@yandex.ru> | ||
;; Álvaro González <alvarogonzalezsotillo@gmail.com> | ||
;; URL: https://github.com/dgutov/diff-hl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL header is unnecessary here, it's only read from the main .el file by the package.el infrastructure.
diff-hl-show-hunk-popup.el
Outdated
(declare-function popup-set-list "popup") | ||
(declare-function popup-select "popup") | ||
(declare-function popup-draw "popup") | ||
(eval-when-compile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval-when-compile
is unnecessary here, IIRC.
I've been trying out the feature and I like it. One point of feedback I would have for the popup version (I still need to install posframe and try it out), is that it would be good if the popup could always popup at the start of the line, so the aligment of the diff in the popup is the same of that of the file. |
I tried it out today, couldn't make posframe integration work (likely I messed up with my cache because I (mis)use gccemacs). One thing I spotted immediately - when I click on fringe it asks to save file. In my version I specifically avoided saving, I think it is not convenient and error prone. How to turn this off? |
I use If I get this PR merged, my plan is to store the diffs in the overlays (#112) as an option, with a customize flag like |
dgutov#147 (comment): - Since popup and posframe are not require-d by any of the features here (except at runtime), we probably need a bunch of declare-function declarations to clean up the byte compilation warnings. - Removed diff-hl-show-hunk-popup-default-width, the full with is used - It would be good if the popup could always popup at the start of the line, so the aligment of the diff in the popup is the same of that of the file.
avoid this overlap, set 0 contex lines in `vc-diff'. For example, if git is used, set `vc-git-diff-switches' to '--unified=0'. If subversion is used, try to set `vc-svn-diff-switches' to '--diff-cmd=\"diff -x -U0\"'"
Now I use
I used a customized variable because I didn't know what value to use. But now, it seems clear that the correct width for the popup is the full width, so i removed Still working in the width of the posframe.
I used Eclipse long time ago, and I liked quick-diff, and #112 was the final inspiration.
I think the solution could be the contex of the diff algorithm. Two hunks can be overlaped in the output of If I customize For SVN, maybe setting |
I'm still using your repo version, so I don't know if you updated this, but for me, if I mouse click on the fringe to get the popup (configured at the right fringe), it pops up at the end of line. |
why not to make overlays default? |
Perhaps that would not be optimal for both possible values of |
And either way, the code could reuse the method employed by |
Very good.
Yeah, looks like full width is the best. VS Code uses the full width anyway: https://stackoverflow.com/a/47296478/615245
One of the best motivations! Props to you.
Right. Check out the macro |
Maybe there are some memory problems in large diffs. But I think there will be no problem with modern hardware.
I am afraid If there are no objections, I will remove it. |
Fully understanding no one owes nothing to nobody, I would still like to point out that forcing save might be a show stopper for others as well. At least in my workflow I reach out to diffs when I think I'm screwing up, other users could have those live-reload-on-save a-la node.js systems and forcing users to save might be undesirable. |
Solved.
There is a problem in console (not GUI): console doesn't not support overline, so I simulated it with an empty line with underline. I added a
Currently, I prefer
I have added the
I forgot it. Removed. |
Thanks.
I wonder if console users would prefer no extra line, even if the horizontal line can't be shown. Anyway, we can leave that to future bug reports. But note that you missed the first bit from the diff I posted: the one that removed a newline from in front of the header as well (in
All right, so it seems we should keep the both option variables. But is it working right for you? If you prefer for them to be both + (smart-lines (and diff-hl-show-hunk-inline-popup-smart-lines (not diff-hl-show-hunk-inline-popup-hide-hunk)))
Perhaps it should say "no lines removed". Something else I've been thinking: since |
properly closed inline popup. Also: named face for posframe buttons.
properly closed inline popup. Also: Removed extra blank line in inline popup Also: named face for posframe buttons.
…sotillo/diff-hl into diff-hl-show-hunk
…rong and it converted (3) into (1). I have changed an `and` for an `or` to avoid (4) | | hide-hunk | not hide-hunk | |-----------------+-----------------------------+--------------------------------------| | smart-lines | (1) Sort of wayback machine | (2) Your preferences (default) | | not smart-lines | (3) My preferences | (4) New lines are shown twice, noisy |
You are right, removed that extra new line.
I admit I have changed my mind a couple of times:
I have tried to avoid (4), and convert it to (3), but the logic was wrong. I have changed an |
I think mouse-mode and global-minor-mode should be a separate minor mode, to avoid conflicts with other packages, but the rest of key bindings can be in |
I'm about to implement this comment. So, |
Not necessary: you just add |
Thanks for the table, it confirms that we do need both variables. But I think we'll just remove the condition for Finally, it's high time to start merging this. I'll try to make time this weekend to merge the "meat" of this PR (the modes, commands, and the keymap changes), but simplify the README change for now. Redoing the README will come after (and BTW, I'll need the name of the tool you used for the gifs ;). |
Done
If you mean the displayed keystrokes, I use screenkey. The version in Ubuntu repositories is not very up to date, so I use the repository version (just checkout and run If you mean the screencast, I use OBS and Kdenlive and then convert the video to gif with
|
Excellent, thank you. |
@purcell Hi Steve! Would you say it's okay for |
hunk since it is located on a non deleted line.
It should match the name prefix, or we could have the two packages coexist in the same repo, ie. 2 recipes. That's a bit fiddly though. I'd suggest incubating with the |
Thanks for the reply, guess I'll go that route indeed. |
I didn't notice the new The header of the inline popup should be updated with the revision the diff is computed against, something like:
Since you are merging this PR, do you prefer to make this change yourself? Or is it better if I merge |
@alvarogonzalezsotillo Please go ahead. |
@dgutov Just in case, you can find in https://github.com/alvarogonzalezsotillo/diff-hl/tree/unincubating-inline-popup a branch that has merged master, this PR and If you prefer I can merge |
Thanks! I've done the merge now, and simplified some bits and pieces. Please take a look, see whether everything still works to your expectations, and let's continue fixing and improving the feature in new issues and PRs. I hope to get around to refreshing the images (and adding a gif or two) sometime soon. |
This PR is a follow up of #145
I refactored the code to allow several backends to to show the differences of the current hunk. Currently,
posframe
andpopup
are implemented. Also, there is a modediff-hl-show-hunk-mode
with new key bindings (C-v x *
,C-v x {
andC-v x }
) and another modediff-hl-show-hunk-mouse-mode
to enable the mouse in the fringe and the margin.popup
seems to work fine from the begining.posframe
has been harder, but the current version works with Ubuntu (KDE, Gnome 3) and Windows.I would like to include
diff-hl-show-hunk
in thediff-hl-command-map
asC-x v *
, but It would require a dependency fromdiff-hl
todiff-hl-show-hunk
, instead of the other way arround (not very clean). Do you think it will be possible in any other way?I made minor changes in
README.md
, but I can add more instructions (see https://github.com/alvarogonzalezsotillo/diff-hl-show-hunk#customization)The images added to the readme file have not the same style as the previous ones. Maybe you can get a static image with your own settings and change them. If not, I can change my theme in emacs and take again all the images.
If you like this PR, I will need some directions about how to proceed with the FSF.