delta icon indicating copy to clipboard operation
delta copied to clipboard

Is there a way to config delta to not show the 'Class/Function' section?

Open simokhwang opened this issue 5 years ago • 10 comments

Is there a way to config delta to not show the 'Class/Function' section in each diff?

Thank you.

simokhwang avatar Oct 23 '20 14:10 simokhwang

Hi @simokhwang, you can do hunk-header-style = omit. However, is there something you'd like to display at that location instead (like some separating characters for example)? Otherwise, won't it be hard to read the diff no clear demarcation between distinct hunks? Ref https://github.com/dandavison/delta/issues/319#issuecomment-695825152 where a similar request was made. cc @nortliteborealis are you still looking for different (more minimal) hunk-header customization? let's move minimal hunk-header discussion to this ticket.

You could also use

    hunk-header-style = raw
    hunk-header-decoration-style = none
image

or

    hunk-header-style = raw
    hunk-header-decoration-style = ul
image

By the way, the low-level documentation of individual delta options (delta --help) contains this:

--hunk-header-style <hunk-header-style>
    Style (foreground, background, attributes) for the hunk-header. See STYLES section. The style 'omit' can be
    used to remove the hunk header section from the output [default: syntax]

dandavison avatar Oct 23 '20 15:10 dandavison

Thanks for your reply and creating delta. It is a great tool.

Basically, i find that 'class/function' section takes up a lot of screen space. So it will make me longer (compare to vanilla git diff) to scroll thru the differences. So i am looking for ways to make delta result more compact.

On Fri, 23 Oct 2020 at 08:15, Dan Davison [email protected] wrote:

Hi @simokhwang https://github.com/simokhwang, you can do hunk-header-style = omit. However, is there something you'd like to display at that location instead (like some separating characters for example)? Otherwise, won't it be hard to read the diff no clear demarcation between distinct hunks? Ref #319 (comment) https://github.com/dandavison/delta/issues/319#issuecomment-695825152 where a similar request was made. cc @nortliteborealis https://github.com/nortliteborealis are you still looking for different (more minimal) hunk-header customization? let's move minimal hunk-header discussion to this ticket.

You could also use

hunk-header-style = raw
hunk-header-decoration-style = none

[image: image] https://user-images.githubusercontent.com/52205/97021415-cef17700-1520-11eb-9541-704cb70332ce.png

or

hunk-header-style = raw
hunk-header-decoration-style = ul

[image: image] https://user-images.githubusercontent.com/52205/97021478-e03a8380-1520-11eb-9c27-787b1ac71f70.png

By the way, the full documentation of delta is obtained by doing delta --help, which mentions this:

--hunk-header-style Style (foreground, background, attributes) for the hunk-header. See STYLES section. The style 'omit' can be used to remove the hunk header section from the output [default: syntax]

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dandavison/delta/issues/364#issuecomment-715404892, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPUCGOHI5FP2ROUX6JIDOLSMGMZDANCNFSM4S4UZGBQ .

simokhwang avatar Oct 23 '20 18:10 simokhwang

@simokhwang, thanks. Here's a quick comparison of some possible customizations, including one that is equally compact with default git diff. Does this help?

Vanilla git diff (3 lines)

 }
@@ -381,20 +376,25 @@ fn handle_hunk_header_line(
     config: &Config,

Delta default (7 lines)

}

────────────────────────────┐
fn handle_hunk_header_line( │
────────────────────────────┘
376
    config: &Config,

Delta custom I (5 lines)

[delta]
    line-numbers = false
    hunk-header-decoration-style = ul
}

fn handle_hunk_header_line( 
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    config: &Config,

Delta custom II (3 lines)

[delta]
    line-numbers = false
    hunk-header-style = raw
    hunk-header-decoration-style = none
}
@@ -381,20 +376,25 @@ fn handle_hunk_header_line(
    config: &Config,

dandavison avatar Oct 23 '20 19:10 dandavison

For me the issue is that a lot of the time the "class name" is actually just the first line of the hunk and it makes no sense to draw a box around it - it's just not special. For example: 2020-10-29-14:11:10

In these cases I would expect delta to just not display anything there, or maybe just have some colored underscores to seperate the hunks.

For now I'll be using hunk-header-style = omit since the changing line numbers and the empty line is enough separation for me. 2020-10-29-14:15:17

(yes I'm aware the colors are horrible, configuring them right now :P )

SuperCuber avatar Oct 29 '20 12:10 SuperCuber

a lot of the time the "class name" is actually just the first line of the hunk and it makes no sense to draw a box around it - it's just not special.

Right, I understand. Just to be clear: it is git that identifies these hunk headers, not delta, so you will see exactly the same headers under vanilla git. So if you were to use hunk-header-style=raw and hunk-header-decoration-style = none you'd be getting pretty much the vanilla git experience.

In these cases I would expect delta to just not display anything there, or maybe just have some colored underscores to separate the hunks.

The question is, how is delta to know when git has done a "useful job" of pulling out a hunk header vs when git has pulled out a "boring" line?

Incidentally, have you seen this gist and accompanying blog post? https://gist.github.com/tekin/12500956bd56784728e490d8cef9cb81 I believe it improves the hunk header selection algorithm for several languages, but I agree that for things like configuration files that we will still be dealing with meaningless "header" choices.

I'm happy to receive more suggestions for ways delta can make these headers better. It sounds like one feature we could add would be an option to insert a simple separator of some sort instead of displaying any of the actual text from the hunk header.

dandavison avatar Oct 29 '20 15:10 dandavison

it is git that identifies these hunk headers, not delta

I guess the solution to that would be on the git side then, maybe you can configure the algorithm for certain file types to show an empty line and then delta could detect whether the hunk header is empty... But that sounds pretty implausible to get it working and it would require the user to edit their gitattributes and stuff...

Adding an option to insert a constant separator for users who just want to sidestep the whole issue sounds like a good idea to me.

SuperCuber avatar Oct 29 '20 16:10 SuperCuber

Adding an option to insert a constant separator for users who just want to sidestep the whole issue sounds like a good idea to me.

Yes, I agree. Seeing as they are (a) not actually part of ones diff and (b) not helpful in several language contexts, giving delta an option to minimize the amount of unnecessary information our brains are processing seems like the right thing to do.

So the next question is how to specify this. I think that we want this to be expressed using hunk-header-style and hunk-header-decoration-style. It's seeming to me like this should, but does not, do it:

[delta]
    hunk-header-style = omit
    hunk-header-decoration-style = ul

In fact what that does is just nuke the entire thing so you don't even get the ul. So if we could get that to render the ul separator with no header (we also have ol, and we are free to implement other things like ul-dashed or whatever) and for people who really want to nuke the entire thing that would be

[delta]
    hunk-header-style = omit
    hunk-header-decoration-style = none

cc @ryuta69 who might also have thoughts here.

dandavison avatar Oct 29 '20 16:10 dandavison

An additional idea is to support this on a per-filetype basis, although I imagine it would make the configuration a bit convoluted

SuperCuber avatar Oct 29 '20 17:10 SuperCuber

Hi. To me, I'm exactly same as @SuperCuber currently.

For now I'll be using hunk-header-style = omit since the changing line numbers and the empty line is enough separation for me.

But improving this is interesting. Below makes sense.

In fact what that does is just nuke the entire thing so you don't even get the ul. So if we could get that to render the ul separator with no header (we also have ol, and we are free to implement other things like ul-dashed or whatever) and for people who really want to nuke the entire thing that would be

ghost avatar Oct 30 '20 03:10 ghost

Any news on this?

brodmo avatar Dec 26 '24 19:12 brodmo