texlive[69437] Master/texmf-dist: piton (15jan24)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 15 22:00:22 CET 2024


Revision: 69437
          https://tug.org/svn/texlive?view=revision&revision=69437
Author:   karl
Date:     2024-01-15 22:00:21 +0100 (Mon, 15 Jan 2024)
Log Message:
-----------
piton (15jan24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
    trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
    trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
    trunk/Master/texmf-dist/source/lualatex/piton/piton.ins
    trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
    trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-01-15 21:00:10 UTC (rev 69436)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-01-15 21:00:21 UTC (rev 69437)
@@ -1,5 +1,5 @@
 % -*- coding: utf-8 ; -*-
-\documentclass[dvipsnames]{article}
+\documentclass[dvipsnames,svgnames]{article}
 
 \usepackage{fontspec}
 
@@ -14,11 +14,11 @@
     begin-escape = ! ,
     end-escape = ! ,
     begin-escape-math = \( , 
-    end-escape-math = \) 
+    end-escape-math = \) ,
+    detected-commands = highLight 
   }
 
 
-
 \usepackage[executable=python.exe]{pyluatex}
 
 \usepackage{xcolor}
@@ -34,6 +34,7 @@
 \usepackage{tcolorbox}
 \usepackage{luacolor,lua-ul}
 
+
 \usepackage{caption}
 
 % We use \MakeShortVerb of shortvrb and not \DefineShortVerb of fancyvrb
@@ -112,7 +113,7 @@
 L'extension \pkg{piton} utilise la librairie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs
   (\emph{pattern-matching} en anglais) pour Lua, écrite en C, fondée sur les PEG (\emph{parsing expression
     grammars}): \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} pour «parser» le code Python, OCaml, C ou SQL et le
-composer avec un coloriage syntaxique. Comme elle utilise du code Lua, elle fonctionne uniquement avec |lualatex|
+composer avec un coloriage syntaxique. Comme elle utilise le Lua de LuaLaTeX, elle fonctionne uniquement avec |lualatex|
 (et ne va pas fonctionner avec les autres moteurs de compilation LaTeX, que ce soit |latex|, |pdflatex| ou
 |xelatex|). Elle n'utilise aucun programme extérieur et la compilation ne requiert donc pas |--shell-escape|. La
 compilation est très rapide puisque tout le travail du parseur est fait par la librairie LPEG, écrite en C.
@@ -157,7 +158,8 @@
 
 \subsection{Choix du langage}
 
-L'extension \pkg{piton} prend en charge quatre langages informatiques : Python, OCaml, SQL et C, ou plutôt \CC.
+L'extension \pkg{piton} prend en charge quatre langages informatiques : Python, OCaml, SQL et C, ou plutôt \CC. Il
+prend aussi en charge un langage minimal appelé «|minimal|» : cf.~\pageref{minimal}.
 
 \smallskip
 Par défaut, le langage est Python.
@@ -170,6 +172,10 @@
 |\PitonOptions{language = C}|
 
 \smallskip
+\colorbox{yellow!50}{\textbf{Nouveau 2.4}}\enskip La variable L3 contenant le nom du langage courant est :
+|\l_piton_language_str|.
+
+\smallskip
 Dans la suite de ce document, on parlera de Python mais les fonctionnalités s'appliquent aussi aux autres langages.
 
 
@@ -326,7 +332,7 @@
 
 \begin{itemize}
 \item La clé \Definition{language} spécifie le langage informatique considéré (la casse n'est pas prise en compte).
-Quatre valeurs sont possibles : |Python|, |OCaml|, |C| et |SQL|. La valeur initiale est |Python|.
+Cinq valeurs sont possibles : |Python|, |OCaml|, |C|, |SQL| et |minimal|. La valeur initiale est |Python|.
 
 \item \index{path} La clé \Definition{path} indique un chemin où seront cherchés les fichiers inclus par
 |\PitonInputFile|. 
@@ -353,7 +359,7 @@
 \item \index{line-numbers} La clé \Definition{line-numbers} active la numérotation des lignes (en débordement à gauche) dans les
 environnements \verb|{Piton}| et dans les listings produits par la commande |\PitonInputFile|.
 
-\colorbox{yellow!50}{\textbf{Nouveau 2.1}}\enskip Cette clé propose en fait plusieurs sous-clés.
+Cette clé propose en fait plusieurs sous-clés.
 \begin{itemize}
 \item La clé \Definition{line-numbers/skip-empty-lines} demande que les lignes vides soient considérées comme non existantes en
 ce qui concerne la numérotation des lignes (si la clé \verb|/absolute| est active, la clé \verb|/skip-empty-lines|
@@ -592,7 +598,8 @@
 \medskip
 Comme on s'en doute, si un langage informatique utilise un certain style et que ce style n'est pas défini
 localement pour ce langage, c'est la version globale qui est utilisée. Cette notion de globalité n'a pas de
-rapport avec la notion de liaison locale de TeX (notion de groupe TeX).
+rapport avec la notion de liaison locale de TeX (notion de groupe TeX).\footnote{Du point de vue des groupes de
+  TeX, les liaisons faites par |\SetPitonStyle| sont toujours locales.}
 
 \medskip
 Les styles fournis par défaut par \pkg{piton} sont tous définis globalement.
@@ -810,7 +817,7 @@
 mécanismes permettant de n'insérer qu'une partie du fichier en question.
 \begin{itemize}
 \item On peut spécifier la partie à insérer par les numéros de lignes (dans le fichier d'origine).
-\item \colorbox{yellow!50}{\textbf{Nouveau 2.1}}\enskip On peut aussi spécifier la partie à insérer par des marqueurs textuels.
+\item On peut aussi spécifier la partie à insérer par des marqueurs textuels.
 \end{itemize}
 Dans les deux cas, si on souhaite numéroter les lignes avec les numéros des lignes du fichier d'origine, il
 convient d'utiliser la clé |line-numbers/absolute|.
@@ -825,8 +832,6 @@
 
 \subsubsection{Avec des marqueurs textuels}
 
-\colorbox{yellow!50}{\textbf{Nouveau 2.1}}
-
 \index{marker/beginning}
 \index{marker/end}
 
@@ -937,37 +942,36 @@
 
 \subsection{Mise en évidence d'identificateurs}
 
-\index{identifiers (clé)}
+\indexcommand{SetPitonIdentifier}
+\label{SetPitonIdentifier}
 
-On peut demander le changement de formatage de certains identificateurs avec la clé |identifiers| de
-|\PitonOptions|.\footnote{Cette fonctionnalité n'est pas disponible avec le langage SQL car, en SQL, il n'y a pas
-  d'identificateurs (il n'y a que des noms de tables et des noms de champs).}
+\colorbox{yellow!50}{\bfseries Modification 2.4}\par\nobreak
 
 \smallskip
-Cette clé prend en argument une valeur au format suivant : 
+La commande |\SetPitonIdentifier| permet de changer le formatage de certains identificateurs.
 
-\quad |{ names = |\textsl{\ttfamily noms}|, style = |\textsl{\ttfamily instructions}| }|
+\smallskip
+Cette commande prend trois arguments : un optionnel et deux obligatoires.
 
 \begin{itemize}
-\item \textsl{\ttfamily noms} est une liste de noms d'identificateurs (séparés par des virgules) ; 
+\item L'argument optionnel (entre crochets) indique le langage (informatique) concerné ; si cet
+argument est absent, les réglages faits par |\SetPitonIdentifier| s'appliqueront à tous les langages.\footnote{On rappelle que, dans \pkg{piton}, les noms des langages informatiques ne sont pas
+  sensibles à la casse.}
 
-\item \textsl{\ttfamily instructions} est une liste d'instructions LaTeX de formatage du même type que pour les
-styles précédemment définis (cf.~\ref{styles} p.~\pageref{styles}).
+\item Le premier argument obligatoire est une liste de noms d'identificateurs séparés par des virgules.
+
+\item Le deuxième argument obligatoire est une liste d'instructions LaTeX de formatage du même type que pour les
+styles précédemment définis (cf. \ref{styles}, p.~\pageref{styles}).
+
+
 \end{itemize}
 
-\emph{Attention} : Seuls les identifiants peuvent voir leur formatage affecté. Les mots-clés et les noms de
-fonctions prédéfinies ne seront pas affectés, même s'ils figurent dans la liste \textsl{\ttfamily noms}.
+\emph{Attention} : Seuls les identificateurs peuvent voir leur formatage affecté. Les mots-clés et les noms de
+fonctions prédéfinies ne seront pas affectés, même s'ils figurent dans le premier argument de
+|\SetPitonIdentifier|. 
 
 \begin{Verbatim}
-\PitonOptions 
-  {
-    ~emphase#identifiers@ = 
-     {
-       ~emphase#names@ = { l1 , l2 } , 
-       ~emphase#style@ = \color{red} 
-     }
-  }
-
+~emphase#\SetPitonIdentifier{l1,l2}{\color{red}}@
 \begin{Piton}
 def tri(l):
     """Tri par segmentation"""
@@ -986,14 +990,7 @@
 
 \begingroup
 
-\PitonOptions 
-  {
-    identifiers = 
-     {
-       names = { l1 , l2 } , 
-       style = \color{red} 
-     }
-  }
+\SetPitonIdentifier{l1,l2}{\color{red}}
 
 \begin{Piton}
 def tri(l):
@@ -1010,19 +1007,14 @@
 \endgroup
 
 \bigskip
-En utilisant la clé |identifiers|, on peut ajouter de nouvelles fonctions prédéfinies (ou de nouveaux mots-clés,
-etc.) qui seront détectées par \pkg{piton}.
+Avec la commande |\SetPitonIdentifiers|, on peut ajouter à un langage informatique de nouvelles fonctions
+prédéfinies (ou de nouveaux mots-clés, etc.) qui seront détectées par \pkg{piton}.
 
 
 \begin{Verbatim}
-\PitonOptions 
-  {
-    ~emphase#identifiers@ = 
-     {
-       names = { cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial } , 
-       style = \PitonStyle{Name.Builtin}
-     }
-  }
+~emphase#\SetPitonIdentifier[Python]@
+  {cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial}
+  {\PitonStyle{Name.Builtin}}
 
 \begin{Piton}
 from math import *
@@ -1035,15 +1027,10 @@
 
 \begingroup
 
-\PitonOptions 
-  {
-    identifiers = 
-     {
-       names = { cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial } , 
-       style = \PitonStyle{Name.Builtin}
-     }
-  }
-
+\SetPitonIdentifier[Python]
+  {cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial}
+  {\PitonStyle{Name.Builtin}}
+ 
 \begin{Piton}
 from math import *
 cos(pi/2) 
@@ -1064,6 +1051,7 @@
 \item Il est possible d'avoir des commentaires entièrement composés en LaTeX.
 \item Il est possible d'avoir, dans les commentaires Python, les éléments entre \texttt{\$} composés en mode
 mathématique de LaTeX.
+\item Il est possible de demander à \pkg{piton} de détecter directement certaines commandes LaTeX avec leur argument.
 \item Il est possible d'insérer du code LaTeX à n'importe quel endroit d'un listing Python.
 \end{itemize}
 Ces mécanismes vont être détaillés dans les sous-parties de cette partie.
@@ -1153,29 +1141,38 @@
 \end{Piton}
 
 
-\subsubsection{Le mécanisme «escape»}
+\subsubsection{La clé «detected-commands»}
 
-\index{begin-escape}
-\index{end-escape}
+\index{detected-commands (key)}
 
-Il est aussi possible de surcharger les listings Python pour y insérer du code LaTeX à peu près n'importe où (mais
-entre deux lexèmes, bien entendu). Cette fonctionnalité n'est pas activée par défaut par \pkg{piton}. Pour
-l'utiliser, il faut spécifier les deux délimiteurs marquant l'échappement (le premier le commençant et le deuxième
-le terminant) en utilisant les clés \Definition{begin-escape} et \Definition{end-escape} (\emph{qui ne sont accessibles
-que dans le préambule du document}). Les deux délimiteurs peuvent être identiques.
+\colorbox{yellow!50}{\bfseries Nouveau 2.4}\par\nobreak
 
+\smallskip
+La clé |detected-commands| de |\PitonOptions| permet de spécifier une liste de noms de commandes LaTeX qui seront
+directement détectées par \pkg{piton}.
 
-\bigskip
-Dans l'exemple suivant, on suppose que le préambule du document contient l'instruction :
+\begin{itemize}
+\item Cette clé |detected-commands| ne peut être utilisée que dans le préambule du document.
 
+\item Les noms de commandes LaTeX doivent apparaître sans la contre-oblique 
+(ex. : |detected-commands = { emph , bfseries }|). 
+
+\item Ces commandes doivent être des commandes LaTeX à un seul argument obligatoire entre accolades (et ces
+accolages doivent être explicites).
+\end{itemize}
+
+\medskip
+Dans l'exemple suivant, qui est une programmation récursive de la factorielle, on décide de surligner en jaune
+l'appel récursif. La commande |\highLight| de \pkg{lua-el} (cette extension requiert elle-même l'extension
+\pkg{luacolor}) permet de le faire avec la syntaxe |\hightLight{...}|.
+
+\smallskip
+On suppose que l'on a mis dans le préambule du document LaTeX l'instruction suivante :
 \begin{Verbatim}
