From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: Rik Kabel via ntg-context <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@xs4all.nl>
Subject: Re: \autoinsertedspace fails
Date: Fri, 6 Jan 2023 08:53:22 +0100 [thread overview]
Message-ID: <1b82368a-49c3-aea3-a8c6-93faf88f0727@xs4all.nl> (raw)
In-Reply-To: <d7f26fd1-9258-b27d-f987-e2f8730a9f0e@rik.users.panix.com>
On 1/6/2023 3:05 AM, Rik Kabel via ntg-context wrote:
>
> On 2023-01-05 04:35, Hans Hagen via ntg-context wrote:
>> On 1/5/2023 4:21 AM, Rik Kabel via ntg-context wrote:
>
> [ snipped by rik]
>
>> Here is a more lmtx-ish variant:
>>
>> \starttexdefinition tolerant protected BD #=#*#=
>> \removeunwantedspaces
>> \space % insert a space
>> (
>> \ifparameter#2\or
>> #1|–|#2
>> \orelse\ifparameter#1\or
>> #1–
>> \else
>> {\red I NEED A DATE OR DATES!}
>> \fi
>> )
>> \autoinsertedspace
>> \stoptexdefinition
>>
>> Hans
>
> Thank you for that. This works for me with \optionalspace, but fails in
> some cases with \autoinsertedspace.
>
> I have now re-read lowlevel-macros.pdf and have a better understanding
> of what I read when first I approached it; I still have a way to go.
>
> /Tolerant/ removes the need for /dodoubleempty/ and friends and the
> two-step /macro/ and /doMacro/ dance. There was a small advantage to the
> two-step, however. I had two separate macros, BD and BDNP (no parens),
> as shown.
>
> The old code in full was:
>
> %-------------------- Birth and death dates -----------------------%
> % Ferdinand de Saussure\BD{1857}{1913}
> % Noam Chomsky \BD{1928}
> %
> % Perhaps this could be tied to an acronym-like database so that the
> % dates are printed only once per person.
> % \removeunwantedspaces allows this to directly follow, or follow
> % after whitespace, the associated name: Name\BD{1}{2} or
> % Name \BD{1}{2}.
> % Using the compound indication (|–|) allows hyphenation after the
> % endash. Omitting it and using a bare endash inhibits hyphenation
> % ‘twixt the endash and the paren.
> % By default, add parens around the dates. If none are needed due to
> % the context, use \BDNP.
> %
> \newif\ifBDParen
> \starttexdefinition unexpanded BD
> \BDParentrue
> \dodoublegroupempty
> \doBD
> \stoptexdefinition
> \starttexdefinition unexpanded BDNP
> \BDParenfalse
> \dodoublegroupempty
> \doBD
> \stoptexdefinition
> \starttexdefinition doBD #1#2
> \removeunwantedspaces\
> \ifBDParen(\fi
> \ifsecondargument
> #1|–|#2
> \else\iffirstargument
> #1–
> \else
> {\red I NEED A DATE OR DATES!}
> \fi\fi
> \ifBDParen)\fi
> \autoinsertedspace
> \stoptexdefinition
>
> Both call the same doBD, but they set a flag (newif) to control
> insertion or not of the parens. While there is no performance benefit
> compared to having two fully separate macros, there is a maintenance
> benefit in having only one place, doBD, to make changes should they be
> required.
>
> Can you suggest a way to do this under the new one-step scheme, or am I
> over-thinking this?
just remove the #* in the example i sent,
\starttexdefinition tolerant protected BD #=#=
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2023-01-06 7:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 0:12 Rik Kabel via ntg-context
2023-01-04 22:10 ` Rik Kabel via ntg-context
2023-01-04 23:45 ` Hans Hagen via ntg-context
2023-01-05 3:21 ` Rik Kabel via ntg-context
2023-01-05 7:38 ` Hans Hagen via ntg-context
2023-01-05 9:35 ` Hans Hagen via ntg-context
2023-01-06 2:05 ` Rik Kabel via ntg-context
2023-01-06 7:53 ` Hans Hagen via ntg-context [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b82368a-49c3-aea3-a8c6-93faf88f0727@xs4all.nl \
--to=ntg-context@ntg.nl \
--cc=j.hagen@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).