#!/usr/local/bin/perl $QUERY = $ENV{'QUERY_STRING'}; $KEYMAP = "$ENV{'HOME'}/.w3m/keymap"; if ($QUERY) { # &write_keymap($QUERY); print <) { s/^keymap\s+// || next; (($k, $_) = &getQWord($_)) || next; (($f, $_) = &getWord($_)) || next; $FUNC_EXIST{$f} || next; ($d, $_) = &getQWord($_); push(@key, $k); push(@func, $f); push(@data, $d); } close(KEYMAP); $N = @key; print <Keymap Setting

Keymap Setting

 Key Command Argument

EOF $i = 0; while(@key) { $k = &Q(shift @key); $f = shift @func; $d = &Q(shift @data); print <
 $k Delete EOF $i++; } print < EOF sub write_keymap { local($query) = @_; @key = (); @func = (); @data = (); for $q (split('&', $query)) { ($_, $d) = split('=', $q); if (s/^k_//) { $key[$_] = $d; } elsif (s/^f_//) { $func[$_] = $d; } elsif (s/^d_//) { $data[$_] = $d; } elsif (s/^del_//) { $del[$_] = 1; } } open(KEYMAP, "> ${KEYMAP}") || next; while(@key) { $k = &UQ(shift @key); $f = shift @func; $d = &UQ(shift @data); ($f =~ /^\w/) || next; (shift @del) && next; print KEYMAP "keymap\t$k\t$f"; if ($d ne '') { if ($d =~ /[\"\'\\\s]/) { $d =~ s/([\"\\])/\\$1/g; print KEYMAP "\t\t\"$d\""; } else { $d =~ s/([\"\\])/\\$1/g; print KEYMAP "\t\t$d"; } } print KEYMAP "\n"; } close(KEYMAP); } sub UQ { local($_) = @_; s/\+/ /g; s/%([\da-f][\da-f])/pack('c', hex($1))/egi; return $_; } sub Q { local($_) = @_; s/\&/\&/g; s/\/\>/g; s/\"/\"/g; return $_; } sub getQWord { local($_) = @_; local($x) = ''; s/^\s+//; while($_ ne '') { if (s/^\'(([^\'\\]|\\.)*)\'// || s/^\"(([^\"\\]|\\.)*)\"// || s/^([^\'\"\\\s]+)// || s/^\\(.)//) { $x .= $1; } else { last; } } return ($x, $_); } sub getWord { local($_) = @_; s/^\s+//; s/^(\S+)// || return (); return ($1, $_); } sub print_func { local($f) = @_; for(@FUNC_LIST) { if ($f eq $_) { print "