]> granicus.if.org Git - python/commitdiff
do_cmd_let(): Simple implementation to allow \let to be used to establish
authorFred Drake <fdrake@acm.org>
Fri, 15 May 1998 04:28:37 +0000 (04:28 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 15 May 1998 04:28:37 +0000 (04:28 +0000)
synonyms for macros.  This supports:

\let\newname = \oldname
\let\newname\oldname

This is useful sometimes, and can at least avoid real errors at other times.

Doc/perl/python.perl

index 536f324011f23234210104ebae0817cb04cc5056..8882b319fa2ae61966092f581890fcb36c24b79c 100644 (file)
@@ -55,6 +55,24 @@ sub ArabictoRoman {
     $D2[$c[2]] . $D1[$c[1]] . $D0[$c[0]];
 }
 
+
+# This is a fairly simple hack; it supports \let when it is used to create
+# (or redefine) a macro to exactly be some other macro: \let\newname=\oldname.
+# Many uses of \let aren't supported.
+#
+sub do_cmd_let{
+    local($_) = @_;
+    my $matched = 0;
+    s/\s*[\\]([a-zA-Z]+)\s*(=\s*)?[\\]([a-zA-Z]*)/$matched=1; ''/e;
+    if ($matched) {
+       my($new, $old) = ($1, $3);
+       eval "sub do_cmd_$new { do_cmd_$old" . '(@_); }';
+       print "\ndefining handler for \\$new using \\$old\n";
+    }
+    $_;
+}
+
+
 # words typeset in a special way (not in HTML though)
 
 sub do_cmd_ABC{ 'ABC' . @_[0]; }
@@ -84,9 +102,9 @@ sub do_cmd_authoraddress{
     $_;
 }
 
-sub do_cmd_developer{ do_cmd_author(@_[0]); }
-sub do_cmd_developers{ do_cmd_author(@_[0]); }
-sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
+#sub do_cmd_developer{ do_cmd_author(@_[0]); }
+#sub do_cmd_developers{ do_cmd_author(@_[0]); }
+#sub do_cmd_developersaddress{ do_cmd_authoraddress(@_[0]); }
 
 sub do_cmd_hackscore{
     local($_) = @_;