Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 1
    Can't you just use grouping? I mean: \begingroup ... \def\cs{whatever} ... \endgroup? Commented May 26, 2023 at 15:47
  • 1
    You have abstracted the question well, but IMHO if you posit the question in context with a real-world application, you might get better answers and methods of achieving what you want. (x-y problem) Commented May 26, 2023 at 15:55
  • 1
    Sorry, but your explanation is still not very clear. It still looks like what you are saying can be achieved with grouping. Commented May 26, 2023 at 16:02
  • 1
    Try this: \def\bar{foo} \def\foo#1{\begingroup\def\bar{#1}\endgroup}\foo{bar}\bar\par \def\foo#1{\begingroup\gdef\bar{#1}\endgroup}\foo{bar}\bar \bye Commented May 26, 2023 at 16:07
  • 1
    Ah, but if you \global\def, then grouping does not work, clearly. But you didn't mention it in the question... 😉 Commented May 26, 2023 at 16:18