-\PitonOptions{~emphase#begin-escape=!,end-escape=!@}
+\PitonOptions{~emphase#detected-commands@ = highLight}
 \end{Verbatim}
 
-\medskip
-Dans le code suivant, qui est une programmation récursive de la factorielle, on décide de surligner en jaune
-l'instruction qui contient l'appel récursif. Cet exemple utilise la commande |\highLight| de \pkg{lua-ul} (cette
-extension requiert aussi l'extension \pkg{luacolor}).
+On peut alors écrire directement :
 \begin{Verbatim}
 \begin{Piton}
 def fact(n):
@@ -1182,7 +1179,7 @@
     if n==0:
         return 1
     else:
-        ~emphase#!\highLight{!@return n*fact(n-1)~emphase#!}!@
+        ~emphase#\highLight@{return n*fact(n-1)}
 \end{Piton}
 \end{Verbatim}
 
@@ -1191,24 +1188,35 @@
     if n==0:
         return 1
     else:
-        !\highLight{!return n*fact(n-1)!}!
+        \highLight{return n*fact(n-1)}
 \end{Piton}
 
-\bigskip
-En fait, dans le cas présent, il serait sans doute plus habile d'utiliser la commande |\@highLight| de
-\pkg{lua-ul}: cette commande bascule vers un fond jaune jusqu'à la fin du groupe TeX courant. Comme le nom de cette
-commande contient le caractère |@|, il convient de lui donner un synonyme sans caractère |@| pour pouvoir
-l'utiliser directement dans |{Piton}|.
 
-\begingroup
-\fvset{commandchars=\~\#\+,formatcom=\color{gray}}
+\subsubsection{Le mécanisme «escape»}
+
+\index{begin-escape}
+\index{end-escape}
+
+Il est aussi possible de surcharger les listings Python pour y insérer du code LaTeX à peu près n'importe où (mais
+entre deux lexèmes, bien entendu). Cette fonctionnalité n'est pas activée par défaut par \pkg{piton}. Pour
+l'utiliser, il faut spécifier les deux délimiteurs marquant l'échappement (le premier le commençant et le deuxième
+le terminant) en utilisant les clés \Definition{begin-escape} et \Definition{end-escape} (\emph{qui ne sont accessibles
+que dans le préambule du document}). Les deux délimiteurs peuvent être identiques.
+
+\medskip
+On reprend l'exemple précédent de la factorielle et on souhaite surligner en rose l'instruction qui contient l'appel
+récursif. La commande |\highLight| de \pkg{lua-ul} permet de le faire avec la syntaxe |\highLight{LightPink}{...}|.
+Du fait de la présence de l'argument optionnel entre crochets, on ne peut pas utiliser la clé |detected-commands|
+comme précédemment mais on peut utiliser le mécanisme «escape».
+
+\smallskip
+On suppose que le préambule du document contient l'instruction :
+
 \begin{Verbatim}
-\makeatletter
-~emphase#\NewCommandCopy{\Jaune}{\@highLight}+
-\makeatother
+\PitonOptions{~emphase#begin-escape=!,end-escape=!@}
 \end{Verbatim}
-\endgroup
 
+On peut alors écrire :
 \begin{Verbatim}
 \begin{Piton}
 def fact(n):
@@ -1215,21 +1223,16 @@
     if n==0:
         return 1
     else:
-        ~emphase#!\Jaune!@return n*fact(n-1)
+        ~emphase#!\highLight[LightPink]{!@return n*fact(n-1)~emphase#!}!@
 \end{Piton}
 \end{Verbatim}
 
-\makeatletter
-\NewCommandCopy{\Jaune}{\@highLight}
-\makeatother
-
-
 \begin{Piton}
 def fact(n):
     if n==0:
         return 1
     else:
-        !\Jaune!return n*fact(n-1)
+        !\highLight[LightPink]{!return n*fact(n-1)!}!
 \end{Piton}
 
 
@@ -1955,6 +1958,7 @@
    \begin{pythonrepl}
  }
  {
+   \end{pythonrepl}
    \directlua
      {
        tex.print("\\begin{Piton}")
@@ -1962,7 +1966,6 @@
        tex.print("\\end{Piton}")
        tex.print("") 
      }
-   \end{pythonrepl}
  }
 \end{Verbatim}
 
@@ -1995,6 +1998,7 @@
    \begin{pythonrepl}
  }
  {
+   \end{pythonrepl}
    \directlua
      {
        tex.print("\\begin{Piton}")
@@ -2002,7 +2006,6 @@
        tex.print("\\end{Piton}")
        tex.print("") 
      }
-   \end{pythonrepl}
  }
 
 
@@ -2321,8 +2324,57 @@
 \end{Verbatim}
 
 
+
 \newpage
 
+\subsection{Le langage «minimal»}
+
+
+\label{minimal}
+\index{minimal (langage «minimal»)}
+
+\colorbox{yellow!50}{\bfseries Nouveau 2.4}\par\nobreak
+
+\bigskip
+On peut basculer vers le langage «|minimal|» avec |\PitonOptions{language = minimal}|
+
+\bigskip
+On peut aussi choisir le langage «|minimal|» pour un environnement |{Piton}| individuel :
+%
+\begin{Verbatim}
+\begin{Piton}~emphase#[language=minimal]@
+...
+\end{Piton}
+\end{Verbatim}
+
+\bigskip
+L'option est aussi disponible pour |\PitonInputFile| : |\PitonInputFile[language=minimal]{...}|
+
+
+\vspace{1cm}
+
+\begin{center}
+\begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
+\toprule
+\normalfont Style  & Usage \\
+\midrule
+Number & les nombres \\
+String & les chaînes de caractères (qui sont entre \texttt{"}) \\
+Comment & les commentaires (qui débutent par |#|) \\
+Comment.LaTeX & les commentaires commençant par \texttt{\#>} qui sont composés par \pkg{piton} comme du code LaTeX (et
+                appelés simplement «commentaires LaTeX» dans ce document) \\
+\bottomrule
+\end{tabularx}
+\end{center}
+
+\bigskip
+Ce langage «|minimal|» est proposé par \pkg{piton} à l'utilisateur final pour qu'il y a puisse y ajouter des
+formatages de mots-clés avec la commande |\SetPitonIdentifier| (cf. \ref{SetPitonIdentifier},
+p.~\pageref{SetPitonIdentifier}) et créer par exemple un langage pour pseudo-code.
+
+
+\newpage
+
 \phantomsection
 \addcontentsline{toc}{section}{Index}
 

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-01-15 21:00:10 UTC (rev 69436)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-01-15 21:00:21 UTC (rev 69437)
@@ -29,7 +29,7 @@
 \usepackage{geometry}
 \geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
 \usepackage{fontspec}
-\usepackage[dvipsnames]{xcolor}
+\usepackage[dvipsnames,svgnames]{xcolor}
 \usepackage{caption,tabularx,tcolorbox,luacolor,lua-ul,upquote}
 \def\emphase{\bgroup\color{RoyalPurple}\let\next=}
 \fvset{commandchars=\~\#\@,formatcom=\color{gray}}
@@ -43,7 +43,8 @@
     begin-escape = ! ,
     end-escape = ! ,
     begin-escape-math = \( , 
-    end-escape-math = \) 
+    end-escape-math = \) ,
+    detected-commands = highLight
   }
 
 \parindent 0pt
@@ -71,12 +72,12 @@
 % \iffalse
 %<*STY>
 % \fi
-\def\PitonFileVersion{2.3}
-\def\PitonFileDate{2024/01/06}
+\def\PitonFileVersion{2.4}
+\def\PitonFileDate{2024/01/15}
 % \iffalse
 %</STY>
 %<*LUA>
--- Version 2.3 of 2024/01/06
+-- Version 2.4 of 2024/01/15
 %</LUA>
 %\fi
 %
@@ -102,13 +103,12 @@
 % The package \pkg{piton} uses the Lua library LPEG\footnote{LPEG is a
 % pattern-matching library for Lua, written in C, based on \emph{parsing
 % expression grammars}:
-% \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} 
-% for parsing Python, OCaml, C or SQL listings and typesets them with syntactic
-% highlighting. Since it uses Lua code, it works with |lualatex| only (and won't
-% work with the other engines: |latex|, |pdflatex| and |xelatex|). It does not
-% use external program and the compilation does not require |--shell-escape|.
-% The compilation is very fast since all the parsing is done by the library
-% LPEG, written in C.
+% \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} for parsing Python, OCaml, C
+% or SQL listings and typesets them with syntactic highlighting. Since it uses
+% the Lua of LuaLaTeX, it works with |lualatex| only (and won't work with the
+% other engines: |latex|, |pdflatex| and |xelatex|). It does not use external
+% program and the compilation does not require |--shell-escape|. The compilation
+% is very fast since all the parsing is done by the library LPEG, written in C. 
 % 
 % \bigskip
 % Here is an example of code typeset by \pkg{piton}, with the environment |{Piton}|.
@@ -165,7 +165,8 @@
 % \subsection{Choice of the computer language}
 %
 % In current version, the package \pkg{piton} supports four computer languages:
-% Python, OCaml, SQL and C (in fact \CC).
+% Python, OCaml, SQL and C (in fact \CC). It supports also a special language
+% called ``|minimal|'': cf. \pageref{minimal}.
 %
 % \smallskip
 % By default, the language used is Python.
@@ -176,6 +177,10 @@
 % and its key |language|: |\PitonOptions{language = C}|.
 %
 % \smallskip
+% \colorbox{yellow!50}{\textbf{New 2.4}}\enskip The name of the L3 variable
+% corresponding to that key is |\l_piton_language_str|.
+%
+% \smallskip
 % In what follows, we will speak of Python, but the features described also
 % apply to the other languages.
 % 
@@ -323,8 +328,8 @@
 %
 % \begin{itemize}
 % \item The key \Definition{language} speficies which computer language is
-% considered (that key is case-insensitive). Four values are allowed :
-% |Python|, |OCaml|, |C| and |SQL|. The initial value is |Python|.
+% considered (that key is case-insensitive). Five values are allowed :
+% |Python|, |OCaml|, |C|, |SQL| and |minimal|. The initial value is |Python|.
 % 
 % \item \index{path} The key \Definition{path} specifies a path where the files included by
 % |\PitonInputFile| will be searched.
@@ -359,8 +364,7 @@
 % line numbering in the environments |{Piton}| and in the listings resulting
 % from the use of |\PitonInputFile|.
 % 
-% \colorbox{yellow!50}{\textbf{New 2.1}}\enskip In fact, the key |line-numbers| has
-% several subkeys.
+% In fact, the key |line-numbers| has several subkeys.
 % \begin{itemize}
 % \item With the key \Definition{line-numbers/skip-empty-lines}, the empty lines
 % are considered as non existent for the line numbering (if the key |/absolute|
@@ -572,8 +576,8 @@
 % 
 % \bigskip
 % The different styles, and their use by \pkg{piton} in the different languages
-% which it supports (Python, OCaml, C and SQL), are described in the part
-% \ref{Semantic}, starting at the page \pageref{Semantic}. 
+% which it supports (Python, OCaml, C, SQL and ``|minimal|''), are described in
+% the part \ref{Semantic}, starting at the page \pageref{Semantic}. 
 % 
 %
 % \bigskip
@@ -625,7 +629,8 @@
 % As expected, if an informatic language uses a given style and if that style has
 % no local definition for that language, the global version is used. That notion
 % of ``global style'' has no link with the notion of global definition in TeX
-% (the notion of \emph{group} in TeX).
+% (the notion of \emph{group} in TeX).\footnote{As regards the TeX groups, the
+% definitions done by \texttt{\textbackslash SetPitonStyle} are always local.}
 % 
 % \bigskip
 % The package \pkg{piton} itself (that is to say the file |piton.sty|) defines
@@ -863,8 +868,7 @@
 % \begin{itemize}
 % \item It's possible to specify the part that we want to insert by the numbers
 % of the lines (in the original file).
-% \item \colorbox{yellow!50}{\textbf{New 2.1}}\enskip It's also possible to
-% specify the part to insert with textual markers.
+% \item It's also possible to specify the part to insert with textual markers.
 % \end{itemize}
 % In both cases, if we want to number the lines with the numbers of the
 % lines in the file, we have to use the key |line-numbers/absolute|.
@@ -880,8 +884,6 @@
 %
 % \subsubsection{With textual markers}
 %
-% \colorbox{yellow!50}{\textbf{New 2.1}}
-%
 % \index{marker/beginning}
 % \index{marker/end}
 %
@@ -998,42 +1000,38 @@
 %
 % \subsection{Highlighting some identifiers}
 %
-% \index{identifiers (key)}
+% \label{SetPitonIdentifier}
 %
-% It's possible to require a changement of formating for some identifiers with
-% the key |identifiers| of |\PitonOptions|.\footnote{This feature is not
-% available for the language SQL because, in SQL, there is no identifiers :
-% there are only names of fields and names of tables.}
+% \colorbox{yellow!50}{\bfseries Modification 2.4}\par\nobreak
 %
 % \smallskip
-% That key takes in as argument a value of the following format:
+% The command |\SetPitonIdentifier| allows to change the formatting of some
+% identifiers.
 %
-% \quad |{ names = |\textsl{\ttfamily names}|, style = |\textsl{\ttfamily
-% instructions}| }|
+% \smallskip
+% That command takes in three arguments: one 
 %
 % \begin{itemize}
-% \item \textsl{\ttfamily names} is a (comma-separated) list of identifier
-% names; 
+% \item The optionnal argument (within square brackets) specifies the informatic
+% langage. If this argument is not present, the tunings done by
+% |\SetPitonIdentifier| will apply to all the informatic langages of
+% \pkg{piton}.\footnote{We recall, that, in the package \pkg{piton}, the
+% names of the informatic languages are case-insensitive.}
 %
-% \item \textsl{\ttfamily instructions} is a list of LaTeX instructions of the
+% \item The first mandatory argument is a comma-separated list of names of
+% identifiers.
+%
+% \item The second mandatory argument is a list of LaTeX instructions of the
 % same type as \pkg{piton} ``styles'' previously presented (cf~\ref{styles}
 % p.~\pageref{styles}). 
 % \end{itemize}
-%
+% 
 % \emph{Caution}: Only the identifiers may be concerned by that key. The
-% keywords and the built-in functions won't be affected, even if their name is
-% in the list \textsl{\ttfamily names}.
+% keywords and the built-in functions won't be affected, even if their name
+% appear in the first argument of the command |\SetPitonIdentifier|.
 % 
 % \begin{Verbatim}
-% \PitonOptions 
-%   {
-%     ~emphase#identifiers@ = 
-%      {
-%        ~emphase#names@ = { l1 , l2 } , 
-%        ~emphase#style@ = \color{red} 
-%      }
-%   }
-%
+% ~emphase#\SetPitonIdentifier{l1,l2}{\color{red}}@
 % \begin{Piton}
 % def tri(l):
 %     """Segmentation sort"""
@@ -1052,14 +1050,7 @@
 %
 % \begingroup
 %
-% \PitonOptions 
-%   {
-%     identifiers = 
-%      {
-%        names = { l1 , l2 } , 
-%        style = \color{red} 
-%      }
-%   }
+% \SetPitonIdentifier{l1,l2}{\color{red}}
 %
 % \begin{Piton}
 % def tri(l):
@@ -1076,19 +1067,15 @@
 % \endgroup
 % 
 % \bigskip
-% By using the key |identifier|, it's possible to add other built-in functions
-% (or other new keywords, etc.) that will be detected by \pkg{piton}.
+% By using the command |\SetPitonIdentifier|, it's possible to add other
+% built-in functions (or other new keywords, etc.) that will be detected by
+% \pkg{piton}.
 %
 %
 % \begin{Verbatim}
-% \PitonOptions 
-%   {
-%     ~emphase#identifiers@ = 
-%      {
-%        names = { cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial } , 
-%        style = \PitonStyle{Name.Builtin}
-%      }
-%   }
+% ~emphase#\SetPitonIdentifier[Python]@
+%   {cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial}
+%   {\PitonStyle{Name.Builtin}}
 %
 % \begin{Piton}
 % from math import *
@@ -1101,14 +1088,9 @@
 %
 % \begingroup
 %
-% \PitonOptions 
-%   {
-%     identifiers = 
-%      {
-%        names = { cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial } , 
-%        style = \PitonStyle{Name.Builtin}
-%      }
-%   }
+% \SetPitonIdentifier[Python]
+%   {cos, sin, tan, floor, ceil, trunc, pow, exp, ln, factorial}
+%   {\PitonStyle{Name.Builtin}}
 %
 % \begin{Piton}
 % from math import *
@@ -1131,6 +1113,8 @@
 % \item It's possible to compose comments entirely in LaTeX.
 % \item It's possible to have the elements between \texttt{\$} in the comments
 % composed in LateX mathematical mode.
+% \item It's possible to ask \pkg{piton} to detect automatically some LaTeX
+% commands, thanks to the key |detected-commands|.
 % \item It's also possible to insert LaTeX code almost everywhere in a Python listing.
 % \end{itemize}
 %
@@ -1216,7 +1200,54 @@
 % def square(x):
 %     return x*x # compute $x^2$
 % \end{Piton}
+%
+% \subsubsection{The key ``detected-commands''}
+%
+% \index{detected-commands (key)}
+%
+% \colorbox{yellow!50}{\bfseries New 2.4}\par\nobreak
+%
+% \smallskip
+% The key |detected-commands| of |\PitonOptions| allow to specify a
+% (comma-separated) list of names of LaTeX commands that will be detected 
+% directly by \pkg{piton}.
+%
+% \begin{itemize}
+% \item The key |detected-commands| must be used in the preamble of the LaTeX document.
 % 
+% \item The names of the LaTeX commands must appear without the leading
+% backslash (eg. |detected-commands = { emph, bfseries }|). 
+%
+% \item These commands must be LaTeX commands with only one (mandatory) argument
+% between braces (and these braces must be explicit). 
+% \end{itemize}
+%
+% \medskip
+% We assume that the preamble of the LaTeX document contains the following line.
+% \begin{Verbatim}
+% \PitonOptions{~emphase#detected-commands@ = highLight}
+% \end{Verbatim}
+%
+% Then, it's possible to write directly:
+% \begin{Verbatim}
+% \begin{Piton}
+% def fact(n):
+%     if n==0:
+%         return 1
+%     else:
+%         ~emphase#\highLight@{return n*fact(n-1)}
+% \end{Piton}
+% \end{Verbatim}
+%
+% \begin{Piton}
+% def fact(n):
+%     if n==0:
+%         return 1
+%     else:
+%         \highLight{return n*fact(n-1)}
+% \end{Piton}
+%
+% 
 % \subsubsection{The mechanism ``escape''}
 %
 % \index{escape-math}
@@ -1233,7 +1264,15 @@
 % in the preamble of the document}.
 %
 % \medskip
-% In the following example, we assume that the preamble of the document contains
+% We consider once again the previous example of a recursive programmation of
+% the factorial. We want to highlight in pink the instruction containing the
+% recursive call. With the package \pkg{lua-el}, we can use the syntax
+% |\highLight[LightPink]{...}|. Because of the optional argument between square
+% brackets, it's not possible to use the key |detected-commands| but it's
+% possible to acheive our goal with the more general mechanism ``escape''.
+%
+% \medskip
+% We assume that the preamble of the document contains
 % the following instruction:
 %
 % \begin{Verbatim}
@@ -1241,10 +1280,7 @@
 % \end{Verbatim}
 %
 % \medskip
-% In the following code, which is a recursive programmation of the mathematical
-% factorial, we decide to highlight in yellow the instruction which contains the
-% recursive call. That example uses the command |\highLight| of \pkg{lua-ul}
-% (that package requires itself the package \pkg{luacolor}).
+% Then, it's possible to write:
 % \begin{Verbatim}
 % \begin{Piton}
 % def fact(n):
@@ -1251,7 +1287,7 @@
 %     if n==0:
 %         return 1
 %     else:
-%         ~emphase#!\highLight{!@return n*fact(n-1)~emphase#!}!@
+%         ~emphase#!\highLight[LightPink]{!@return n*fact(n-1)~emphase#!}!@
 % \end{Piton}
 % \end{Verbatim}
 %
@@ -1260,49 +1296,11 @@
 %     if n==0:
 %         return 1
 %     else:
-%         !\highLight{!return n*fact(n-1)!}!
+%         !\highLight[LightPink]{!return n*fact(n-1)!}!
 %    \end{Piton}
-%         
-% \bigskip
-% In fact, in that case, it's probably easier to use the command |\@highLight|
-% of \pkg{lua-ul}: that command sets a yellow background until the end of the
-% current TeX group. Since the name of that command contains the character |@|,
-% it's necessary to define a synonym without |@| in order to be able to use it
-% directly in |{Piton}|.
-% \begingroup
-% \fvset{commandchars=\~\#\+,formatcom=\color{gray}}
-% \begin{Verbatim}
-% \makeatletter
-% ~emphase#\NewCommandCopy{\Yellow}{\@highLight}+
-% \makeatother
-% \end{Verbatim}
-% \endgroup
 %
-% \begin{Verbatim}
-% \begin{Piton}
-% def fact(n):
-%     if n==0:
-%         return 1
-%     else:
-%         ~emphase#!\Yellow!@return n*fact(n-1)
-% \end{Piton}
-% \end{Verbatim}
 %
-% \makeatletter
-% \NewCommandCopy{\Yellow}{\@highLight}
-% \makeatother
 %
-%
-% \begin{Piton}
-% def fact(n):
-%     if n==0:
-%         return 1
-%     else:
-%         !\Yellow!return n*fact(n-1)
-% \end{Piton}
-%
-%
-%
 % \bigskip
 % \emph{Caution} : The escape to LaTeX allowed by the |begin-escape| and
 % |end-escape| is not active in the strings nor in the Python comments (however,
@@ -2242,7 +2240,52 @@
 % \SetPitonStyle~emphase#[SQL]@{Keywords = \bfseries \MakeUppercase}
 % \end{Verbatim}
 %
+% \newpage
 %
+% \subsection{The language ``minimal''}
+%
+% \colorbox{yellow!50}{\bfseries New 2.4}\par\nobreak
+%
+% \bigskip
+% It's possible to switch to the language ``|minimal|'' with |\PitonOptions{language = minimal}|.
+%
+% \bigskip
+% It's also possible to set the language ``|minimal|'' for an individual environment |{Piton}|. 
+% %
+% \begin{Verbatim}
+% \begin{Piton}~emphase#[language=minimal]@
+% ...
+% \end{Piton}
+% \end{Verbatim}
+%
+% \bigskip
+% The option exists also for |\PitonInputFile| : |\PitonInputFile[language=minimal]{...}|
+%
+%
+% \label{minimal}
+%
+% \vspace{1cm}
+%
+% \begin{center}
+% \begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
+% \toprule
+% \normalfont Style  & Usage \\
+% \midrule
+% Number & the numbers \\
+% String & the strings (between \texttt{"}) \\
+% Comment & les comments (which begins with |#|) \\
+% Comment.LaTeX &  the comments beginning with \texttt{\#>}, which are composed by
+%   \pkg{piton} as LaTeX code (merely named ``LaTeX comments'' in this document) \\
+% \bottomrule
+% \end{tabularx}
+% \end{center}
+%
+% \bigskip
+% That language is provided for the final user who might wish to add keywords in
+% that language (with the command |\SetPitonIdentifier|: cf. \ref{SetPitonIdentifier},
+% p.~\pageref{SetPitonIdentifier}) in order to create, for example, a language
+% for pseudo-code.
+%
 % \newpage
 %
 % \section{Implementation}
@@ -2400,6 +2443,14 @@
 \cs_new_protected:Npn \@@_fatal:n { \msg_fatal:nn { piton } }
 \cs_new_protected:Npn \@@_fatal:nn { \msg_fatal:nnn { piton } }
 \cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { piton } }
+\cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { piton } }
+\cs_new_protected:Npn \@@_gredirect_none:n #1 
+  {
+    \group_begin:
+    \globaldefs = 1
+    \msg_redirect_name:nnn { piton } { #1 } { none }
+    \group_end:
+  }
 %    \end{macrocode}
 %
 % \bigskip
@@ -2422,11 +2473,17 @@
 % 
 % \bigskip
 %    \begin{macrocode}
-\@@_msg_new:nn { piton.lua~not~found }
+\@@_msg_new:nnn { piton.lua~not~found }
   { 
     The~file~'piton.lua'~can't~be~found.\\ 
-    The~package~'piton'~won't~be~loaded.
+    The~package~'piton'~won't~be~loaded.\\
+    If~you~want~to~know~how~to~retrieve~the~file~'piton.lua',~type~H~<return>.
   }
+  {
+    On~the~site~CTAN,~go~to~the~page~of~'piton':~https://ctan.org/pkg/piton.~
+    The~file~'README.md'~explains~how~to~retrieve~the~files~'piton.sty'~and~
+    'piton.lua'.
+  }
 %    \end{macrocode}
 %
 % \bigskip
@@ -2605,7 +2662,11 @@
 %
 % \bigskip
 %    \begin{macrocode}
-\lua_now:n { piton = piton~or { } }
+\lua_now:n 
+  { 
+    piton = piton~or { } 
+    piton.ListCommands = lpeg.P ( false ) 
+  }
 %    \end{macrocode}
 % 
 % \bigskip
@@ -2615,8 +2676,8 @@
 % considered (the initial value is |python|).
 %
 %    \begin{macrocode}
-\str_new:N \l_@@_language_str
-\str_set:Nn \l_@@_language_str { python }
+\str_new:N \l_piton_language_str
+\str_set:Nn \l_piton_language_str { python }
 %    \end{macrocode}
 % 
 % \medskip
@@ -2631,11 +2692,6 @@
 \bool_new:N \l_@@_in_PitonInputFile_bool 
 %    \end{macrocode}
 %
-% \medskip
-% The following flag will be raised in the |\AtBeginDocument|.
-%    \begin{macrocode}
-\bool_new:N \g_@@_in_document_bool
-%    \end{macrocode}
 % 
 % \medskip
 % We will compute (with Lua) the numbers of lines of the Python code and store
@@ -3331,6 +3387,9 @@
 %    \begin{macrocode}
 \keys_define:nn { PitonOptions }
   {
+    detected-commands .code:n =  \@@_detected_commands:n { #1 } , 
+    detected-commands .value_required:n = true , 
+    detected-commands .usage:n = preamble , 
 %    \end{macrocode}
 % First, we put keys that should be avalaible only in the preamble.
 %    \begin{macrocode}
@@ -3367,7 +3426,7 @@
 % Now, general keys.
 %    \begin{macrocode}
     language         .code:n = 
-      \str_set:Nx \l_@@_language_str { \str_lowercase:n { #1 } } , 
+      \str_set:Nx \l_piton_language_str { \str_lowercase:n { #1 } } , 
     language         .value_required:n  = true ,
     path             .str_set:N         = \l_@@_path_str ,
     path             .value_required:n  = true , 
@@ -3519,14 +3578,9 @@
 %    \end{macrocode}
 % 
 %
+% 
 %
 % \bigskip
-%    \begin{macrocode}
-\hook_gput_code:nnn { begindocument } { . }
-  { \bool_gset_true:N \g_@@_in_document_bool }
-%    \end{macrocode}
-% 
-% \bigskip
 % \subsubsection{The numbers of the lines}
 %
 % \medskip
@@ -3619,7 +3673,7 @@
     \tl_set:Nx \l_tmpa_tl 
       { 
         \lua_now:e 
-          { piton.ParseBis('\l_@@_language_str',token.scan_string()) }
+          { piton.ParseBis('\l_piton_language_str',token.scan_string()) }
           { #1 } 
       }
     \bool_if:NTF \l_@@_show_spaces_bool
@@ -3649,7 +3703,7 @@
     \tl_set:Nx \l_tmpa_tl 
       { 
         \lua_now:e 
-          { piton.Parse('\l_@@_language_str',token.scan_string()) } 
+          { piton.Parse('\l_piton_language_str',token.scan_string()) } 
           { #1 } 
       }
     \bool_if:NT \l_@@_show_spaces_bool
@@ -3681,7 +3735,7 @@
         \tl_set:Nx \l_tmpa_tl 
           { 
             \lua_now:e 
-              { piton.ParseTer('\l_@@_language_str',token.scan_string()) } 
+              { piton.ParseTer('\l_piton_language_str',token.scan_string()) } 
               { #1 } 
           }
       }
@@ -3689,7 +3743,7 @@
         \tl_set:Nx \l_tmpa_tl 
           { 
             \lua_now:e 
-              { piton.Parse('\l_@@_language_str',token.scan_string()) }
+              { piton.Parse('\l_piton_language_str',token.scan_string()) }
               { #1 } 
           }
       }
@@ -3718,7 +3772,7 @@
         \tl_set:Nx \l_tmpa_tl 
           { 
             \lua_now:e 
-              { piton.ParseTer('\l_@@_language_str',token.scan_string()) } 
+              { piton.ParseTer('\l_piton_language_str',token.scan_string()) } 
               { #1 }
           } 
       }
@@ -3726,7 +3780,7 @@
         \tl_set:Nx \l_tmpa_tl 
           { 
             \lua_now:e 
-              { piton.Parse('\l_@@_language_str',token.scan_string()) }
+              { piton.Parse('\l_piton_language_str',token.scan_string()) }
               { #1 } 
           }
       }
@@ -3919,7 +3973,7 @@
               { 
                 piton.GobbleParse
                   ( 
-                    '\l_@@_language_str' , 
+                    '\l_piton_language_str' , 
                     \int_use:N \l_@@_gobble_int , 
                     token.scan_argument() 
                   ) 
@@ -4013,10 +4067,9 @@
       { \str_set:Nn \l_@@_file_name_str { #3 } } 
       { 
         \str_set_eq:NN \l_@@_file_name_str \l_@@_path_str 
-        \str_put_right:Nn \l_@@_file_name_str { / }
-        \str_put_right:Nn \l_@@_file_name_str { #3 }
+        \str_put_right:Nn \l_@@_file_name_str { / #3 }
       }
-    \exp_args:NV \file_if_exist:nTF \l_@@_file_name_str 
+    \file_if_exist:nTF { \l_@@_file_name_str }
       { \@@_input_file:nn { #1 } { #2 } }
       { \msg_error:nnn { piton } { Unknown~file } { #3 } } 
     \group_end:
@@ -4105,7 +4158,7 @@
       \lua_now:e
         { 
           piton.ParseFile(
-           '\l_@@_language_str' ,
+           '\l_piton_language_str' ,
            '\l_@@_file_name_str' ,
            \int_use:N \l_@@_first_line_int , 
            \int_use:N \l_@@_last_line_int ) 
@@ -4161,7 +4214,7 @@
 %    \begin{macrocode}
 \NewDocumentCommand { \PitonStyle } { m } 
   { 
-    \cs_if_exist_use:cF { pitonStyle _ \l_@@_language_str  _ #1 }
+    \cs_if_exist_use:cF { pitonStyle _ \l_piton_language_str  _ #1 }
       { \use:c { pitonStyle _ #1 } }
   }
 %    \end{macrocode}
@@ -4172,7 +4225,7 @@
   { 
     \str_set:Nx \l_@@_SetPitonStyle_option_str { \str_lowercase:n { #1 } }
     \str_if_eq:onT \l_@@_SetPitonStyle_option_str { current-language }
-      { \str_set_eq:NN \l_@@_SetPitonStyle_option_str \l_@@_language_str }
+      { \str_set_eq:NN \l_@@_SetPitonStyle_option_str \l_piton_language_str }
     \keys_set:nn { piton / Styles } { #2 } 
     \str_clear:N \l_@@_SetPitonStyle_option_str 
   } 
@@ -4332,10 +4385,34 @@
 % \bigskip
 % \subsubsection{Highlighting some identifiers}
 %
+%
+% \medskip
+%    \begin{macrocode}
+\NewDocumentCommand { \SetPitonIdentifier } { o m m } 
+  { 
+    \clist_set:Nn \l_tmpa_clist { #2 }
+    \IfNoValueTF { #1 }
+      { 
+        \clist_map_inline:Nn \l_tmpa_clist 
+          { \cs_set:cpn { pitonIdentifier _ ##1 } { #3 } }
+      }
+      {
+        \str_set:Nx \l_tmpa_str { \str_lowercase:n { #1 } }
+        \str_if_eq:onT \l_tmpa_str { current-language }
+          { \str_set_eq:NN \l_tmpa_str \l_piton_language_str }
+        \clist_map_inline:Nn \l_tmpa_clist 
+          { \cs_set:cpn { pitonIdentifier _ \l_tmpa_str _ ##1 } { #3 } }
+      }
+  } 
+%    \end{macrocode}
 % 
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_identifier:n #1
-  { \cs_if_exist_use:c { PitonIdentifier _ \l_@@_language_str _ #1 } { #1 } } 
+  { 
+    \cs_if_exist_use:cF { pitonIdentifier _ \l_piton_language_str _ #1 } 
+      { \cs_if_exist_use:c { pitonIdentifier_ #1 } }
+    { #1 } 
+  } 
 %    \end{macrocode}
 %
 % \bigskip
@@ -4357,6 +4434,8 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_set_identifiers:n #1
   {
+    \@@_error:n { key~identifiers~deprecated }
+    \@@_gredirect_none:n { key~identifiers~deprecated }
     \clist_clear_new:N \l_@@_identifiers_names_tl 
     \tl_clear_new:N \l_@@_style_tl 
     \keys_set:nn { Piton / identifiers } { #1 }
@@ -4363,7 +4442,7 @@
     \clist_map_inline:Nn \l_@@_identifiers_names_tl 
       {
         \tl_set_eq:cN 
-          { PitonIdentifier _ \l_@@_language_str _ ##1 }
+          { PitonIdentifier _ \l_piton_language_str _ ##1 }
           \l_@@_style_tl
       }
   }
@@ -4390,7 +4469,7 @@
 % here the affectation is global because we have to exit many groups and even
 % the environments |{Piton}|).
 %    \begin{macrocode}
-    \cs_gset_protected:cpn { PitonIdentifier _ \l_@@_language_str _ #1 } 
+    \cs_gset_protected:cpn { PitonIdentifier _ \l_piton_language_str _ #1 } 
       { \PitonStyle { UserFunction } }
 %    \end{macrocode}
 % Now, we put the name of that new user function in the dedicated sequence
@@ -4397,15 +4476,15 @@
 % (specific of the current language). {\bfseries That sequence will be used only
 % by |\PitonClearUserFunctions|}.
 %    \begin{macrocode}
-    \seq_if_exist:cF { g_@@_functions _ \l_@@_language_str _ seq }
-      { \seq_new:c { g_@@_functions _ \l_@@_language_str _ seq } }
-    \seq_gput_right:cn { g_@@_functions _ \l_@@_language_str _ seq } { #1 }
+    \seq_if_exist:cF { g_@@_functions _ \l_piton_language_str _ seq }
+      { \seq_new:c { g_@@_functions _ \l_piton_language_str _ seq } }
+    \seq_gput_right:cn { g_@@_functions _ \l_piton_language_str _ seq } { #1 }
 %    \end{macrocode}
 % We update |\g_@@_languages_seq| which is used only by the command
 % |\PitonClearUserFunctions| when it's used without its optional argument.
 %    \begin{macrocode}
-    \seq_if_in:NVF \g_@@_languages_seq \l_@@_language_str 
-      { \seq_gput_left:NV \g_@@_languages_seq \l_@@_language_str }
+    \seq_if_in:NVF \g_@@_languages_seq \l_piton_language_str 
+      { \seq_gput_left:NV \g_@@_languages_seq \l_piton_language_str }
   }
 %    \end{macrocode}
 %
@@ -4493,6 +4572,15 @@
 % \bigskip
 % \subsubsection{The error messages of the package}
 % 
+%    \begin{macrocode}
+\@@_msg_new:nn { key~identifiers~deprecated }
+  {
+    The~key~'identifiers'~in~the~command~\token_to_str:N PitonOptions\ 
+    is~now~deprecated:~you~should~use~the~command~
+    \token_to_str:N \SetPitonIdentifier\ instead.\\
+    However,~you~can~go~on.
+  }
+%    \end{macrocode}
 % 
 %    \begin{macrocode}
 \@@_msg_new:nn { Unknown~key~for~SetPitonStyle } 
@@ -4550,7 +4638,7 @@
 %   \begin{macrocode}
 \@@_msg_new:nn { syntax~error }
   {
-    Your~code~\l_@@_language_str\ is~not~syntactically~correct.\\
+    Your~code~\l_piton_language_str\ is~not~syntactically~correct.\\
     It~won't~be~printed~in~the~PDF~file.
   }
 %    \end{macrocode}
@@ -4617,11 +4705,11 @@
     break-lines-in-Piton,~
     continuation-symbol,~ 
     continuation-symbol-on-indentation,~
+    detected-commands,~
     end-of-broken-line,~
     end-range,~
     env-gobble,~
     gobble,~
-    identifiers,~
     indent-broken-lines,~
     language,~
     left-margin,~
@@ -4673,28 +4761,47 @@
   }
 %    \end{macrocode}
 %
-% \bigskip
-%    \begin{macrocode}
-\@@_msg_new:nn { Python~error }
-  { A~Python~error~has~been~detected. }
-%    \end{macrocode}
 %
 % \bigskip
 % \subsubsection{We load piton.lua}
 %
-%
 % \bigskip
 %    \begin{macrocode}
 \hook_gput_code:nnn { begindocument } { . }
   { \lua_now:e { require("piton.lua") } }
+%    \end{macrocode}
+% 
+% \bigskip
+% \subsubsection{Detected commands}
+%
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_detected_commands:n #1
+  { \lua_now:n { piton.addListCommands('#1') } }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
+\ExplSyntaxOff
+\directlua 
+  {
+    lpeg.locale(lpeg)
+    local P , alpha , C , Cf, space = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space
+    local One_P = space ^ 0 
+                  * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end ) 
+                  * space ^ 0 
+    function piton.addListCommands( key_value )
+       piton.ListCommands =  
+         piton.ListCommands + 
+           Cf ( One_P * ( P "," * One_P ) ^ 0  ,
+                ( function (s,t) return s + t end ) ) : match ( key_value ) 
+    end
+  }
 %</STY>
 %    \end{macrocode}
 % 
+% 
 % \bigskip
 % \subsection{The Lua part of the implementation}
 %
-% 
-%
 % \bigskip
 % The Lua code will be loaded via a |{luacode*}| environment. The environment
 % is by itself a Lua block and the local declarations will be local to that
@@ -5342,6 +5449,23 @@
 %    \end{macrocode}
 %
 % \bigskip
+% \paragraph{Detected commands}
+%
+%    \begin{macrocode}
+DetectedCommands = 
+      Ct ( Cc "Open" 
+            * C ( 
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopPython:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+%    \end{macrocode}
+% 
+% \bigskip
 % \paragraph{EOL}
 %
 % \bigskip
@@ -5622,6 +5746,7 @@
      + Escape + EscapeMath
      + CommentLaTeX
      + Beamer
+     + DetectedCommands 
      + LongString 
      + Comment
      + ExceptionInConsole
@@ -5896,6 +6021,20 @@
 end
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+DetectedCommands = 
+      Ct ( Cc "Open" 
+            * C ( 
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopOCaml:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+%    \end{macrocode}
+% 
 %
 % \bigskip
 % \paragraph{EOL}
@@ -6134,6 +6273,7 @@
      + Tab
      + Escape + EscapeMath
      + Beamer 
+     + DetectedCommands
      + TypeParameter
      + String + QuotedString + Char
      + Comment
@@ -6362,6 +6502,20 @@
 end
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+DetectedCommands = 
+      Ct ( Cc "Open" 
+            * C ( 
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopC:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+%    \end{macrocode}
+% 
 % \bigskip
 % \paragraph{EOL}
 %
@@ -6459,6 +6613,7 @@
      + Escape + EscapeMath 
      + CommentLaTeX
      + Beamer
+     + DetectedCommands
      + Preproc
      + Comment + LongComment
      + Delim
@@ -6524,6 +6679,7 @@
       P "=" + P "!=" + P "<>" + P ">=" + P ">" + P "<=" + P "<"  + S "*+/"
     )
 %    \end{macrocode}
+%
 % In SQL, the keywords are case-insensitive. That's why we have a little
 % complication. We will catch the keywords with the identifiers and, then,
 % distinguish the keywords with a Lua function. However, some keywords will be
@@ -6669,6 +6825,20 @@
 end
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+DetectedCommands = 
+      Ct ( Cc "Open" 
+            * C ( 
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopSQL:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+%    \end{macrocode}
+%
 % \bigskip
 % \paragraph{EOL}
 %
@@ -6813,6 +6983,7 @@
      + Escape + EscapeMath 
      + CommentLaTeX
      + Beamer
+     + DetectedCommands
      + Comment + LongComment
      + Delim
      + Operator
@@ -6855,6 +7026,168 @@
 languages['sql'] = languageSQL
 %    \end{macrocode}
 % 
+% \subsubsection{The LPEG language Minimal}
+% 
+%    \begin{macrocode}
+local CommentMath = 
+  P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$"
+
+local Comment = 
+  WithStyle ( 'Comment' ,
+     Q ( P "#" ) 
+     * ( CommentMath + Q ( ( 1 - S "$\r" ) ^ 1 ) ) ^ 0 ) 
+  * ( EOL + -1 )
+
+
+local String = 
+  WithStyle ( 'String.Short' ,
+      Q "\"" 
+      * ( VisualSpace 
+          + Q ( ( P "\\\"" + 1 - S " \"" ) ^ 1 ) 
+        ) ^ 0 
+      * Q "\""
+    )
+
+
+local balanced_braces =
+  P { "E" ,
+       E = 
+           (
+             P "{" * V "E" * P "}" 
+             + 
+             String  
+             + 
+             ( 1 - S "{}" ) 
+           ) ^ 0 
+    }
+
+if piton_beamer 
+then
+  Beamer =
+      L ( P "\\pause" * ( P "[" * ( 1 - P "]" ) ^ 0 * P "]" ) ^ -1 ) 
+    + 
+      Ct ( Cc "Open" 
+            * C ( 
+                  ( 
+                    P "\\uncover" + P "\\only" + P "\\alert" + P "\\visible"
+                    + P "\\invisible" + P "\\action" 
+                  ) 
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopMinimal:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+    + OneBeamerEnvironment ( "uncoverenv" , MainLoopMinimal ) 
+    + OneBeamerEnvironment ( "onlyenv" , MainLoopMinimal ) 
+    + OneBeamerEnvironment ( "visibleenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "invisibleenv" , MainLoopMinimal ) 
+    + OneBeamerEnvironment ( "alertenv" , MainLoopMinimal ) 
+    + OneBeamerEnvironment ( "actionenv" , MainLoopMinimal ) 
+    +
+      L ( 
+          ( P "\\alt" )
+          * P "<" * (1 - P ">") ^ 0 * P ">" 
+          * P "{" 
+        )
+      * K ( 'ParseAgain.noCR' , balanced_braces ) 
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces ) 
+      * L ( P "}" )
+    +  
+      L ( 
+          ( P "\\temporal" )
+          * P "<" * (1 - P ">") ^ 0 * P ">" 
+          * P "{" 
+        )
+      * K ( 'ParseAgain.noCR' , balanced_braces ) 
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces ) 
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces ) 
+      * L ( P "}" )
+end
+
+DetectedCommands = 
+      Ct ( Cc "Open" 
+            * C ( 
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 
+                  * P "{" 
+                ) 
+            * Cc "}" 
+         ) 
+       * ( C ( balanced_braces ) / (function (s) return MainLoopMinimal:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" ) 
+
+local EOL = 
+  P "\r" 
+  *
+  (
+    ( space^0 * -1 )
+    + 
+    Ct ( 
+         Cc "EOL"
+         * 
+         Ct (
+              Lc "\\@@_end_line:"
+              * BeamerEndEnvironments 
+              * BeamerBeginEnvironments 
+              * Lc "\\@@_newline: \\@@_begin_line:"
+            )
+       )
+  ) 
+  *
+  SpaceIndentation ^ 0
+
+local CommentMath = 
+  P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$" -- $
+
+local CommentLaTeX =
+  P(piton.comment_latex) 
+  * Lc "{\\PitonStyle{Comment.LaTeX}{\\ignorespaces" 
+  * L ( ( 1 - P "\r" ) ^ 0 ) 
+  * Lc "}}" 
+  * ( EOL + -1 )  
+
+local identifier = letter * alphanum ^ 0
+
+local Identifier = K ( 'Identifier' , identifier )
+
+local MainMinimal = 
+       EOL
+     + Space 
+     + Tab
+     + Escape + EscapeMath 
+     + CommentLaTeX
+     + Beamer
+     + DetectedCommands
+     + Comment
+     + Delim
+     + String
+     + Punct
+     + Identifier 
+     + Number
+     + Word
+
+MainLoopMinimal = 
+  (  ( space^1 * -1 ) 
+     + MainMinimal
+  ) ^ 0 
+
+languageMinimal =
+  Ct (
+       ( ( space - P "\r" ) ^ 0 * P "\r" ) ^ -1 
+       * BeamerBeginEnvironments 
+       * Lc '\\@@_begin_line:'
+       * SpaceIndentation ^ 0 
+       * MainLoopMinimal
+       * -1 
+       * Lc '\\@@_end_line:' 
+     )
+languages['minimal'] = languageMinimal
+
 % \bigskip
 % \subsubsection{The function Parse}
 %
@@ -7226,8 +7559,24 @@
 %
 % \verb|https://github.com/fpantigny/piton|
 %
+% \subsection*{Changes between versions 2.3 and 2.4}
+%
+% The key |identifiers| of the command |\PitonOptions| is now deprecated and
+% replaced by the new command |\SetPitonIdentifier|.
+%
+% A new special language called ``minimal'' has been added.
+%
+% New key |detected-commands|.
+%
 % \subsection*{Changes between versions 2.2 and 2.3}
 %
+% New key |detected-commands|
+% 
+% The variable |\l_piton_language_str| is now public.
+% 
+%
+% \subsection*{Changes between versions 2.2 and 2.3}
+%
 % New key |write|.
 % 
 % \subsection*{Changes between versions 2.1 and 2.2}

Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.ins
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.ins	2024-01-15 21:00:10 UTC (rev 69436)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.ins	2024-01-15 21:00:21 UTC (rev 69437)
@@ -34,7 +34,7 @@
 \generate{\file{piton.sty}{\from{piton.dtx}{STY}}}
 \def\MetaPrefix{--}
 \preamble
--------------------------------------------
+---------------------------------------------
 Copyright (C) 2022-2024 by F. Pantigny
 
 This file may be distributed and/or modified under the
@@ -48,7 +48,7 @@
 LaTeX version 2005/12/01 or later.
 -------------------------------------------
 
-This file is part of the LuaLaTeX package 'piton'.
+This file is part of the LuaLaTeX package 'piton'. 
 \endpreamble
 \nopostamble
 \generate{\file{piton.lua}{\from{piton.dtx}{LUA}}}

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-01-15 21:00:10 UTC (rev 69436)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-01-15 21:00:21 UTC (rev 69437)
@@ -5,7 +5,7 @@
 -- The original source files were:
 --
 -- piton.dtx  (with options: `LUA')
--- -------------------------------------------
+-- ---------------------------------------------
 -- Copyright (C) 2022-2024 by F. Pantigny
 -- 
 -- This file may be distributed and/or modified under the
@@ -20,7 +20,7 @@
 -- -------------------------------------------
 -- 
 -- This file is part of the LuaLaTeX package 'piton'.
--- Version 2.3 of 2024/01/06
+-- Version 2.4 of 2024/01/15
 
 
 if piton.comment_latex == nil then piton.comment_latex = ">" end
@@ -337,6 +337,17 @@
       * K ( 'ParseAgain.noCR' , balanced_braces )
       * L ( P "}" )
 end
+DetectedCommands =
+      Ct ( Cc "Open"
+            * C (
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopPython:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
 local PromptHastyDetection = ( # ( P ">>>" + P "..." ) * Lc ( '\\__piton_prompt:' ) ) ^ -1
 local Prompt = K ( 'Prompt' , ( ( P ">>>" + P "..." ) * P " " ^ -1 ) ^ -1  )
 local EOL =
@@ -480,6 +491,7 @@
      + Escape + EscapeMath
      + CommentLaTeX
      + Beamer
+     + DetectedCommands
      + LongString
      + Comment
      + ExceptionInConsole
@@ -666,6 +678,17 @@
       * K ( 'ParseAgain.noCR' , balanced_braces )
       * L ( P "}" )
 end
+DetectedCommands =
+      Ct ( Cc "Open"
+            * C (
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopOCaml:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
 local EOL =
   P "\r"
   *
@@ -814,6 +837,7 @@
      + Tab
      + Escape + EscapeMath
      + Beamer
+     + DetectedCommands
      + TypeParameter
      + String + QuotedString + Char
      + Comment
@@ -969,6 +993,17 @@
       * K ( 'ParseAgain.noCR' , balanced_braces )
       * L ( P "}" )
 end
+DetectedCommands =
+      Ct ( Cc "Open"
+            * C (
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopC:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
 local EOL =
   P "\r"
   *
@@ -1020,6 +1055,7 @@
      + Escape + EscapeMath
      + CommentLaTeX
      + Beamer
+     + DetectedCommands
      + Preproc
      + Comment + LongComment
      + Delim
@@ -1158,6 +1194,17 @@
       * K ( 'ParseAgain.noCR' , balanced_braces )
       * L ( P "}" )
 end
+DetectedCommands =
+      Ct ( Cc "Open"
+            * C (
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopSQL:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
 local EOL =
   P "\r"
   *
@@ -1253,6 +1300,7 @@
      + Escape + EscapeMath
      + CommentLaTeX
      + Beamer
+     + DetectedCommands
      + Comment + LongComment
      + Delim
      + Operator
@@ -1277,6 +1325,163 @@
        * Lc '\\__piton_end_line:'
      )
 languages['sql'] = languageSQL
+local CommentMath =
+  P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$"
+
+local Comment =
+  WithStyle ( 'Comment' ,
+     Q ( P "#" )
+     * ( CommentMath + Q ( ( 1 - S "$\r" ) ^ 1 ) ) ^ 0 )
+  * ( EOL + -1 )
+
+local String =
+  WithStyle ( 'String.Short' ,
+      Q "\""
+      * ( VisualSpace
+          + Q ( ( P "\\\"" + 1 - S " \"" ) ^ 1 )
+        ) ^ 0
+      * Q "\""
+    )
+
+local balanced_braces =
+  P { "E" ,
+       E =
+           (
+             P "{" * V "E" * P "}"
+             +
+             String
+             +
+             ( 1 - S "{}" )
+           ) ^ 0
+    }
+
+if piton_beamer
+then
+  Beamer =
+      L ( P "\\pause" * ( P "[" * ( 1 - P "]" ) ^ 0 * P "]" ) ^ -1 )
+    +
+      Ct ( Cc "Open"
+            * C (
+                  (
+                    P "\\uncover" + P "\\only" + P "\\alert" + P "\\visible"
+                    + P "\\invisible" + P "\\action"
+                  )
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopMinimal:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
+    + OneBeamerEnvironment ( "uncoverenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "onlyenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "visibleenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "invisibleenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "alertenv" , MainLoopMinimal )
+    + OneBeamerEnvironment ( "actionenv" , MainLoopMinimal )
+    +
+      L (
+          ( P "\\alt" )
+          * P "<" * (1 - P ">") ^ 0 * P ">"
+          * P "{"
+        )
+      * K ( 'ParseAgain.noCR' , balanced_braces )
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces )
+      * L ( P "}" )
+    +
+      L (
+          ( P "\\temporal" )
+          * P "<" * (1 - P ">") ^ 0 * P ">"
+          * P "{"
+        )
+      * K ( 'ParseAgain.noCR' , balanced_braces )
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces )
+      * L ( P "}{" )
+      * K ( 'ParseAgain.noCR' , balanced_braces )
+      * L ( P "}" )
+end
+
+DetectedCommands =
+      Ct ( Cc "Open"
+            * C (
+                  piton.ListCommands
+                  * ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1
+                  * P "{"
+                )
+            * Cc "}"
+         )
+       * ( C ( balanced_braces ) / (function (s) return MainLoopMinimal:match(s) end ) )
+       * P "}" * Ct ( Cc "Close" )
+
+local EOL =
+  P "\r"
+  *
+  (
+    ( space^0 * -1 )
+    +
+    Ct (
+         Cc "EOL"
+         *
+         Ct (
+              Lc "\\__piton_end_line:"
+              * BeamerEndEnvironments
+              * BeamerBeginEnvironments
+              * Lc "\\__piton_newline: \\__piton_begin_line:"
+            )
+       )
+  )
+  *
+  SpaceIndentation ^ 0
+
+local CommentMath =
+  P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$" -- $
+
+local CommentLaTeX =
+  P(piton.comment_latex)
+  * Lc "{\\PitonStyle{Comment.LaTeX}{\\ignorespaces"
+  * L ( ( 1 - P "\r" ) ^ 0 )
+  * Lc "}}"
+  * ( EOL + -1 )
+
+local identifier = letter * alphanum ^ 0
+
+local Identifier = K ( 'Identifier' , identifier )
+
+local MainMinimal =
+       EOL
+     + Space
+     + Tab
+     + Escape + EscapeMath
+     + CommentLaTeX
+     + Beamer
+     + DetectedCommands
+     + Comment
+     + Delim
+     + String
+     + Punct
+     + Identifier
+     + Number
+     + Word
+
+MainLoopMinimal =
+  (  ( space^1 * -1 )
+     + MainMinimal
+  ) ^ 0
+
+languageMinimal =
+  Ct (
+       ( ( space - P "\r" ) ^ 0 * P "\r" ) ^ -1
+       * BeamerBeginEnvironments
+       * Lc '\\__piton_begin_line:'
+       * SpaceIndentation ^ 0
+       * MainLoopMinimal
+       * -1
+       * Lc '\\__piton_end_line:'
+     )
+languages['minimal'] = languageMinimal
+
 function piton.Parse(language,code)
   local t = languages[language] : match ( code )
   if t == nil

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-01-15 21:00:10 UTC (rev 69436)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-01-15 21:00:21 UTC (rev 69437)
@@ -19,8 +19,8 @@
 %% LaTeX version 2005/12/01 or later.
 %% -------------------------------------------
 %% 
-\def\PitonFileVersion{2.3}
-\def\PitonFileDate{2024/01/06}
+\def\PitonFileVersion{2.4}
+\def\PitonFileDate{2024/01/15}
 
 
 \NeedsTeXFormat{LaTeX2e}
@@ -37,6 +37,14 @@
 \cs_new_protected:Npn \__piton_fatal:n { \msg_fatal:nn { piton } }
 \cs_new_protected:Npn \__piton_fatal:nn { \msg_fatal:nnn { piton } }
 \cs_new_protected:Npn \__piton_msg_new:nn { \msg_new:nnn { piton } }
+\cs_new_protected:Npn \__piton_msg_new:nnn { \msg_new:nnnn { piton } }
+\cs_new_protected:Npn \__piton_gredirect_none:n #1
+  {
+    \group_begin:
+    \globaldefs = 1
+    \msg_redirect_name:nnn { piton } { #1 } { none }
+    \group_end:
+  }
 \__piton_msg_new:nn { LuaLaTeX~mandatory }
   {
     LuaLaTeX~is~mandatory.\\
@@ -47,11 +55,17 @@
   }
 \sys_if_engine_luatex:F { \msg_critical:nn { piton } { LuaLaTeX~mandatory } }
 \RequirePackage { luatexbase }
-\__piton_msg_new:nn { piton.lua~not~found }
+\__piton_msg_new:nnn { piton.lua~not~found }
   {
     The~file~'piton.lua'~can't~be~found.\\
-    The~package~'piton'~won't~be~loaded.
+    The~package~'piton'~won't~be~loaded.\\
+    If~you~want~to~know~how~to~retrieve~the~file~'piton.lua',~type~H~<return>.
   }
+  {
+    On~the~site~CTAN,~go~to~the~page~of~'piton':~https://ctan.org/pkg/piton.~
+    The~file~'README.md'~explains~how~to~retrieve~the~files~'piton.sty'~and~
+    'piton.lua'.
+  }
 \file_if_exist:nF { piton.lua }
   { \msg_critical:nn { piton } { piton.lua~not~found } }
 \bool_new:N \g__piton_footnotehyper_bool
@@ -143,13 +157,16 @@
         \bool_gset_true:N \g__piton_footnote_bool
       }
   }
-\lua_now:n { piton = piton~or { } }
-\str_new:N \l__piton_language_str
-\str_set:Nn \l__piton_language_str { python }
+\lua_now:n
+  {
+    piton = piton~or { }
+    piton.ListCommands = lpeg.P ( false )
+  }
+\str_new:N \l_piton_language_str
+\str_set:Nn \l_piton_language_str { python }
 \str_new:N \l__piton_path_str
 \bool_new:N \l__piton_in_PitonOptions_bool
 \bool_new:N \l__piton_in_PitonInputFile_bool
-\bool_new:N \g__piton_in_document_bool
 \int_new:N \l__piton_nb_lines_int
 \int_new:N \l__piton_nb_non_empty_lines_int
 \int_new:N \g__piton_line_int
@@ -467,6 +484,9 @@
   }
 \keys_define:nn { PitonOptions }
   {
+    detected-commands .code:n =  \__piton_detected_commands:n { #1 } ,
+    detected-commands .value_required:n = true ,
+    detected-commands .usage:n = preamble ,
     begin-escape .code:n =
       \lua_now:e { piton.begin_escape = "\lua_escape:n{#1}" } ,
     begin-escape .value_required:n = true ,
@@ -495,7 +515,7 @@
     math-comments .default:n  = true ,
     math-comments .usage:n = preamble ,
     language         .code:n =
-      \str_set:Nx \l__piton_language_str { \str_lowercase:n { #1 } } ,
+      \str_set:Nx \l_piton_language_str { \str_lowercase:n { #1 } } ,
     language         .value_required:n  = true ,
     path             .str_set:N         = \l__piton_path_str ,
     path             .value_required:n  = true ,
@@ -626,8 +646,6 @@
   }
 \NewDocumentCommand \__piton_fake_PitonOptions { }
   { \keys_set:nn { PitonOptions } }
-\hook_gput_code:nnn { begindocument } { . }
-  { \bool_gset_true:N \g__piton_in_document_bool }
 \int_new:N \g__piton_visual_line_int
 \cs_new_protected:Npn \__piton_print_number:
   {
@@ -681,7 +699,7 @@
     \tl_set:Nx \l_tmpa_tl
       {
         \lua_now:e
-          { piton.ParseBis('\l__piton_language_str',token.scan_string()) }
+          { piton.ParseBis('\l_piton_language_str',token.scan_string()) }
           { #1 }
       }
     \bool_if:NTF \l__piton_show_spaces_bool
@@ -703,7 +721,7 @@
     \tl_set:Nx \l_tmpa_tl
       {
         \lua_now:e
-          { piton.Parse('\l__piton_language_str',token.scan_string()) }
+          { piton.Parse('\l_piton_language_str',token.scan_string()) }
           { #1 }
       }
     \bool_if:NT \l__piton_show_spaces_bool
@@ -724,7 +742,7 @@
         \tl_set:Nx \l_tmpa_tl
           {
             \lua_now:e
-              { piton.ParseTer('\l__piton_language_str',token.scan_string()) }
+              { piton.ParseTer('\l_piton_language_str',token.scan_string()) }
               { #1 }
           }
       }
@@ -732,7 +750,7 @@
         \tl_set:Nx \l_tmpa_tl
           {
             \lua_now:e
-              { piton.Parse('\l__piton_language_str',token.scan_string()) }
+              { piton.Parse('\l_piton_language_str',token.scan_string()) }
               { #1 }
           }
       }
@@ -755,7 +773,7 @@
         \tl_set:Nx \l_tmpa_tl
           {
             \lua_now:e
-              { piton.ParseTer('\l__piton_language_str',token.scan_string()) }
+              { piton.ParseTer('\l_piton_language_str',token.scan_string()) }
               { #1 }
           }
       }
@@ -763,7 +781,7 @@
         \tl_set:Nx \l_tmpa_tl
           {
             \lua_now:e
-              { piton.Parse('\l__piton_language_str',token.scan_string()) }
+              { piton.Parse('\l_piton_language_str',token.scan_string()) }
               { #1 }
           }
       }
@@ -871,7 +889,7 @@
               {
                 piton.GobbleParse
                   (
-                    '\l__piton_language_str' ,
+                    '\l_piton_language_str' ,
                     \int_use:N \l__piton_gobble_int ,
                     token.scan_argument()
                   )
@@ -923,10 +941,9 @@
       { \str_set:Nn \l__piton_file_name_str { #3 } }
       {
         \str_set_eq:NN \l__piton_file_name_str \l__piton_path_str
-        \str_put_right:Nn \l__piton_file_name_str { / }
-        \str_put_right:Nn \l__piton_file_name_str { #3 }
+        \str_put_right:Nn \l__piton_file_name_str { / #3 }
       }
-    \exp_args:NV \file_if_exist:nTF \l__piton_file_name_str
+    \file_if_exist:nTF { \l__piton_file_name_str }
       { \__piton_input_file:nn { #1 } { #2 } }
       { \msg_error:nnn { piton } { Unknown~file } { #3 } }
     \group_end:
@@ -993,7 +1010,7 @@
       \lua_now:e
         {
           piton.ParseFile(
-           '\l__piton_language_str' ,
+           '\l_piton_language_str' ,
            '\l__piton_file_name_str' ,
            \int_use:N \l__piton_first_line_int ,
            \int_use:N \l__piton_last_line_int )
@@ -1020,7 +1037,7 @@
   }
 \NewDocumentCommand { \PitonStyle } { m }
   {
-    \cs_if_exist_use:cF { pitonStyle _ \l__piton_language_str  _ #1 }
+    \cs_if_exist_use:cF { pitonStyle _ \l_piton_language_str  _ #1 }
       { \use:c { pitonStyle _ #1 } }
   }
 \NewDocumentCommand { \SetPitonStyle } { O { } m }
@@ -1027,7 +1044,7 @@
   {
     \str_set:Nx \l__piton_SetPitonStyle_option_str { \str_lowercase:n { #1 } }
     \str_if_eq:onT \l__piton_SetPitonStyle_option_str { current-language }
-      { \str_set_eq:NN \l__piton_SetPitonStyle_option_str \l__piton_language_str }
+      { \str_set_eq:NN \l__piton_SetPitonStyle_option_str \l_piton_language_str }
     \keys_set:nn { piton / Styles } { #2 }
     \str_clear:N \l__piton_SetPitonStyle_option_str
   }
@@ -1139,8 +1156,28 @@
     ParseAgain         = \__piton_piton:n ,
   }
 \bool_if:NT \g__piton_math_comments_bool { \SetPitonStyle { Comment.Math } }
+\NewDocumentCommand { \SetPitonIdentifier } { o m m }
+  {
+    \clist_set:Nn \l_tmpa_clist { #2 }
+    \IfNoValueTF { #1 }
+      {
+        \clist_map_inline:Nn \l_tmpa_clist
+          { \cs_set:cpn { pitonIdentifier _ ##1 } { #3 } }
+      }
+      {
+        \str_set:Nx \l_tmpa_str { \str_lowercase:n { #1 } }
+        \str_if_eq:onT \l_tmpa_str { current-language }
+          { \str_set_eq:NN \l_tmpa_str \l_piton_language_str }
+        \clist_map_inline:Nn \l_tmpa_clist
+          { \cs_set:cpn { pitonIdentifier _ \l_tmpa_str _ ##1 } { #3 } }
+      }
+  }
 \cs_new_protected:Npn \__piton_identifier:n #1
-  { \cs_if_exist_use:c { PitonIdentifier _ \l__piton_language_str _ #1 } { #1 } }
+  {
+    \cs_if_exist_use:cF { pitonIdentifier _ \l_piton_language_str _ #1 }
+      { \cs_if_exist_use:c { pitonIdentifier_ #1 } }
+    { #1 }
+  }
 \keys_define:nn { PitonOptions }
   { identifiers .code:n = \__piton_set_identifiers:n { #1 } }
 \keys_define:nn { Piton / identifiers }
@@ -1150,6 +1187,8 @@
   }
 \cs_new_protected:Npn \__piton_set_identifiers:n #1
   {
+    \__piton_error:n { key~identifiers~deprecated }
+    \__piton_gredirect_none:n { key~identifiers~deprecated }
     \clist_clear_new:N \l__piton_identifiers_names_tl
     \tl_clear_new:N \l__piton_style_tl
     \keys_set:nn { Piton / identifiers } { #1 }
@@ -1156,7 +1195,7 @@
     \clist_map_inline:Nn \l__piton_identifiers_names_tl
       {
         \tl_set_eq:cN
-          { PitonIdentifier _ \l__piton_language_str _ ##1 }
+          { PitonIdentifier _ \l_piton_language_str _ ##1 }
           \l__piton_style_tl
       }
   }
@@ -1163,13 +1202,13 @@
 \cs_new_protected:cpn { pitonStyle _ Name.Function.Internal } #1
   {
     { \PitonStyle { Name.Function } { #1 } }
-    \cs_gset_protected:cpn { PitonIdentifier _ \l__piton_language_str _ #1 }
+    \cs_gset_protected:cpn { PitonIdentifier _ \l_piton_language_str _ #1 }
       { \PitonStyle { UserFunction } }
-    \seq_if_exist:cF { g__piton_functions _ \l__piton_language_str _ seq }
-      { \seq_new:c { g__piton_functions _ \l__piton_language_str _ seq } }
-    \seq_gput_right:cn { g__piton_functions _ \l__piton_language_str _ seq } { #1 }
-    \seq_if_in:NVF \g__piton_languages_seq \l__piton_language_str
-      { \seq_gput_left:NV \g__piton_languages_seq \l__piton_language_str }
+    \seq_if_exist:cF { g__piton_functions _ \l_piton_language_str _ seq }
+      { \seq_new:c { g__piton_functions _ \l_piton_language_str _ seq } }
+    \seq_gput_right:cn { g__piton_functions _ \l_piton_language_str _ seq } { #1 }
+    \seq_if_in:NVF \g__piton_languages_seq \l_piton_language_str
+      { \seq_gput_left:NV \g__piton_languages_seq \l_piton_language_str }
   }
 \NewDocumentCommand \PitonClearUserFunctions { ! o }
   {
@@ -1215,6 +1254,13 @@
     \token_to_str:N \piton\ but~there~is~no~environment~
     {piton}.~This~error~is~fatal.
   }
+\__piton_msg_new:nn { key~identifiers~deprecated }
+  {
+    The~key~'identifiers'~in~the~command~\token_to_str:N PitonOptions\
+    is~now~deprecated:~you~should~use~the~command~
+    \token_to_str:N \SetPitonIdentifier\ instead.\\
+    However,~you~can~go~on.
+  }
 \__piton_msg_new:nn { Unknown~key~for~SetPitonStyle }
   {
     The~style~'\l_keys_key_str'~is~unknown.\\
@@ -1255,7 +1301,7 @@
   }
 \__piton_msg_new:nn { syntax~error }
   {
-    Your~code~\l__piton_language_str\ is~not~syntactically~correct.\\
+    Your~code~\l_piton_language_str\ is~not~syntactically~correct.\\
     It~won't~be~printed~in~the~PDF~file.
   }
 \NewDocumentCommand \PitonSyntaxError { }
@@ -1301,11 +1347,11 @@
     break-lines-in-Piton,~
     continuation-symbol,~
     continuation-symbol-on-indentation,~
+    detected-commands,~
     end-of-broken-line,~
     end-range,~
     env-gobble,~
     gobble,~
-    identifiers,~
     indent-broken-lines,~
     language,~
     left-margin,~
@@ -1343,10 +1389,25 @@
     in~Beamer.\\
     If~you~go~on,~that~argument~will~be~ignored.
   }
-\__piton_msg_new:nn { Python~error }
-  { A~Python~error~has~been~detected. }
 \hook_gput_code:nnn { begindocument } { . }
   { \lua_now:e { require("piton.lua") } }
+\cs_new_protected:Npn \__piton_detected_commands:n #1
+  { \lua_now:n { piton.addListCommands('#1') } }
+\ExplSyntaxOff
+\directlua
+  {
+    lpeg.locale(lpeg)
+    local P , alpha , C , Cf, space = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space
+    local One_P = space ^ 0
+                  * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end )
+                  * space ^ 0
+    function piton.addListCommands( key_value )
+       piton.ListCommands =
+         piton.ListCommands +
+           Cf ( One_P * ( P "," * One_P ) ^ 0  ,
+                ( function (s,t) return s + t end ) ) : match ( key_value )
+    end
+  }
 
 \endinput
 %%



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