I took Christian's answer and I tried to make something working with complex indexing situations.
The most complex situation that I can imagine is something like
A!b!C@D|E
In this situation what you need to print in bold face is C, so we have to make some manipulation.
A solution could be using delimited arguments, but I decided to use the \seq_set_split: command: at first I create a sequence using the | as separator, then I take only the first element of the sequence, that is everything but the |... part.
Then I create another seq with the @ delimiter, and then another one with the ! delimiter. The last element of this sequence is the entry, stored in the \l_hernan_entry_tl token list. And now you can do what Christian suggested.
\documentclass{article}
\usepackage{imakeidx}
\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \l_hernan_seq
\tl_new:N \l_hernan_first_split_tl % for storing the entry without "|see..." part
\tl_new:N \l_hernan_second_split_tl % for storing the entry without "@..." part
\tl_new:N \l_hernan_entry_tl % for storing the entry
\seq_new:N \l_hernan_vertical_bar_seq
\seq_new:N \l_hernan_at_seq
\seq_new:N \l_hernan_entries_seq
\NewDocumentCommand{\important}{m}
{
\seq_set_split:Nnn \l_hernan_vertical_bar_seq {|} {#1}
\seq_get_left:NN \l_hernan_vertical_bar_seq \l_hernan_first_split_tl
%
\seq_set_split:NnV \l_hernan_at_seq {@} \l_hernan_first_split_tl
\seq_get_left:NN \l_hernan_at_seq \l_hernan_second_split_tl
%
\seq_set_split:NnV \l_hernan_entries_seq {!} \l_hernan_second_split_tl
\seq_get_right:NN \l_hernan_entries_seq \l_hernan_entry_tl
%
\seq_if_in:NVTF\l_hernan_seq \l_hernan_entry_tl
{\l_hernan_entry_tl \index{#1}} %true
{\seq_put_left:NV \l_hernan_seq \l_hernan_entry_tl
\textbf{\l_hernan_entry_tl}\index{#1}} %false
%\seq_show:N \l_hernan_seq
}
\NewDocumentCommand{\getimportantwordslist}{+O{\par}}{
\seq_use:Nn{\l_hernan_seq}{#1}
}
\ExplSyntaxOff
\NewDocumentCommand{\PrintHighlighted}{+m}{%
Here is the list of important words:
\getimportantwordslist
}
\makeindex
\begin{document}
The most complex situation that I can imagine is \important{Mainentry!subentry!realentry@myentry|see{other}} for indexing the \important{realentry} word as \important{myentry}.
\important{Here} starts the stuff, but \important{Here} it's not highlighted!
Here is some \important{expression} which isn't highlighted again here: \important{expression}
And another \important{word}, not highlighted in here: \important{word}
\bigskip
\PrintHighlighted
\printindex
\end{document}
Please let me know if you find some bug.
\important, however, due to lacking expansion – Sep 18 '15 at 15:32LaTeX3gobbles whitespace, so one has to switch betweenExplSyntaxetc. to make commands that work with the L3 - macros and those, that can't. Use\seq_use:Nn{\l_hernan_seq}{\par}for usage with newlines. – Sep 18 '15 at 21:34