Subject: Re: [PATCH] diff: "lisp" userdiff_driver

From: Junio C Hamano <[email-masked]>
Date: Sat, 15 Nov 2025 21:30:10 -0800

Johannes Sixt <[email-masked]> 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?

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.

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