# [PATCH] userdiff: add support for Fountain documents

3 messages from 2015-07-19 to 2015-07-21. Participants: Zoë Blade, Junio C Hamano, Zoë Blade.
Thread: https://gitlist.dev/t/39891

## Zoë Blade, 2015-07-19 12:31

Subject: [PATCH] userdiff: add support for Fountain documents
Message-ID: <1437309082-19060-1-git-send-email-zoe@bytenoise.co.uk>
URL: https://gitlist.dev/e/1437309082-19060-1-git-send-email-zoe%40bytenoise.co.uk

```
Add support for Fountain, a plain text screenplay format.  Git
facilitates not just programming specifically, but creative writing
in general, so it makes sense to also support other plain text
documents besides source code.

In the structure of a screenplay specifically, scenes are roughly
analogous to functions, in the sense that it makes your job easier
if you can see which ones were changed in a given range of patches.

More information about the Fountain format can be found on its
official website, at http://fountain.io .

Signed-off-by: Zoë Blade <zoe@bytenoise.co.uk>
---
 Documentation/gitattributes.txt | 2 ++
 t/t4018-diff-funcname.sh        | 1 +
 t/t4018/fountain-scene          | 4 ++++
 userdiff.c                      | 2 ++
 4 files changed, 9 insertions(+)
 create mode 100644 t/t4018/fountain-scene

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 81fe586..e3b1de8 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -527,6 +527,8 @@ patterns are available:
 
 - `fortran` suitable for source code in the Fortran language.
 
+- `fountain` suitable for Fountain documents.
+
 - `html` suitable for HTML/XHTML documents.
 
 - `java` suitable for source code in the Java language.
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 1dbaa38..67373dc 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -31,6 +31,7 @@ diffpatterns="
 	cpp
 	csharp
 	fortran
+	fountain
 	html
 	java
 	matlab
diff --git a/t/t4018/fountain-scene b/t/t4018/fountain-scene
new file mode 100644
index 0000000..6b3257d
--- /dev/null
+++ b/t/t4018/fountain-scene
@@ -0,0 +1,4 @@
+EXT. STREET RIGHT OUTSIDE - DAY
+
+CHARACTER
+You didn't say the magic phrase, "ChangeMe".
diff --git a/userdiff.c b/userdiff.c
index 2ccbee5..5a600d6 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -35,6 +35,8 @@ IPATTERN("fortran",
 	  * they would have been matched above as a variable anyway. */
 	 "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
 	 "|//|\\*\\*|::|[/<>=]="),
+PATTERNS("fountain", "^((\\.|(([Ii][Nn][Tt]|[Ee][Ss][Tt]|[Ee][Xx][Tt])?\\.?|[Ii]([Nn][Tt])?\\.?/[Ee]([Xx][Tt])?\\.?) ).+)$",
+	 "[^ \t-]+"),
 PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
 	 "[^<>= \t]+"),
 PATTERNS("java",
-- 
2.5.0.rc2.28.g6003e7f.dirty

```

## Junio C Hamano, 2015-07-20 21:17

Subject: Re: [PATCH] userdiff: add support for Fountain documents
Message-ID: <xmqqegk2y1dm.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqegk2y1dm.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1437309082-19060-1-git-send-email-zoe@bytenoise.co.uk>

```
Zoë Blade <zoe@bytenoise.co.uk> writes:

> diff --git a/userdiff.c b/userdiff.c
> index 2ccbee5..5a600d6 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -35,6 +35,8 @@ IPATTERN("fortran",
>  	  * they would have been matched above as a variable anyway. */
>  	 "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
>  	 "|//|\\*\\*|::|[/<>=]="),
> +PATTERNS("fountain", "^((\\.|(([Ii][Nn][Tt]|[Ee][Ss][Tt]|[Ee][Xx][Tt])?\\.?|[Ii]([Nn][Tt])?\\.?/[Ee]([Xx][Tt])?\\.?) ).+)$",
> +	 "[^ \t-]+"),

Wouldn't IPATTERN() be a better choice here?

>  PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
>  	 "[^<>= \t]+"),
>  PATTERNS("java",

```

## Zoë Blade, 2015-07-21 13:23

Subject: Re: [PATCH] userdiff: add support for Fountain documents
Message-ID: <F67D2953-FCA5-43F8-A370-13C77B14553B@bytenoise.co.uk>
URL: https://gitlist.dev/e/F67D2953-FCA5-43F8-A370-13C77B14553B%40bytenoise.co.uk
In-Reply-To: <xmqqegk2y1dm.fsf@gitster.dls.corp.google.com>

```
On 20 Jul 2015, at 22:17, Junio C Hamano <gitster@pobox.com> wrote:

>> +PATTERNS("fountain", "^((\\.|(([Ii][Nn][Tt]|[Ee][Ss][Tt]|[Ee][Xx][Tt])?\\.?|[Ii]([Nn][Tt])?\\.?/[Ee]([Xx][Tt])?\\.?) ).+)$",
>> +	 "[^ \t-]+"),
> 
> Wouldn't IPATTERN() be a better choice here?

Good point, thank you!  Much better:

IPATTERN("fountain", "^((\\.|((int|est|ext)?\\.?|i(nt)?\\.?/e(xt)?\\.?) ).+)$", "[^ \t-]+"),

It looks like some of the others might benefit from being case insensitive too, but I'm not sure, and at any rate it would warrant a separate patch.

I'll send another revision next... :)

Thanks,
Zoë.
```
