texlive[64136] Master/texmf-dist: hereapplies (17aug22)

commits+karl at tug.org commits+karl at tug.org
Wed Aug 17 22:59:12 CEST 2022


Revision: 64136
          http://tug.org/svn/texlive?view=revision&revision=64136
Author:   karl
Date:     2022-08-17 22:59:12 +0200 (Wed, 17 Aug 2022)
Log Message:
-----------
hereapplies (17aug22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/hereapplies/ChangeLog.md
    trunk/Master/texmf-dist/doc/latex/hereapplies/README.md
    trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.pdf
    trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.tex
    trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies-example.lyx
    trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies.module
    trunk/Master/texmf-dist/doc/latex/hereapplies/package.json
    trunk/Master/texmf-dist/tex/latex/hereapplies/hereapplies.sty

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/ChangeLog.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/ChangeLog.md	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/ChangeLog.md	2022-08-17 20:59:12 UTC (rev 64136)
@@ -2,6 +2,25 @@
 ==========
 
 
+## 0.4.0 (2022-08-16)
+
+Changes:
+
+* The `\whereapplies` macro and its starred counterpart now support page ranges
+  and a more robust indexing (a partial rewrite of the code and the addition of
+  the `refcount` dependency were necessary)
+* The LyX module has been updated
+* Documentation
+* Examples
+
+
+## 0.3.1 (2022-08-15)
+
+Changes:
+
+* Documentation
+
+
 ## 0.3.0 (2022-08-13)
 
 Changes:

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/README.md	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/README.md	2022-08-17 20:59:12 UTC (rev 64136)
@@ -7,17 +7,18 @@
 Overview
 --------
 
-**Here Applies** is a LaTeX package that implements an _informal glossary_. Its
-core mechanism is identical to that of a conventional glossary – i.e. some
-concepts are marked as “important” and indicized every time they appear in the
-document – but it does not produce any nomenclature section, nor relies on the
-conventions that normally take part in a glossary.
+**Here Applies** is a LaTeX package that implements an _informal glossary_ for
+cross-linking concepts to their applications. Its core mechanism is identical
+to that of a conventional glossary – i.e. some concepts are marked as
+“important” and indicized every time they appear in the document – but it does
+not produce any nomenclature section, nor relies on the conventions that
+normally take part in a glossary.
 
-In fact, normally, besides an indicization mechanism, a proper glossary should
-be able to produce a dedicated section (usually at the end of the document)
+Besides an indicization mechanism, in fact, a proper glossary should normally
+be able to produce a dedicated section – usually at the end of the document –
 where the terms are collected in alphabetical order, their definitions are
-shown, and the lists of their occurrences are presented. By design, all these
-things but the last one are missing in **Here Applies**.
+shown, and the lists of their occurrences are presented. All these things but
+the last one, by design, are missing in **Here Applies**.
 
 Instead, the package offers only two macros: `\hereapplies` and `\whereapplies`
 (plus their “starred” versions `\hereapplies*` and `\whereapplies*`). In both
@@ -24,22 +25,26 @@
 cases a “concept name” is passed as argument – and this can be any string
 invented in the moment, as long as it contains only letters.
 
-Every time `\hereapplies` is invoked again on an identical string the document
-knows that the same concept from previous invocations is occurring at that
-point. And so every time the `\whereapplies` macro is invoked, all the
-occurrences of that concept within the entire document will be printed in the
-form of a linkable page number list (“pp. 1, 2, 3, 4, …”).
+Every time `\hereapplies` is invoked again on an identical string, the document
+is made aware that the same concept from previous invocations is occurring at
+that point. And so, every time the `\whereapplies` macro is invoked on that
+same string, all the occurrences of that concept within the entire document
+will be printed in the form of a linkable page number list (e.g. “pp. 1, 5,
+8–9, 14–20…”).
 
 As `\hereapplies` is designed to be invoked in the middle of a chapter or a
-section and make it linkable, the `\phantomsection` macro is invoked by default
-before a label is added to that place. To avoid calling `\phantomsection`,
-the “starred” macro `\hereapplies*` is available.
+section, and that location must be made linkable, the `\phantomsection` macro
+is invoked by default before a label is added. To avoid calling
+`\phantomsection`, the “starred” macro `\hereapplies*` is available.
 
 Finally, like `\whereapplies` resembles a pluralizable version of `\pageref`,
 its “starred” version `\whereapplies*` resembles a pluralizable version of
 `\pageref*`.
 
+If you use LyX, the package ships a LyX module as well (please check the
+`lyx-module` subdirectory).
 
+
 Example usage
 -------------
 
@@ -53,30 +58,35 @@
 \begin{document}
 
 \title{Some title}
+
 \author{Some author}
 
 \maketitle
 
-This is concept one. To find this concept applied, please
-see \whereapplies{conceptOne}.
+This is concept one. To find this concept applied, please see
+\whereapplies{conceptOne}.
 
-This is concept two. To find this concept applied, please
-see \whereapplies{conceptTwo}.
+This is concept two. To find this concept applied, please see
+\whereapplies{conceptTwo}.\newpage
 
-\newpage
-
 \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 one'' applies here.\newpage
 
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
 
 \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 one'' applies here.\newpage
 
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
 
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
 \hereapplies[myref]{conceptOne}This is page \thepage. As you can
 see, ``concept one'' applies here. This point in the document is
 labeled \texttt{myref}.
@@ -90,27 +100,31 @@
 A minimal tutorial
 ------------------
 
-### Macro `\hereapplies[label]{concept_name}`
+### Macro `\hereapplies[Label]{ConceptName}`
 
 The `\hereapplies` macro notifies the document that a particular concept
-applies to a particular point and creates a label for it.
+applies to a particular point and adds a label to it.
 
 If the optional argument is passed the label created will be named accordingly,
 otherwise an opaque name will be assigned to it. This argument may contain only
 what is legal in both `\label` and `\pageref`.
 
-The `concept_name` argument may contain only letters and the “at” sign (`@`).
+The `ConceptName` argument may contain only Latin letters and the “at” sign
+(`@`). This string remains confined within the internal scope of the package
+and does not create conflicts with possible macros or labels of the same name.
 
 The “starred” version of this macro (`\hereapplies*`) does not invoke the
 `\phantomsection` directive.
 
 
-### Macro `\whereapplies{concept_name}`
+### Macro `\whereapplies{ConceptName}`
 
 The `\whereapplies` macro prints all the occurrences of a concept, in the form
-“p. …” or “pp. …”
+“p. …” or “pp. …” (with page range support).
 
-The `concept_name` argument may contain only letters and the “at” sign (`@`).
+The `ConceptName` argument may contain only Latin letters and the “at” sign
+(`@`). This string remains confined within the internal scope of the package
+and does not create conflicts with possible macros or labels of the same name.
 
 The “starred” version of this macro (`\whereapplies*`) will use `\pageref*`
 instead of `\pageref` for generating the page list.

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.tex	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/hereapplies-example.tex	2022-08-17 20:59:12 UTC (rev 64136)
@@ -5,30 +5,35 @@
 \begin{document}
 
 \title{Some title}
+
 \author{Some author}
 
 \maketitle
 
-This is concept one. To find this concept applied, please
-see \whereapplies{conceptOne}.
+This is concept one. To find this concept applied, please see
+\whereapplies{conceptOne}.
 
-This is concept two. To find this concept applied, please
-see \whereapplies{conceptTwo}.
+This is concept two. To find this concept applied, please see
+\whereapplies{conceptTwo}.\newpage
 
-\newpage
-
 \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 one'' applies here.\newpage
 
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
 
 \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 one'' applies here.\newpage
 
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
 
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
 \hereapplies[myref]{conceptOne}This is page \thepage. As you can
 see, ``concept one'' applies here. This point in the document is
 labeled \texttt{myref}.

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies-example.lyx
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies-example.lyx	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies-example.lyx	2022-08-17 20:59:12 UTC (rev 64136)
@@ -297,6 +297,84 @@
 status open
 
 \begin_layout Plain Layout
+conceptTwo
+\end_layout
+
+\end_inset
+
+This is page 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+thepage
+\end_layout
+
+\end_inset
+
+.
+ As you can see, 
+\begin_inset Quotes eld
+\end_inset
+
+concept two
+\begin_inset Quotes erd
+\end_inset
+
+ applies here.
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Here applies
+status open
+
+\begin_layout Plain Layout
+conceptTwo
+\end_layout
+
+\end_inset
+
+This is page 
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+thepage
+\end_layout
+
+\end_inset
+
+.
+ As you can see, 
+\begin_inset Quotes eld
+\end_inset
+
+concept two
+\begin_inset Quotes erd
+\end_inset
+
+ applies here.
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Here applies
+status open
+
+\begin_layout Plain Layout
 \begin_inset Argument 1
 status open
 

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies.module
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies.module	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/lyx-module/hereapplies.module	2022-08-17 20:59:12 UTC (rev 64136)
@@ -34,6 +34,9 @@
 	BgColor		lightgray
 	Argument 1
 		Decoration	Classic
+		Font
+			Color		blue
+		EndFont
 		LabelString	"Label"
 		MenuString	"Instance label"
 		Tooltip		"A string that will become the label of the instance (which can be referenced with \ref, \pageref, etc.)"
@@ -64,6 +67,9 @@
 	BgColor		lightgray
 	Argument 1
 		Decoration	Classic
+		Font
+			Color		blue
+		EndFont
 		LabelString	"Label"
 		MenuString	"Instance label"
 		Tooltip		"A string that will become the label of the instance (which can be referenced with \ref, \pageref, etc.)"
@@ -81,7 +87,7 @@
 	EndFont
 	LabelFont
 		Family		Serif
-		Color		green
+		Color		purple
 		Size		Small
 	EndFont
 	LabelString	"Applications of"
@@ -104,7 +110,7 @@
 	EndFont
 	LabelFont
 		Family		Serif
-		Color		green
+		Color		purple
 		Size		Small
 	EndFont
 	LabelString	"Applications of*"

Modified: trunk/Master/texmf-dist/doc/latex/hereapplies/package.json
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hereapplies/package.json	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/doc/latex/hereapplies/package.json	2022-08-17 20:59:12 UTC (rev 64136)
@@ -1,6 +1,6 @@
 {
 	"name": "hereapplies.sty",
-	"version": "0.3.0",
+	"version": "0.4.0",
 	"description": "A LaTeX package for cross-linking concepts to their applications",
 	"homepage": "https://madmurphy.github.io/hereapplies.sty",
 	"author": "madmurphy",

Modified: trunk/Master/texmf-dist/tex/latex/hereapplies/hereapplies.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hereapplies/hereapplies.sty	2022-08-17 20:59:00 UTC (rev 64135)
+++ trunk/Master/texmf-dist/tex/latex/hereapplies/hereapplies.sty	2022-08-17 20:59:12 UTC (rev 64136)
@@ -1,6 +1,6 @@
 %  -*- Mode: latex; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
-
 %
+%
 % hereapplies.sty
 %
 % A LaTeX package for cross-linking concepts to their applications
@@ -7,9 +7,9 @@
 %
 % https://github.com/madmurphy/hereapplies.sty
 %
-% Version 0.3.0
+% Version 0.4.0
 %
-% Copyright (c) 2022 madmurphy <madmurphy333 at gmail.com>
+% Copyright (C) 2022 madmurphy <madmurphy333 at gmail.com>
 %
 % **Here Applies** is free software: you can redistribute it and/or modify it
 % under the terms of the GNU Affero General Public License as published by the
@@ -35,30 +35,35 @@
 %     \begin{document}
 %
 %     \title{Some title}
+%
 %     \author{Some author}
 %
 %     \maketitle
 %
-%     This is concept one. To find this concept applied, please
-%     see \whereapplies{conceptOne}.
+%     This is concept one. To find this concept applied, please see
+%     \whereapplies{conceptOne}.
 %
-%     This is concept two. To find this concept applied, please
-%     see \whereapplies{conceptTwo}.
+%     This is concept two. To find this concept applied, please see
+%     \whereapplies{conceptTwo}.\newpage
 %
-%     \newpage
-%
 %     \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 %     one'' applies here.\newpage
 %
-%     \hereapplies{conceptTwo}This is page \thepage. As you can see,
-%     ``concept two'' applies here.\newpage
+%     \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+%     two'' applies here.\newpage
 %
 %     \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
 %     one'' applies here.\newpage
 %
-%     \hereapplies{conceptTwo}This is page \thepage. As you can see,
-%     ``concept two'' applies here.\newpage
+%     \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+%     two'' applies here.\newpage
 %
+%     \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+%     two'' applies here.\newpage
+%
+%     \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+%     two'' applies here.\newpage
+%
 %     \hereapplies[myref]{conceptOne}This is page \thepage. As you can
 %     see, ``concept one'' applies here. This point in the document is
 %     labeled \texttt{myref}.
@@ -68,6 +73,7 @@
 %
 \ProvidesPackage{hereapplies}
 \RequirePackage{hyperref}
+\RequirePackage{refcount}
 %
 %
 %
@@ -75,65 +81,158 @@
 %         ===================
 %
 %
-% Assign a unique number to each applicable concept
+% Assign a unique number to each concept
 \newcounter{@ha at concept@counter}
 % Assign a unique number to each unnamed occurrence of a concept
 \newcounter{@ha at unlabeled@counter}
 %
 %
-% Macro `\@ha at newapplicable{concept_name}`
+% Macro `\@ha at makeoccurrencelist{HyperrefMacro}{LabelList}`
 % *****************************************************************************
 %
-% Initialize a new applicable concept
+% Generate the list of page numbers with page range support
 %
-% Thie macro is for internal purposes only. When invoked, it sets up the helper
+% This macro is for internal purposes only. When invoked, it scans the list of
+% labels provided (`LabelList`) and checks which labels refer to duplicate page
+% numbers and which page numbers can be grouped together.
+%
+% The `HyperrefMacro` argument is the macro from the `hyperref` package that
+% will process the label name. This should be either `T at pageref` -- equivalent
+% to `\pageref` -- or `@pagerefstar` -- equivalent to `\pageref*`.
+%
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
+%
+% The `LabelList` must be a comma-separated list of labels.
+%
+\newcommand{\@ha at makeoccurrencelist}[2]{%
+	% Reset the current page number
+	\def\@ha at tmp@@currp{-1}%
+	% Reset the current range offset
+	\def\@ha at tmp@@prangeoffs{-1}%
+	% Iterate through the `LabelList` argument
+	\@for\@ha at tmp@@thislabel:=#2\do{%
+		% Store the page number associated with this label
+		\edef\@ha at tmp@@nextp{\getpagerefnumber{\@ha at tmp@@thislabel}}%
+		% Check that we are not on the same page as in the last iteration
+		\unless\ifnum\@ha at tmp@@currp=\@ha at tmp@@nextp%
+			% This is not the same page as in the last iteration
+			% Is this the first page in which this concept appears?
+			\unless\ifnum\@ha at tmp@@currp=-1%
+				% This is not the first page in which this concept appears
+				% Does this page follow immediately the previous label's page?
+				\ifnum\numexpr\@ha at tmp@@currp+1=\@ha at tmp@@nextp%
+					% This page follows immediately the previous label's page
+					% Are these the first contiguous pages that we encounter?
+					\ifnum\@ha at tmp@@prangeoffs=-1%
+						% These are the first contiguous pages we encounter
+						% Store the first page number of the pair
+						\edef\@ha at tmp@@prangeoffs{\@ha at tmp@@currp}%
+						% Store the first label of the pair
+						\edef\@ha at tmp@@currrangelbl{\@ha at tmp@@currlbl}%
+					\fi%
+				\else%
+					% This page is far from the previous label's page
+					% Was the previous page part of a contiguous range?
+					\ifnum\@ha at tmp@@prangeoffs=-1%
+						% The previous page was a standalone page
+						% Print "[p], "
+						{\csname #1\endcsname{\@ha at tmp@@currlbl}, }%
+					\else%
+						% The previous page was part of a contiguous range
+						% Print "[p--q], "
+						{\csname #1\endcsname{\@ha at tmp@@currrangelbl}--\csname
+							#1\endcsname{\@ha at tmp@@currlbl}, }%
+						% Reset the current range offset
+						\def\@ha at tmp@@prangeoffs{-1}%
+					\fi%
+				\fi%
+			\fi%
+			% Prepare the next page number
+			\edef\@ha at tmp@@currp{\@ha at tmp@@nextp}%
+			% Prepare the next label
+			\edef\@ha at tmp@@currlbl{\@ha at tmp@@thislabel}%
+		\fi%
+	}%
+	% Print the last page number
+	% Is there at least one page to print?
+	\unless\ifnum\@ha at tmp@@currp=-1%
+		% There is at least one page to print
+		% Was the previous page part of a contiguous range?
+		\ifnum\@ha at tmp@@prangeoffs=-1%
+			% The previous page was a standalone page
+			% Print "[p], "
+			{\csname #1\endcsname{\@ha at tmp@@currlbl}}%
+		\else%
+			% The previous page was part of a contiguous range
+			% Print "[p--q], "
+			{\csname #1\endcsname{\@ha at tmp@@currrangelbl}--\csname
+				#1\endcsname{\@ha at tmp@@currlbl}}%
+		\fi%
+	\fi%
+}
+%
+%
+% Macro `\@ha at newconcept{ConceptName}`
+% *****************************************************************************
+%
+% Initialize a new concept
+%
+% This macro is for internal purposes only. When invoked, it sets up the helper
 % macros, counters and auxiliary files needed for keeping track of a concept.
-% If the concept was already initialized this macro will be no op.
+% If the concept was already initialized the macro will be no op.
 %
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
 %
-\newcommand{\@ha at newapplicable}[1]{%
+\newcommand{\@ha at newconcept}[1]{%
 	% Was this concept already initialized?
-	\expandafter\ifx\csname @ha at prop@@cursor@#1\endcsname\relax%
+	\expandafter\ifx\csname @ha at prop@@count@#1\endcsname\relax%
 		% The concept was never initialized
-		% Move the counter to the current id
-		\stepcounter{@ha at concept@counter}%
 		% Set the output to "??" - it will be updated by the .haN file
-		\expandafter\def\csname @ha at prop@@uoutput@#1\endcsname{\textbf{??}}%
+		\expandafter\gdef\csname @ha at prop@@uoutput@#1\endcsname{\textbf{??}}%
 		% Set the starred output to "??" - it will be updated by the .haN file
-		\expandafter\def\csname @ha at prop@@soutput@#1\endcsname{\textbf{??}}%
-		% The last page that applies
-		\expandafter\def\csname @ha at prop@@cursor@#1\endcsname{-1}%
-		% Store the id of the current concept
-		\expandafter\edef\csname @ha at prop@@id@#1\endcsname{\arabic{@ha at concept@counter}}%
+		\expandafter\gdef\csname @ha at prop@@soutput@#1\endcsname{\textbf{??}}%
+		% Use "p." for the preamble when there is only one occurrence
+		\expandafter\gdef\csname @ha at prop@@preamble@#1\endcsname{p.~}%
+		% Increase the counter of concepts
+		\stepcounter{@ha at concept@counter}%
+		% Store the current value of the counter of concepts
+		\expandafter\xdef\csname
+			@ha at prop@@count@#1\endcsname{\the at ha@concept at counter}%
 		% Initialize the .haN file
 		% Previous versions had this line, which created unwanted whitespaces:
-		%\@starttoc{ha\csname @ha at prop@@id@#1\endcsname}%
+		%\@starttoc{ha\csname @ha at prop@@count@#1\endcsname}%
 		% I am thankful to David Carlisle for the following replacement:
-		{\endlinechar=\m at ne\@starttoc{ha\csname @ha at prop@@id@#1\endcsname}}%
+		{\endlinechar=\m at ne\@starttoc{ha\csname @ha at prop@@count@#1\endcsname}}%
 		% Store all the occurrences when the document reaches the end
 		\AtEndDocument{%
 			% Make sure that there are occurrences
-			\expandafter\ifcsname @ha at prop@@preamble@#1\endcsname%
+			\expandafter\ifcsname @ha at prop@@labels@#1\endcsname%
 				% There are occurrences
-				% When `\hereapplies` is the last directive of the document and
-				% is not followed by any text, due to an unknown bug
-				% `\whereapplies` prints "??" even when there are occurrences
-				% of a concept. Uncommenting the `\phantom` macro below fixes
-				% the bug, yet it might be wiser to leave the choice to the
-				% user and search for more final solutions in the meanwhile.
-				% The `\phantom{}` directive can also be inserted
-				% manually at the end of the document.
-				%\phantom{}%
 				% Set the .haN file as output
-				\addtocontents{ha\csname @ha at prop@@id@#1\endcsname}{%
+				\addtocontents{ha\csname @ha at prop@@count@#1\endcsname}{%
 					% Write "p./pp. \pageref..." to the output
 					\gdef\expandafter\protect\csname @ha at prop@@uoutput@#1\endcsname{%
-						\csname @ha at prop@@preamble@#1\endcsname\csname @ha at prop@@ucache@#1\endcsname%
+						% Preamble (either "p." or "pp.")
+						\csname @ha at prop@@preamble@#1\endcsname%
+						% `\T at pageref` is a synonym of `\pageref`
+						\expandafter\protect\csname
+							@ha at makeoccurrencelist\endcsname{T at pageref}{\csname
+								@ha at prop@@labels@#1\endcsname}%
 					}%
 					% Write "p./pp. \pageref*..." to the starred output
 					\gdef\expandafter\protect\csname @ha at prop@@soutput@#1\endcsname{%
-						\csname @ha at prop@@preamble@#1\endcsname\csname @ha at prop@@scache@#1\endcsname%
+						% Preamble (either "p." or "pp.")
+						\csname @ha at prop@@preamble@#1\endcsname%
+						% `\@pagerefstar` is a synonym of `\pageref*`
+						\expandafter\protect\csname
+							@ha at makeoccurrencelist\endcsname{@pagerefstar}{\csname
+								@ha at prop@@labels@#1\endcsname}%
 					}%
 				}%
 			\fi%
@@ -142,72 +241,61 @@
 }
 %
 %
-% Macro: `\@ha at getpropat{property_name}{concept_name}`
+% Macro: `\@ha at getpropat{PropertyName}{ConceptName}`
 % *****************************************************************************
 %
-% Get the current value of a concept's property
+% Get the value of a concept's property
 %
-% Thie macro is for internal purposes (but nothing forbids invoking it
-% directly).
+% This macro is for internal purposes (but nothing forbids invoking it
+% directly). If a concept was never initialized the macro will initialize it.
 %
-% Possible values for the `property_name` argument are: `cursor`, `id`,
-% `preamble`, `scache`, `soutput`, `ucache`, `uoutput`.
+% Possible values for the `PropertyName` argument are: `count`, `labels`,
+% `preamble`, `soutput`, `uoutput`.
 %
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
 %
 \newcommand{\@ha at getpropat}[2]{%
-	% Make sure that the applicable concept is initialized
-	\@ha at newapplicable{#2}%
-	% Print all the occurrences of the concept
+	% Make sure that the concept is initialized
+	\@ha at newconcept{#2}%
+	% Print the concept's property
 	\csname @ha at prop@@#1@#2\endcsname%
 }
 %
 %
-% Macro: `\starred at labeled@hereapplies{label}{concept_name}`
+% Macro: `\starred at labeled@hereapplies{Label}{ConceptName}`
 % *****************************************************************************
 %
 % Equivalent to `\hereapplies*`, but the two arguments are both mandatory
 %
-% Thie macro is for internal purposes (but nothing forbids invoking it
+% This macro is for internal purposes (but nothing forbids invoking it
 % directly). See the documentation of `\hereapplies` for more information.
 %
 \newcommand{\starred at labeled@hereapplies}[2]{%
 	% Make sure that the concept has been initialized
-	\@ha at newapplicable{#2}%
+	\@ha at newconcept{#2}%
 	% Assign a label to this occurrence
 	\label{#1}%
-	% If the cursor already points to the current page do nothing
-	\unless\ifnum\csname @ha at prop@@cursor@#2\endcsname=\thepage%
-		% Is this the first occurrence?
-		\expandafter\ifcsname @ha at prop@@preamble@#2\endcsname%
-			% This is *not* the first occurrence
-			% Use "pp." for the preamble when there are multiple occurrences
-			\expandafter\def\csname @ha at prop@@preamble@#2\endcsname{pp.~}%
-			% Populate the cache
-			\expandafter\g at addto@macro\csname @ha at prop@@ucache@#2\endcsname{, \pageref{#1}}%
-			% Populate the starred cache
-			\expandafter\g at addto@macro\csname @ha at prop@@scache@#2\endcsname{, \pageref*{#1}}%
-		\else%
-			% This is the first occurrence
-			% Use "p." for the preamble when there is only one occurrence
-			\expandafter\def\csname @ha at prop@@preamble@#2\endcsname{p.~}%
-			% Initialize the cache
-			\expandafter\def\csname @ha at prop@@ucache@#2\endcsname{\pageref{#1}}%
-			% Initialize the starred cache
-			\expandafter\def\csname @ha at prop@@scache@#2\endcsname{\pageref*{#1}}%
-		\fi%
-		% Make the cursor point to the current page
-		\expandafter\edef\csname @ha at prop@@cursor@#2\endcsname{\thepage}%
+	\expandafter\ifcsname @ha at prop@@labels@#2\endcsname%
+		% This is *not* the first occurrence
+		\expandafter\g at addto@macro\csname @ha at prop@@labels@#2\endcsname{,#1}%
+		% Use "pp." for the preamble when there are multiple occurrences
+		\expandafter\gdef\csname @ha at prop@@preamble@#2\endcsname{pp.~}%
+	\else%
+		% This is the first occurrence
+		\expandafter\gdef\csname @ha at prop@@labels@#2\endcsname{#1}%
 	\fi%
 }
 %
 %
-% Macro: `\starred at hereapplies[label]{concept_name}`
+% Macro: `\starred at hereapplies[Label]{ConceptName}`
 % *****************************************************************************
 %
 % Equivalent to `\hereapplies*`
 %
-% Thie macro is for internal purposes (but nothing forbids invoking it
+% This macro is for internal purposes (but nothing forbids invoking it
 % directly). See the documentation of `\hereapplies` for more information.
 %
 \newcommand{\starred at hereapplies}[2][]{%
@@ -217,7 +305,9 @@
 		% Assign a unique number to the unnamed occurrence
 		\stepcounter{@ha at unlabeled@counter}%
 		% Call `\starred at hereapplies` with an opaque label
-		\edef\tmp{\noexpand\starred at labeled@hereapplies{#2:__appl\arabic{@ha at unlabeled@counter}__}{#2}}\tmp%
+		{\edef\tmp{\noexpand\starred at labeled@hereapplies{%
+			ha:#2-unnamed\the at ha@unlabeled at counter}{#2}%
+		}\tmp}%
 	\else%
 		% The macro has been called with two arguments
 		\starred at labeled@hereapplies{#1}{#2}%
@@ -230,7 +320,7 @@
 %         ===================
 %
 %
-% Macro: `\hereapplies[label]{concept_name}`
+% Macro: `\hereapplies[Label]{ConceptName}`
 % *****************************************************************************
 %
 % Notify the document that a particular concept applies and create a label for
@@ -240,7 +330,10 @@
 % accordingly, otherwise an opaque name will be assigned to it. This argument
 % may contain only what is legal in both `\label` and `\pageref`.
 %
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
 %
 % The starred version of this macro (`\hereapplies*`) does not invoke the
 % `\phantomsection` directive.
@@ -251,12 +344,16 @@
 }
 %
 %
-% Macro: `\whereapplies{concept_name}`
+% Macro: `\whereapplies{ConceptName}`
 % *****************************************************************************
 %
 % Print all the occurrences of a concept in the form "p. ..." or "pp. ..."
+% with page range support
 %
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
 %
 % The starred version of this macro (`\whereapplies*`) will use `\pageref*`
 % instead of `\pageref` for generating the page list.



More information about the tex-live-commits mailing list.