After some debugging, the example code I offered above seems to work, with minor adjustments:

\begingroup
\let\loc\loctextloc
\currentbtxloctext
\btxcomma
\endgroup

Thanks again for all the help!

Joey

On Mon, Nov 29, 2021 at 12:11 PM Joey McCollum <jmccollum20140511@gmail.com> wrote:
Okay. So using this example as a template, I'd like to do the following: 
  • define a general-purpose \loc macro that can be invoked in the main text (i.e., outside of citations) in the usual way; this one would correspond to \WhateverB above and would not remove punctuation preceding the macro.
  • separately define a \loctextloc macro that accepts the same input as \loc, but conditionally removes preceding punctuation based on variables set outside of this macro during the citation process (e.g., \btxsblshorthandbeforetextloc); this would correspond to \WhateverA above.
  • in the macro for typesetting the loctext btx parameter, redefine \loc to do what \loctextloc does, and then invoke \currentbtxloctext so that the \loc invocations it contains will be expanded like \loctextloc, as follows: 
\begingroup
\def\loc\loctextloc
\currentbtxloctext
\btxcomma
\endgroup

Is this a ConTeXt-friendly way to do this? I'm attempted this now, but I have some errors to debug, and I'd like to know if this is even a feasible direction before I continue.

Joey

On Sun, Nov 28, 2021 at 5:39 AM Hans Hagen <j.hagen@xs4all.nl> wrote:
On 11/28/2021 2:39 AM, Joey McCollum wrote:
> I was afraid that might be the problem. I've described some of the
> intended purpose of this code near the end of the "Checking for a macro  > ...

Maybe play with:

\starttext

\def\WhateverA{\removeunwantedspaces\removepunctuation\space ¶ 1.23}
\def\WhateverB{¶ 1.23}

foo bar, \WhateverA\ test
foo bar, \WhateverB\ test

\stoptext

so, wrap ¶ into a macro

\def\MyParSymbol{\removeunwantedspaces\removepunctuation\space ¶}

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------