ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: consistent index entries
Date: Sat, 1 Aug 2020 22:16:29 +0200	[thread overview]
Message-ID: <DAD63188-720D-4D83-90F5-999FBF755D58@fiee.net> (raw)
In-Reply-To: <673719ec-6fba-04db-2cae-ffb14128f827@gmail.com>


> Am 01.08.2020 um 21:30 schrieb Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>:
>> \def\Ort#1{\index{\ctxlua{user.Lookup("#1")}}}
> 
> You have to expand the \index argument:
> 
> \define[1]\Ort{\expanded{\index{...}}}

Ah, I never know where to expand (tried \expanded\ctxlua).

Now,

\def\TOrt#1{\expanded{\Ort{\ctxlua{userdata.Lookup("#1")}}}#1} % Loc + Text
\defineprocessor[kursiv][style=italicface]
\def\TFOrt#1{\expanded{\Ort[kursiv->]{\ctxlua{userdata.Lookup("#1")}}}#1} % Loc in Footnote + Text

works. :)

(I always define \TIndex to avoid doubling, e.g. Hamburg\index{Hamburg}.)


> When you use formatting commands etc. you have to use the optional argument for sorting.

I don’t understand.

\Ort[kursiv->]{Hamburg} works.

> You can avoid a few problems when you move the \index command to Lua and use context.index or you use a pure TeX solution.
> 
> %%%% begin lua example
> 
> function userdata.index(name)
>    local indexentry = userdata.lookup[name] or name
>    context.index(indexentry)
> end

That’s nice, but since I use different registers, I’d need to define that function for each. Since I also use several shortcuts (e.g. \TOrt, \TFOrt, \TPerson, \TFPerson) I would multiply the effort on the Lua side.
I find my TeX definitions (like above) shorter, where I can use the same Lua function for each.
With your code I could at least shorten it to:

function userdata.Lookup(name)
   context(userdata.Lookups[name] or name)
end

> %%%% begin tex example

Oh, this is also nice. But isn’t the Lua version faster? (I have >600 person entries and a few hundred locations).

Thank you!

Hraban

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2020-08-01 20:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01 11:22 Henning Hraban Ramm
2020-08-01 18:49 ` Henning Hraban Ramm
2020-08-01 19:01   ` Jairo A. del Rio
2020-08-01 19:18     ` Jairo A. del Rio
2020-08-01 19:50     ` Henning Hraban Ramm
2020-08-01 19:30   ` Wolfgang Schuster
2020-08-01 20:16     ` Henning Hraban Ramm [this message]
2020-08-01 20:44       ` Wolfgang Schuster
2020-08-01 20:57         ` Henning Hraban Ramm

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=DAD63188-720D-4D83-90F5-999FBF755D58@fiee.net \
    --to=texml@fiee.net \
    --cc=ntg-context@ntg.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).