public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Scott L. Burson" <Scott@sympoiesis•com>
To: Junio C Hamano <gitster@pobox•com>
Cc: "Johannes Sixt" <j6t@kdbg•org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail•com>,
	"Jaydeep P Das" <jaydeepjd.8914@gmail•com>,
	"Atharva Raykar" <raykar.ath@gmail•com>,
	git@vger•kernel.org,
	"Scott L. Burson via GitGitGadget" <gitgitgadget@gmail•com>
Subject: Re: [PATCH] diff: "lisp" userdiff_driver
Date: Mon, 17 Nov 2025 15:23:19 -0800	[thread overview]
Message-ID: <CAF5LJ4CMtEaJgDYRHXvCTUm9Pjpv2GAsMQN9D-DL-Ric3ADMXQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqbjl2ee8t.fsf@gitster.g>

On Sat, Nov 15, 2025 at 9:30 PM Junio C Hamano <gitster@pobox•com> wrote:
>
> Johannes Sixt <j6t@kdbg•org> writes:
>
> >> +     /* Either an unindented left paren, or a slightly indented line
> >> +      * starting with "(def" */
> >> +     "^((\\(|:space:{1,2}\\(def).*)$",
> >
> > Compared to the Scheme driver, this regular expression is
> >
> > - more restrictive because it does not permit arbitrary indentation;
> >
> > - less restrictive because it permits everything that begins with "(def".
> >
> > What would happen if this regular expression were added to the Scheme
> > driver? Would it pick up additional and unwanted hunk headers is typical
> > Scheme code?

Hmm, we haven't heard from Atharva.  I'll try asking around in the
Scheme community.

The regex I proposed has a bug.  The use of the Posix character class
is incorrect, because that class includes tabs.  I will replace it
with a literal space.  Also, many Lisps, including Common Lisp in its
default configuration, are case-insensitive, and at least in the
1970s, it wasn't completely unheard-of to write Lisp code in
uppercase; I'll change the entry to use 'IPATTERN'.

> As we generally assume that the file being edited is syntactically
> sound, even if one lisp variant understands "(deffoo" and others do
> not, it should be generally fine for the pattern to say something
> like "at the beginning of the line, optionally following a few
> spaces, four-letter sequence '(def' is likely to be the beginning of
> a function definition", as long as there is some convention that
> user defined functions and macros, unless they are to behave
> similarly to "(defun", would not be named so confusingly to start
> with d-e-f.

Agreed, but this is not the most important point.  The greater
potential for false positives comes from the rule (in my proposal)
that a left parenthesis in column 0 is taken as indicating a top-level
definition, without even looking at the following characters.
Although Lisp dialects certainly vary, I have not seen one in which
standard indentation practice does not indent internal expressions;
certainly, Lisp mode in Emacs indents them.  And, I think the rule
really does need to be that broad, because top-level forms don't
always begin with "def"; indeed, one can put any executable expression
at top level in a source file to perform load-time initializations.

It's only when there is some indentation that I think the regex needs
to require a word beginning with "def".

> It would be nice if a single set of rules can cover what existing
> scheme patterns cover, Emacs lisp, and Common lisp.

Agreed.  I do think it would be a little better for non-Scheme users
if the single driver were named "lisp" instead of "scheme".  Renaming
the driver out from under the Scheme community, though, seems like it
would be unfriendly, even after a deprecation period.

One solution would be to add an aliasing mechanism to the
driver table.  Perhaps there would be other use cases for it.  If you
would consider a patch along these lines, I can code it up.

  reply	other threads:[~2025-11-17 23:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-15 10:17 [PATCH] diff: "lisp" userdiff_driver Scott L. Burson via GitGitGadget
2025-11-15 17:06 ` Johannes Sixt
2025-11-15 23:32   ` Scott L. Burson
2025-11-20 16:47     ` D. Ben Knoble
2025-11-27  2:10       ` Scott L. Burson
2025-11-16  5:30   ` Junio C Hamano
2025-11-17 23:23     ` Scott L. Burson [this message]
2025-11-18  4:38       ` Junio C Hamano
2025-11-27  2:38 ` [PATCH v2 0/2] userdiff: extend Scheme support to cover other Lisp dialects Scott L. Burson via GitGitGadget
2025-11-27  2:38   ` [PATCH v2 1/2] diff: "lisp" userdiff_driver Scott L. Burson via GitGitGadget
2025-11-27 10:32     ` Scott L. Burson
2025-11-27 10:51       ` Johannes Sixt
2025-11-27  2:38   ` [PATCH v2 2/2] merge with Scheme regexp; fix bugs Scott L. Burson via GitGitGadget
2025-11-27 16:09     ` Johannes Sixt
2025-12-02 10:27       ` Johannes Sixt
2026-01-14  6:18         ` Scott L. Burson
2026-01-14  8:40           ` Johannes Sixt
2026-01-15 23:18   ` [PATCH v3 0/2] userdiff: extend Scheme support to cover other Lisp dialects Scott L. Burson via GitGitGadget
2026-01-15 23:18     ` [PATCH v3 1/2] userdiff: tighten word-diff test case of the scheme driver Johannes Sixt via GitGitGadget
2026-01-15 23:18     ` [PATCH v3 2/2] userdiff: extend Scheme support to cover other Lisp dialects Scott L. Burson via GitGitGadget
2026-01-16  8:49       ` Johannes Sixt
2026-01-17  2:09         ` Scott L. Burson
2026-01-17  8:15           ` Johannes Sixt
2026-04-15  2:27     ` [PATCH v4 0/2] " Scott L. Burson via GitGitGadget
2026-04-15  2:27       ` [PATCH v4 1/2] userdiff: tighten word-diff test case of the scheme driver Johannes Sixt via GitGitGadget
2026-04-15  2:27       ` [PATCH v4 2/2] userdiff: extend Scheme support to cover other Lisp dialects Scott L. Burson via GitGitGadget
2026-04-15  6:54       ` [PATCH v4 0/2] " Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAF5LJ4CMtEaJgDYRHXvCTUm9Pjpv2GAsMQN9D-DL-Ric3ADMXQ@mail.gmail.com \
    --to=scott@sympoiesis$(echo .)com \
    --cc=avarab@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitgitgadget@gmail$(echo .)com \
    --cc=gitster@pobox$(echo .)com \
    --cc=j6t@kdbg$(echo .)org \
    --cc=jaydeepjd.8914@gmail$(echo .)com \
    --cc=raykar.ath@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox