From da99bb0bcd8c92e0d6de8b929b67095fae251f88 Mon Sep 17 00:00:00 2001 From: "Scott L. Burson" Date: Fri, 14 Nov 2025 15:16:57 -0800 Subject: [PATCH 1/2] diff: "lisp" userdiff_driver The "scheme" driver doesn't quite work for Common Lisp. This driver is very generic and should work for almost any dialect of Lisp, including Common Lisp. Signed-off-by: Scott L. Burson --- userdiff.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/userdiff.c b/userdiff.c index fe710a68bfdfa6..e127b4a1f1cd22 100644 --- a/userdiff.c +++ b/userdiff.c @@ -249,6 +249,14 @@ PATTERNS("kotlin", "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" /* unary and binary operators */ "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"), +PATTERNS("lisp", + /* Either an unindented left paren, or a slightly indented line + * starting with "(def" */ + "^((\\(|:space:{1,2}\\(def).*)$", + /* Common Lisp symbol syntax allows arbitrary strings between vertical bars */ + "\\|([^\\\\]|\\\\\\\\|\\\\\\|)*\\|" + /* All other words are delimited by spaces or parentheses/brackets/braces */ + "|([^][(){} \t])+"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*", /* -- */ From 86315aa3e36afa1ee741a2c9b9e95a71ca569302 Mon Sep 17 00:00:00 2001 From: "Scott L. Burson" Date: Wed, 26 Nov 2025 17:23:48 -0800 Subject: [PATCH 2/2] merge with Scheme regexp; fix bugs This commit merges (by disjoining) the new generic Lisp regexp into the existing Scheme regexp. It also fixes two bugs: the new regexp was unintentionally allowing tabs, and the matching of "(def" should be case-insensitive. Signed-off-by: Scott L. Burson --- userdiff.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/userdiff.c b/userdiff.c index e127b4a1f1cd22..b67dfddbeffb3d 100644 --- a/userdiff.c +++ b/userdiff.c @@ -249,14 +249,6 @@ PATTERNS("kotlin", "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" /* unary and binary operators */ "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"), -PATTERNS("lisp", - /* Either an unindented left paren, or a slightly indented line - * starting with "(def" */ - "^((\\(|:space:{1,2}\\(def).*)$", - /* Common Lisp symbol syntax allows arbitrary strings between vertical bars */ - "\\|([^\\\\]|\\\\\\\\|\\\\\\|)*\\|" - /* All other words are delimited by spaces or parentheses/brackets/braces */ - "|([^][(){} \t])+"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*", /* -- */ @@ -352,14 +344,21 @@ PATTERNS("rust", "|[0-9][0-9_a-fA-Fiosuxz]*(\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?" "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"), PATTERNS("scheme", - "^[\t ]*(\\(((define|def(struct|syntax|class|method|rules|record|proto|alias)?)[-*/ \t]|(library|module|struct|class)[*+ \t]).*)$", + /* A possibly indented left paren followed by a Scheme keyword. */ + "^[\t ]*(\\(((define|def(struct|syntax|class|method|rules|record|proto|alias)?)[-*/ \t]|(library|module|struct|class)[*+ \t]).*)$\n" + /* + * For other Lisp dialects: either an unindented left paren, or a + * slightly indented line starting with "(def". + */ + "^((\\(| {1,2}\\([Dd][Ee][Ff]).*)$", /* - * R7RS valid identifiers include any sequence enclosed - * within vertical lines having no backslashes + * The union of R7RS and Common Lisp symbol syntax: allows arbitrary + * strings between vertical bars, including escaped backslashes and + * vertical bars. */ - "\\|([^\\\\]*)\\|" + "\\|([^\\\\]|\\\\\\\\|\\\\\\|)*\\|" /* All other words should be delimited by spaces or parentheses */ - "|([^][)(}{[ \t])+"), + "|([^][)(}{ \t])+"), PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"), { .name = "default", .binary = -1 },