grml-zsh-refcard.tex.in: update copyright information
[grml-gen-zshrefcard.git] / genrefcard.pl
index d50e91b..057142e 100755 (executable)
@@ -2,7 +2,16 @@
 use strict;
 #{{{ readme
 ### Author: Frank Terbeck <ft@bewatermyfriend.org>
-### GPLv2
+###
+### This file is free software: you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published
+### by the Free Software Foundation, either version 3 of the License,
+### or (at your option) any later version.
+###
+### This file is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
 ###
 ### generate grml zsh refcard.
 ### #v#: variables
@@ -263,8 +272,9 @@ sub __abbrev { #{{{
     my ($sec, $desc) = @_;
     my ($abbrev, $value, $doc);
 
+    xprint(1, "$ln, $i\n");
     while ($ln <= $i) { # the global $i
-        if ($input[$ln] =~ m!^\s*\#A[0-9]*\#!) {
+        if ($input[$ln] =~ m!^\s*#A[0-9]*#!) {
             xprint(1, "Ending abbreviation handling in line $ln.\n");
             $ln++;
             return 1;
@@ -275,12 +285,12 @@ sub __abbrev { #{{{
             $doc = $1;
         }
 
-        if ($input[$ln] =~ m!\s*['"]([^"']*)['"]\s\$?['"]([^"']*)['"]!) {
+        if ($input[$ln] =~ m!^\s*['"]([^"']*)['"]\s+\$?['"]([^"']*)['"]!) {
             $abbrev = $1; $value = &escape_string($2);
             xprint(2, "ab: $abbrev -> $value ($doc);\n");
             push(@{ $data{"abbrev-$secmap[$sec]"} }, "\\command\{$abbrev\}\{\\kbd\{$value" . ($doc ne '' ? "\}\\quad $doc" : "\}") . "\}");
         } else {
-            return 0;
+            xprint(0, "Line didn't look like abbreviation in abbreviations section: " . $input[$ln] . "\n");
         }
         $ln++;
     }
@@ -354,6 +364,25 @@ sub __keybinding { #{{{
        #xprint(0, "!-> DEBUG: kbd: $kbd - value: $value - desc: $desc\n");
 
         push(@{ $data{"keybindings-$secmap[$sec]"} }, "\\command\{$kbd\}\{$desc\}");
+    } elsif ($input[$ln] =~ m!^.*bind2maps\s+([^-])+--\s+(.*)!) {
+        my ($maps, $rest) = ($1, $2);
+        my (@a) = split /\s+/, $rest, 2;
+        if ($a[0] ne q{-s}) {
+            push(@{ $data{"keybindings-$secmap[$sec]"} },
+                 "\\command\{$a[0]\}\{$desc\}");
+            return 1;
+        }
+        my $seq;
+        $rest = $a[1];
+        if ($rest =~ m!^'([^']+)'\s+!) {
+            $seq = $1;
+        } elsif ($rest =~ m!^"([^"]+)"\s+!) {
+            $seq = $1;
+        } else {
+            $seq = $rest;
+        }
+        $seq = demystify_keys($seq);
+        push(@{ $data{"keybindings-$secmap[$sec]"} }, "\\command\{$seq\}\{$desc\}");
     } else {
         return 0;
     }