git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nazarii Bardiuk via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Nazarii Bardiuk <nazarii@bardiuk.com>,
	Nazarii Bardiuk <nazarii@bardiuk.com>
Subject: [PATCH] userdiff: support Clojure
Date: Sat, 13 Mar 2021 20:26:30 +0000	[thread overview]
Message-ID: <pull.902.git.1615667191368.gitgitgadget@gmail.com> (raw)

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 +
 t/t4018/clojure-comment         |  8 ++++++++
 t/t4018/clojure-function        |  6 ++++++
 t/t4018/clojure-ns              | 10 ++++++++++
 t/t4018/clojure-reader-comment  |  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
diff --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
+
+                              ]))
diff --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

                 reply	other threads:[~2021-03-13 20:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=pull.902.git.1615667191368.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nazarii@bardiuk.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).