Re: [PATCH] diff: "lisp" userdiff_driver
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 16, 2025, 05:30 UTC
- Message-ID
- <xmqqbjl2ee8t.fsf@gitster.g>
- In-Reply-To
- <773d3233-c890-4df9-8f7e-32ff8a48651e@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 13 quoted lines
>> + /* 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.