digraphs: parse vim :digraphs to indicate extensions
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 21 Feb 2015 03:55:48 +0000 (04:55 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Jun 2015 03:43:41 +0000 (05:43 +0200)
Run vim to find differences from RFC 1345.
Much easier than trying to parse the source code, and not really a problem
as it's usually installed and rarely changes.

Makefile
base.css
digraphs.plp
tools/mkcharinfo
tools/mkdigraphs-vim [new file with mode: 0755]

index c94599666838d3c4003c47cf3580a6385bdd3e07..b9be7330c2e45f4eed61f71c53f3909702525039 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,9 @@ data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
 data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
        $< $(word 2,$^) >$@
 
+data/digraphs-vim.inc.pl: tools/mkdigraphs-vim
+       $< >$@
+
 digraphs.inc.pl: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-shiar.inc.pl unicode-char.inc.pl
        $< >$@
 
index 7a2d4e7ecc8d1fbf392e112b6fb2cd08b1e77d49..c685acd827bf7c84b55b27c90d9701c0c952f21e 100644 (file)
--- a/base.css
+++ b/base.css
@@ -331,7 +331,8 @@ table.dimap {
 .X  {background: #FFF} /* unidentified */
 #digraphs .Xa {color: #0A0} /* ascii */
 #digraphs .Xl {color: #070} /* latin1 */
-#digraphs .Xz {color: #D00} /* proposed */
+#digraphs .u-prop {color: #D00} /* proposed */
+#digraphs .u-prop.ex {color: #A44} /* experimental, disfavoured */
 
 .Lm, .Mc, .Me, .Zl, .Zp {background: #F00} /* unstyled */
 .X > span               {background: #888} /* invisible contents */
@@ -448,7 +449,7 @@ table.dimap {
 .Xr:hover                                  {background: #FFF} /* reserved */
 .Xa:hover {outline: 1px solid #0F0} /* ascii */
 .Xl:hover {outline: 1px solid #0C0} /* latin1 */
-.Xz:hover {outline: 1px solid #F00} /* proposed */
+.u-prop:hover {outline: 1px solid #F00} /* proposed */
 .l0:hover                                  {background: #888}
 .l1:hover                                  {background: #F88}
 .l2:hover                                  {background: #FC8}
index 702e3e6054fcdc959eba43ea7be0f4d32d83e3d6..a78a90c043d72c2d811aa742f2e5f8983408277a 100644 (file)
@@ -19,7 +19,7 @@ Html({
 <p>i^k in <a href="/vi">Vim</a>.
 Also see <a href="/unicode">common digraphs</a>.</p>
 
-<p class="aside">Unofficial <span class="Xz">proposals</span>
+<p class="aside">Unofficial <span class="u-prop ex">proposals</span>
 are available as <a href="/digraphs.vim">ex commands</a>.</p>
 
 <:
@@ -99,7 +99,9 @@ print "</table>\n";
        <td class="X">unicode
        <td class="X Xl">latin1
        <td class="X Xa">ascii
-       <td class="X Xz">proposed
+       <td class="X u-prop">vim extension
+       <td class="X u-prop ex">proposal
+       <td class="X ex">not in vim
        </table>
 </div>
 
index 1cac30ad7ee597fe4f288b7418f5f09e591db184..2c006c5d34fd202cc8aec19648953516796116be 100755 (executable)
@@ -48,9 +48,10 @@ eval {
 
 my %diinc = (
        'data/digraphs-rfc.inc.pl' => 'u-di',
-       'data/digraphs-shiar.inc.pl' => 'u-prop Xz',
+       'data/digraphs-shiar.inc.pl' => 'u-prop ex',
+       'data/digraphs-vim.inc.pl' => 'u-prop',
 );
-for (keys %diinc) {
+for (sort keys %diinc) {
        -e $_ or next;
        my $di = do $_ or die "Error reading digraphs file $_: ", $@ || $!;
        while (my ($mnem, $cp) = each %$di) {
@@ -82,6 +83,10 @@ for my $chr (keys %info) {
 
        $info->{$_} = $info{$chr}->{$_} for keys %{ $info{$chr} };
 
+       # official digraphs either lose vim flag or gain experimental
+       delete $info->{class}->{'u-prop'} or $info->{class}->{ex}++
+               if $info->{class}->{'u-di'};
+
        # categorise by unicode types and writing script
        $info->{class}->{$_}++ for $info->{category};
        $info->{class}->{$_}++ for $info->{script} || ();
diff --git a/tools/mkdigraphs-vim b/tools/mkdigraphs-vim
new file mode 100755 (executable)
index 0000000..d47a733
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+vim -e -cdigraphs -cq | perl -CSD -nE '
+       BEGIN {
+               say "+{";
+       }
+               say "q{$1} => $3," while /\G(\S\S) (.[^ ]*) +([0-9]+)\s+/g;
+       END {
+               say "}";
+       }
+'