• What would be a suitable git diff hunk header for Scheme?

    From Atharva Raykar@21:1/5 to All on Sun Mar 28 07:43:25 2021
    Hi Schemers,

    If you have used git, you would have noticed the diff hunks have
    this format:

    @@ -k,l +n,m @@ TEXT ---> this is the hunk header
    + something added
    - something removed
    ...

    With most other languages, git provides built-in diff drivers,
    so if you used the diff driver for python you would get the
    enclosing function or class name in the location of TEXT
    above. Similarly other language drivers have important forms
    shown alongside the hunk header to make the give the diff a
    useful landmark.

    I have been working on a patch to introduce a driver for scheme[1]
    as well, but I needed some opinions from more seasoned schemers.

    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk headers
    that I should include, that will work well across most Scheme implementations?

    Regards
    Atharva

    [1] https://public-inbox.org/git/3def82fd-71a7-3ad9-0fa2-48598bfd3313@kdbg.org/T/#m85a1cbe58b1494d0dc43601bae446563b791fa9e

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Atharva Raykar@21:1/5 to All on Tue Mar 30 00:51:42 2021
    On Tuesday, March 30, 2021 at 1:12:24 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk
    headers that I should include, that will work well across most Scheme implementations?
    Perhaps `library` would be nice to have (`define-library` would already
    be covered by the above).

    Just to be clear, in the case where a change within a `define` that is inside a `library`, would you prefer the hunk header showing the `library` line or the `define` line in which the change was made?

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?utf-8?Q?G=C3=B6ran?= Weinholt@21:1/5 to Atharva Raykar on Tue Mar 30 09:42:22 2021
    Atharva Raykar <raykar.ath@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk
    headers that I should include, that will work well across most Scheme implementations?

    Perhaps `library` would be nice to have (`define-library` would already
    be covered by the above).

    --
    Göran Weinholt | https://weinholt.se/
    Debian developer | 73 de SA6CJK

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?utf-8?Q?G=C3=B6ran?= Weinholt@21:1/5 to Atharva Raykar on Tue Mar 30 15:58:47 2021
    Atharva Raykar <raykar.ath@gmail.com> writes:

    On Tuesday, March 30, 2021 at 1:12:24 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk
    headers that I should include, that will work well across most Scheme
    implementations?
    Perhaps `library` would be nice to have (`define-library` would already
    be covered by the above).

    Just to be clear, in the case where a change within a `define` that is inside a
    `library`, would you prefer the hunk header showing the `library` line or the `define` line in which the change was made?

    I believe that showing the `define` would be preferable.

    I've tried to think of anything else to match on, but nothing comes to
    mind. Will there be an opportunity for the community to try out these
    changes before they are included in git?

    --
    Göran Weinholt | https://weinholt.se/
    Debian developer | 73 de SA6CJK

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Atharva Raykar@21:1/5 to All on Tue Mar 30 10:21:50 2021
    On Tuesday, March 30, 2021 at 7:28:50 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    On Tuesday, March 30, 2021 at 1:12:24 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk
    headers that I should include, that will work well across most Scheme >> > implementations?
    Perhaps `library` would be nice to have (`define-library` would already >> be covered by the above).

    Just to be clear, in the case where a change within a `define` that is inside a
    `library`, would you prefer the hunk header showing the `library` line or the
    `define` line in which the change was made?
    I believe that showing the `define` would be preferable.

    I've tried to think of anything else to match on, but nothing comes to
    mind. Will there be an opportunity for the community to try out these changes before they are included in git?

    Here is a way to test the same functionality, without needing a
    patched version of git:

    1. In your repository's `.git/config` file add the following:

    [diff "scheme"]
    xfuncname = "^[\t ]*(\\(define[-* \t].*)$"
    wordRegex = "([^][)(}{[ \t])+"

    2. Add another file in the top level of your project called `.gitattributes` with
    these contents:

    *.scm diff=scheme

    And now if you run `git diff` over your scheme files, you should see hunk headers
    show up for your project. You can tweak the xfuncname regex to try out more constructs if it seems fit to do so.

    Another thing this would add is `git diff --word-diff` will show a diff for each
    individual word, and it's a little more language aware than the default word diff,
    as it will ignore parentheses.

    I also have my own fork of git, which will have this feature here, before it gets
    added in: https://github.com/tfidfwastaken/git

    I have not pushed all the changes yet, but either way I believe the first method
    would be easier to do than trying to build my version of git from source just to
    test this out.

    --
    Atharva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?utf-8?Q?G=C3=B6ran?= Weinholt@21:1/5 to Atharva Raykar on Wed Mar 31 08:57:44 2021
    Atharva Raykar <raykar.ath@gmail.com> writes:

    On Tuesday, March 30, 2021 at 7:28:50 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    On Tuesday, March 30, 2021 at 1:12:24 PM UTC+5:30, Göran Weinholt wrote: >> >> Atharva Raykar <rayka...@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk
    headers that I should include, that will work well across most Scheme >> >> > implementations?
    Perhaps `library` would be nice to have (`define-library` would already >> >> be covered by the above).

    Just to be clear, in the case where a change within a `define` that is inside a
    `library`, would you prefer the hunk header showing the `library` line or the
    `define` line in which the change was made?
    I believe that showing the `define` would be preferable.

    I've tried to think of anything else to match on, but nothing comes to
    mind. Will there be an opportunity for the community to try out these
    changes before they are included in git?

    Here is a way to test the same functionality, without needing a
    patched version of git:

    1. In your repository's `.git/config` file add the following:

    [diff "scheme"]
    xfuncname = "^[\t ]*(\\(define[-* \t].*)$"
    wordRegex = "([^][)(}{[ \t])+"

    2. Add another file in the top level of your project called `.gitattributes` with
    these contents:

    *.scm diff=scheme

    Will this diff driver be default for *.scm? There are other file
    extensions that should be added in that case, such as *.sls, *.sps,
    *.sld and maybe some more. Here's a list, although not all are
    applicable: <https://registry.scheme.org/#filename-extension>

    And now if you run `git diff` over your scheme files, you should see hunk headers
    show up for your project. You can tweak the xfuncname regex to try out more constructs if it seems fit to do so.

    Adding `library` gave good results; I feel that it makes the context
    clearer for changes at the top of libraries.

    --
    Göran Weinholt | https://weinholt.se/
    Debian developer | 73 de SA6CJK

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Atharva Raykar@21:1/5 to All on Wed Mar 31 04:21:47 2021
    On Wednesday, March 31, 2021 at 12:27:47 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    On Tuesday, March 30, 2021 at 7:28:50 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    On Tuesday, March 30, 2021 at 1:12:24 PM UTC+5:30, Göran Weinholt wrote:
    Atharva Raykar <rayka...@gmail.com> writes:

    [...]
    For now I am only taking the following forms for the hunk headers: >> >> >
    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk >> >> > headers that I should include, that will work well across most Scheme
    implementations?
    Perhaps `library` would be nice to have (`define-library` would already
    be covered by the above).

    Just to be clear, in the case where a change within a `define` that is inside a
    `library`, would you prefer the hunk header showing the `library` line or the
    `define` line in which the change was made?
    I believe that showing the `define` would be preferable.

    I've tried to think of anything else to match on, but nothing comes to
    mind. Will there be an opportunity for the community to try out these
    changes before they are included in git?

    Here is a way to test the same functionality, without needing a
    patched version of git:

    1. In your repository's `.git/config` file add the following:

    [diff "scheme"]
    xfuncname = "^[\t ]*(\\(define[-* \t].*)$"
    wordRegex = "([^][)(}{[ \t])+"

    2. Add another file in the top level of your project called `.gitattributes` with
    these contents:

    *.scm diff=scheme
    Will this diff driver be default for *.scm? There are other file
    extensions that should be added in that case, such as *.sls, *.sps,
    *.sld and maybe some more. Here's a list, although not all are
    applicable: <https://registry.scheme.org/#filename-extension>

    This won't be an issue, because the patch will not hardcode the `.gitattribute` values.
    So even after scheme's driver is added, it's still on the user to add the .gitattribute
    file and specify which file types and directories should use the diff driver.

    The documentation for this is here: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header

    So in the builtin patterns, scheme will be added as well.

    And now if you run `git diff` over your scheme files, you should see hunk headers
    show up for your project. You can tweak the xfuncname regex to try out more
    constructs if it seems fit to do so.
    Adding `library` gave good results; I feel that it makes the context
    clearer for changes at the top of libraries.

    Thanks for letting me know. I will add that to the diff driver as well.

    --
    Atharva

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Atharva Raykar@21:1/5 to Atharva Raykar on Thu Jul 1 04:52:30 2021
    As of Git v2.32.0, adding diff=scheme in a .gitattributes file will make Git be smarter with the diff output for Scheme (with all of its variants) code. You can get function context around diff hunks, along with better word-diff output that is aware of
    Scheme keywords.

    Thanks to Göran Weinholt for giving feedback on this feature before it was merged.

    On Sunday, March 28, 2021 at 8:13:27 PM UTC+5:30, Atharva Raykar wrote:
    Hi Schemers,

    If you have used git, you would have noticed the diff hunks have
    this format:

    @@ -k,l +n,m @@ TEXT ---> this is the hunk header
    + something added
    - something removed
    ...

    With most other languages, git provides built-in diff drivers,
    so if you used the diff driver for python you would get the
    enclosing function or class name in the location of TEXT
    above. Similarly other language drivers have important forms
    shown alongside the hunk header to make the give the diff a
    useful landmark.

    I have been working on a patch to introduce a driver for scheme[1]
    as well, but I needed some opinions from more seasoned schemers.

    For now I am only taking the following forms for the hunk headers:

    - `define`
    - `define-syntax`
    - `define-*` (any other define form that may have been introduced via macro)

    Is there any other form that would make a useful landmark for hunk headers that I should include, that will work well across most Scheme implementations?

    Regards
    Atharva

    [1] https://public-inbox.org/git/3def82fd-71a7-3ad9...@kdbg.org/T/#m85a1cbe58b1494d0dc43601bae446563b791fa9e

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)