Hello,

I suggest allowing \Ucharcat to produce active characters.  See
three-line patch attached.  This would allow to produce active
characters expandably in all engines (pdfTeX, luaTeX, XeTeX, pTeX,
upTeX).  My code makes

    \Ucharcat `~ 13
    \expandafter\show\Ucharcat `~ 13
    \edef\foo{\expandafter\noexpand\Ucharcat `~ 13 }

run the code of the active ~ as if it had been typed directly, then show
its meaning, then do the equivalent of \def\foo{~}.

Bruno
>From ab3698191833315858cb5751af886230ffc2a82d Mon Sep 17 00:00:00 2001
From: Bruno Le Floch <br...@le-floch.fr>
Date: Wed, 18 Apr 2018 10:52:55 -0400
Subject: [PATCH] Allow Ucharcat to produce active characters

This is a bit more involved than changing the bounds check because
the "cur_tok" of active characters is like that of control sequences
rather than that of usual characters.
---
 source/texk/web2c/xetexdir/xetex.web | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/source/texk/web2c/xetexdir/xetex.web b/source/texk/web2c/xetexdir/xetex.web
index f7b0bbe..2e5be00 100644
--- a/source/texk/web2c/xetexdir/xetex.web
+++ b/source/texk/web2c/xetexdir/xetex.web
@@ -10499,6 +10499,7 @@ while k<pool_ptr do
       t := @"10000 + (t - @"D800) * @"400 + (so(str_pool[k]) - @"DC00);
     end;
     if cat=0 then t := other_token + t
+    else if cat=active_char then t := cs_token_flag + active_base + t
     else t := max_char_val * cat + t;
   end;
   fast_store_new_token(t);
@@ -10658,7 +10659,7 @@ selector:=old_setting; link(garbage):=str_toks_cat(b,cat); ins_list(link(temp_he
 end;
 
 @ Not all catcode values are allowed by \.{\\Ucharcat}:
-@d illegal_Ucharcat_catcode(#)==(#<left_brace)or(#>other_char)or(#=out_param)or(#=ignore)
+@d illegal_Ucharcat_catcode(#)==(#<left_brace)or(#>active_char)or(#=out_param)or(#=ignore)
 
 @<Scan the argument for command |c|@>=
 case c of
@@ -10676,7 +10677,7 @@ XeTeX_Ucharcat_code:
     if illegal_Ucharcat_catcode(cur_val) then
       begin print_err("Invalid code ("); print_int(cur_val);
 @.Invalid code@>
-      print("), should be in the ranges 1..4, 6..8, 10..12");
+      print("), should be in the ranges 1..4, 6..8, 10..13");
       help1("I'm going to use 12 instead of that illegal code value.");@/
       error; cat:=12;
     end else
-- 
1.9.1


--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
  http://tug.org/mailman/listinfo/xetex

Reply via email to