* [PATCH] userdiff: support Clojure
@ 2021-03-13 20:26 Nazarii Bardiuk via GitGitGadget
0 siblings, 0 replies; only message in thread
From: Nazarii Bardiuk via GitGitGadget @ 2021-03-13 20:26 UTC (permalink / raw)
To: git; +Cc: Nazarii Bardiuk, Nazarii Bardiuk
From: Nazarii Bardiuk <nazarii@bardiuk.com>
Add support for Clojure[1]. Include test cases for the xfuncname pattern
(t4018) and update documentation.
The xfuncname pattern matches any top level form except a line comment.
The word_regex has been constructed based on Reader documentation[2].
[1]: https://clojure.org
[2]: https://clojure.org/reference/reader
Signed-off-by: Nazarii Bardiuk <nazarii@bardiuk.com>
---
userdiff: support Clojure
Add support for Clojure1 [https://clojure.org]. Include test cases for
the xfuncname pattern (t4018) and update documentation.
The xfuncname pattern matches any top level form except a line comment.
The word_regex has been constructed based on Reader documentation2
[https://clojure.org/reference/reader].
Signed-off-by: Nazarii Bardiuk nazarii@bardiuk.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-902%2Fnbardiuk%2Fuserdiff-clojure-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-902/nbardiuk/userdiff-clojure-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/902
Documentation/gitattributes.txt | 2 ++
t/t4018-diff-funcname.sh | 1 +
| 8 ++++++++
t/t4018/clojure-function | 6 ++++++
t/t4018/clojure-ns | 10 ++++++++++
| 5 +++++
userdiff.c | 11 +++++++++++
7 files changed, 43 insertions(+)
create mode 100644 t/t4018/clojure-comment
create mode 100644 t/t4018/clojure-function
create mode 100644 t/t4018/clojure-ns
create mode 100644 t/t4018/clojure-reader-comment
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index e84e104f9325..a7734d413758 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -807,6 +807,8 @@ patterns are available:
- `bibtex` suitable for files with BibTeX coded references.
+- `clojure` suitable for source code in the Clojure language.
+
- `cpp` suitable for source code in the C and C++ languages.
- `csharp` suitable for source code in the C# language.
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 9675bc17db27..f126a349aa24 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -29,6 +29,7 @@ diffpatterns="
ada
bash
bibtex
+ clojure
cpp
csharp
css
--git a/t/t4018/clojure-comment b/t/t4018/clojure-comment
new file mode 100644
index 000000000000..5e20f41b554e
--- /dev/null
+++ b/t/t4018/clojure-comment
@@ -0,0 +1,8 @@
+(comment ;; RIGHT rich comment
+
+
+;; ignore comment
+
+
+ (do-something "ChangeMe"))
+
diff --git a/t/t4018/clojure-function b/t/t4018/clojure-function
new file mode 100644
index 000000000000..347790fd37f7
--- /dev/null
+++ b/t/t4018/clojure-function
@@ -0,0 +1,6 @@
+(defn RIGHT
+ []
+; ignore comment
+
+ (ChangeMe))
+
diff --git a/t/t4018/clojure-ns b/t/t4018/clojure-ns
new file mode 100644
index 000000000000..e3e2e5f4c986
--- /dev/null
+++ b/t/t4018/clojure-ns
@@ -0,0 +1,10 @@
+(ns RIGHT
+
+;; ignore comment
+
+ (:require [some.lib :refer [
+
+
+ ChangeMe
+
+ ]))
--git a/t/t4018/clojure-reader-comment b/t/t4018/clojure-reader-comment
new file mode 100644
index 000000000000..f17e51074558
--- /dev/null
+++ b/t/t4018/clojure-reader-comment
@@ -0,0 +1,5 @@
+#_((def commented-RIGHT-definition
+
+; ignore comment
+
+ ChangeMe))
diff --git a/userdiff.c b/userdiff.c
index 3f81a2261c5e..887264081e3c 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -44,6 +44,17 @@ PATTERNS("bash",
/* -- */
/* Characters not in the default $IFS value */
"[^ \t]+"),
+PATTERNS("clojure",
+ /* Ignore comments */
+ "!^;.*\n"
+ /* Top level forms */
+ "^[^ \t].*$",
+ /* Atoms, Keywords, Symbols */
+ "[#@:]?[^0-9][a-zA-Z0-9*+!-_'?<>=/.]+"
+ /* Numbers */
+ "|[-]?[0-9a-fA-Frxb/MN]+"
+ /* Characters */
+ "|[\\0-9a-fA-F]+"),
PATTERNS("dts",
"!;\n"
"!=\n"
base-commit: 13d7ab6b5d7929825b626f050b62a11241ea4945
--
gitgitgadget
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-13 20:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-13 20:26 [PATCH] userdiff: support Clojure Nazarii Bardiuk via GitGitGadget
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.