From 286abb7dcd6c03d7edcd3d3435bb97448074c3cf Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Thu, 22 Feb 2024 03:04:08 +0000
Subject: CTAN sync 202402220303

---
 macros/latex/contrib/listings/listings.dtx | 376 ++++++++++++++++++-----------
 1 file changed, 236 insertions(+), 140 deletions(-)

(limited to 'macros/latex/contrib/listings/listings.dtx')

diff --git a/macros/latex/contrib/listings/listings.dtx b/macros/latex/contrib/listings/listings.dtx
index c507ab5fc1..c336295db5 100644
--- a/macros/latex/contrib/listings/listings.dtx
+++ b/macros/latex/contrib/listings/listings.dtx
@@ -40,10 +40,12 @@
 \DisableCrossrefs
 \OnlyDescription
 
-\usepackage{lstdoc,textcomp}
+\usepackage{lstdoc}             % the basic support package for generating
+                                % the documentation of this package
+\usepackage{textcomp}           % needed for upquote apostrophes
 \usepackage{mdframed}           % frames for external files
 \usepackage{moreverb}           % writing external files
-\usepackage{xcolor}             % because of colouring the background
+\usepackage{xcolor}             % because of coloring the background
 
 \makeindex
 
@@ -115,7 +117,7 @@
 %^^A =============================================
 %^^A
 %\newbox\abstractbox
-%\setbox\abstractbox=\vbox{
+%\setbox\abstractbox=\vbox{%
 %	\begin{abstract}
 %	The \packagename{listings} package is a source code printer for \LaTeX.
 %	You can typeset stand alone files as well as listings with an environment
@@ -125,7 +127,7 @@
 %   language isn't already supported, you can make your own definition.
 %	\end{abstract}}
 %
-% \title{\vspace*{-2\baselineskip}The \textsf{Listings} Package}
+% \title{\vspace*{-2\baselineskip}The \packagename{Listings} Package}
 % \author{Copyright 1996--2004, Carsten Heinz%
 %    \\ Copyright 2006--2007, Brooks Moses
 %    \\ Copyright 2013--, Jobst Hoffmann
@@ -133,7 +135,7 @@
 %       Hoffmann became the maintainer of the \packagename{listings}
 %       package in 2013; see the Preface for details.}~ %
 %    \textless\lstemail\textgreater}
-% \date{2023/02/27\enspace\enspace Version 1.9\ \box\abstractbox}
+% \date{2024/02/21\enspace\enspace Version 1.10\ \box\abstractbox}
 % \def\lstemail{\href{mailto:j.hoffmann@fh-aachen.de}{\texttt{j.hoffmann(at)fh-aachen.de}}}
 % \ifhyper
 %   \hypersetup{pdftitle=The Listings Package,
@@ -2628,9 +2630,10 @@
 %   \item[1.1,false]
 %     \rkeyname{upquote}|=|\meta{\alternative{true,false}}\label{uoption:upquote}
 %
-%     determines whether the left and right quote are printed |`'| or
-%     \texttt{\textasciigrave\textquotesingle}.  This key requires the
-%     \packagename{textcomp} package if true.
+%     determines whether the left and right quote are printed |`'| (false) or
+%     \texttt{\textasciigrave\textquotesingle} (true).  This key requires the
+%     \packagename{textcomp} package if true, for more information have a
+%     look at page \pageref{sec:upquote}.
 %
 %   \item[0.12,8] \rkeyname{tabsize}|=|\meta{number}
 %
@@ -2790,8 +2793,12 @@
 % \item[0.16] \rcmdname\lstlistoflistings
 %
 %       prints a list of listings. Each entry is with descending priority
-%       either the short caption, the caption, the file name or the name of the
-%       listing, see also the key \keyname{name} in section \ref{rLineNumbers}.
+%       either the short caption, the caption, the file name, or the name of
+%       the listing, see also the key \keyname{name} in section
+%       \ref{rLineNumbers}. From version v1.10 of this package on the list of
+%       listings can be prepared by means of the \packagename{tocbasic} package
+%       \cite[Chapter 15]{Kohm:scrguide}, for more information have a look at
+%       page \pageref{sec:tocbasic}.
 %
 % \item[1.0] \rkeyname{nolol}|=|\meta{\alternative{true,false}}\syntaxor\rkeyname{nolol}
 %
@@ -2811,7 +2818,7 @@
 %       simple way, something like |\small|, |\bfseries| or a combination
 %       of several commands. If there is a need for a complete
 %       customization of the label (justification, fonts, margins, \ldots),
-%       one should use the \textsf{caption} package by A.~Sommerfeldt
+%       one should use the \packagename{caption} package by A.~Sommerfeldt
 %       \cite{Sommerfeldt:caption}.
 %
 % \item[0.20,\arabic{lstlisting},data] \rcmdname\thelstlisting
@@ -3259,7 +3266,7 @@
 % Expand that list yourself and mail me about new items.
 %
 %
-% \subsection{Interface to \textsf{fancyvrb}}
+% \subsection{Interface to \packagename{fancyvrb}}
 %
 % The \packagename{fancyvrb} package---fancy verbatims---from Timothy van Zandt
 % provides macros for reading, writing and typesetting verbatim code. It has
@@ -3924,7 +3931,7 @@
 % \end{TODO}
 %
 %
-% \subsection{\textsf{LGrind} definitions}\label{rLGrindDefinitions}
+% \subsection{\packagename{LGrind} definitions}\label{rLGrindDefinitions}
 %
 % Yes, it's a nasty idea to steal language definitions from other programs.
 % Nevertheless, it's possible for the \packagename{LGrind} definition
@@ -4487,28 +4494,69 @@
 %    make pdf-devel\end{verbatim}
 % gives the same result---it is called \texttt{listings-devel.pdf}.
 %
+%
+% \subsubsection*{How to copy and paste from a document}
+% \label{sec:upquote}
+% If you want to provide a document containing listings formatted by this
+% package (\packagename{listings}) as source for copy and paste, you should
+% be sure to set the key |upquote| to |true| and have
+% |\usepackage{textcomp}| in the preamble of the document. Otherwise the
+% pair |`'| of curly quotation marks is associated with Unicode positions
+% U+2018 and U+2019 \cite{CovingtonMittelbachKuhn:upquote}. These
+% characters are seldom used as delimiters in modern programming languages.
+%
+%
+% \subsubsection*{How to change the layout of the list of listings}
+% \label{sec:tocbasic}
+% If you put the command |\lstlistoflistings| into your document, the list
+% of listings is automatically generated and printed at that point. If you
+% are using the standard \LaTeX{} classes the list is prepared by
+% |\addtocontents| commands or a variation, if you also load the package
+% \packagename{float}. In both cases the layout is the one defined by
+% L. Lamport.
+%
+% If you want to change the layout of this list, you can use the package
+% \packagename{tocbasic} as described in \cite[Chapter
+% 15.3]{Kohm:scrguide}. \packagename{tocbasic} is automatically loaded, if
+% you are using one of the KOMA classes.
+%
+%
 % \makeatletter
 %^^A \def\index@prologue{\section*{Index}\markboth{Index}{Index}}
 % \def\index@prologue{\part{Index}\markboth{Index}{Index}}
 % \makeatother
 %^^A \StopEventually{\lstcheckreference\setcounter{IndexColumns}{2}\PrintIndex}
 % \StopEventually{%
+% \nocite{MF23}
 % \begin{thebibliography}{MDB01}
 %
+%     \bibitem[CMK12]{CovingtonMittelbachKuhn:upquote}
+%       Michael A. Covington, Frank Mittelbach and Markus G. Kuhn.
+%       \newblock{\packagename{upquote} -- upright-quote and grave-accent glyphs
+%       in verbatim}, 2012.
+%
 %     \bibitem[DS13]{DanielSchubert:mdframed}
 %       Marco Daniel and Elke Schubert.
-%       \newblock{The \textsf{mdframed} package}, 2013.
+%       \newblock{The \packagename{mdframed} package}, 2013.
 %
 %     \bibitem[Fai11]{Fairbairns:moreverb}
 %       Robin Fairbairns.
-%       \newblock{The \textsf{moreverb} package}, 2011.
+%       \newblock{The \packagename{moreverb} package}, 2011.
+%
+%     \bibitem[Koh23]{Kohm:scrguide}
+%       Markus Kohm.
+%       \newblock{KOMA-Script -- The Guide}, 2023.
+%
+%     \bibitem[MF23]{MittelbachFischer:companion}
+%       Frank Mittelbach and Ulrike Fischer.
+%       \newblock{The \LaTeX-Companion} Part I and II, 2023.
 %
 %     \bibitem[Mi04]{Mittelbach:companion}
 %       Frank Mittelbach, Michel Goossens, Johannes Braams,
 %                  David P. Carlisle, and Chris Rowley.
 %       \newblock{The \LaTeX-Companion}, 2004.
 %
-%     \bibitem[Som11]{Sommerfeldt:captions}
+%     \bibitem[Som11]{Sommerfeldt:caption}
 %       Axel Sommerfeldt.
 %       \newblock{Customizing captions of floating environments}, 2011.
 % \end{thebibliography}
@@ -5930,7 +5978,7 @@
 % \part{Implementation}
 %
 %
-% \CheckSum{12388}
+% \CheckSum{12409}
 %^^A
 %^^A Don't index TeX-primitives.
 %^^A
@@ -6074,8 +6122,8 @@
 % All files will have same date and version.
 %    \begin{macrocode}
 %<*kernel|misc|doc>
-\def\filedate{2023/02/27}
-\def\fileversion{1.9}
+\def\filedate{2024/02/21}
+\def\fileversion{1.10}
 %</kernel|misc|doc>
 %    \end{macrocode}
 % What we need and who we are.
@@ -6102,13 +6150,13 @@
 %<*misc>
 \ProvidesFile{lstmisc.sty}
              [\filedate\space\fileversion\space(Carsten Heinz)]
-\lst@CheckVersion\fileversion
+\lst@CheckVersion\fileversion%
     {\typeout{^^J%
      ***^^J%
      *** This file requires `listings.sty' version \fileversion.^^J%
-     *** You have a serious problem, so I'm exiting ...^^J%
+     *** You have a serious problem, so I'm exiting...^^J%
      ***^^J}%
-     \batchmode \@@end}
+     \batchmode\@@end}
 %</misc>
 %    \end{macrocode}
 % or by the dummy patch.
@@ -7205,7 +7253,7 @@
 % \end{macro}
 %
 %
-% \subsection{Interfacing with \textsf{keyval}}
+% \subsection{Interfacing with \packagename{keyval}}
 %
 % The \packagename{keyval} package passes the value via the one and only
 % paramater |#1| to the definition part of the key macro. The following
@@ -8155,7 +8203,7 @@
 % \begin{macro}{\lst@DoNewLines}
 % First we take care of |\lst@maxempty| and then of the remaining empty lines.
 %    \begin{macrocode}
-\def\lst@DoNewLines{
+\def\lst@DoNewLines{%
     \@whilenum\lst@newlines>\lst@maxempty \do
         {\lst@ifpreservenumber
             \lsthk@OnEmptyLine
@@ -8885,6 +8933,7 @@
     \lst@ProcessOther {"5C}{\lst@ttfamily{\char92}\textbackslash}
     \lst@ProcessOther {"5E}\textasciicircum
     \lst@ProcessLetter{"5F}{\lst@ttfamily{\char95}\textunderscore}
+                                     % or \char"5F
     \lst@ProcessOther {"60}{\lst@ifupquote \textasciigrave
                                      \else \char96\relax \fi}
     \lst@ProcessOther {"7B}{\lst@ttfamily{\char123}\textbraceleft}
@@ -10622,7 +10671,7 @@
 % Same as |\lst@CDefX| but we both make |#1| active and assign a new catcode.
 %    \begin{macrocode}
 \gdef\lst@ActiveCDefX#1{\lst@ActiveCDefX@#1}
-\gdef\lst@ActiveCDefX@#1#2#3{
+\gdef\lst@ActiveCDefX@#1#2#3{%
     \catcode`#1\active\lccode`\~=`#1%
     \lowercase{\lst@CDefIt~}{#2}{#3}{}}
 %    \end{macrocode}
@@ -13226,7 +13275,7 @@
 % of background color to the left of the margin is now drawn before the left
 % side of the frame is drawn, so that they overlap correctly in Acrobat.
 %
-% \begin{macro}{\lst@frameMakeVBox}
+% \begin{macro}{\lst@frameMakeBoxV}
 %    \begin{macrocode}
 \gdef\lst@frameMakeBoxV#1#2#3{%
     \setbox#1\hbox{%
@@ -13711,6 +13760,7 @@
 %
 %
 % \section{Typesetting a listing}
+% \label{sec:typesetting-listing}
 %
 % \begingroup
 %    \begin{macrocode}
@@ -13743,7 +13793,22 @@
 % \end{lstkey}
 % \end{lstkey}
 % \end{lstkey}
+%
+% \begin{lstkey}{nolol}
+%     is just another key with an obvious meaning here. We'll use it below,
+%     of course.
+%    \begin{macrocode}
+\lst@Key{nolol}{false}[t]{\lstKV@SetIf{#1}\lst@ifnolol}
+\def\lst@nololtrue{\let\lst@ifnolol\iftrue}
+\let\lst@ifnolol\iffalse % init
+%    \end{macrocode}
+% \end{lstkey}
 % \end{macro}
+%
+%
+% \subsection{Dealing with lineranges}
+% \label{sec:lineranges}
+%
 % The following code is just copied from the current development version, and
 % from the |lstpatch.sty| file that Carsten left in version 1.3b for doing
 % line ranges with numbers and range markers. It uses some more keys:
@@ -13794,7 +13859,7 @@
 %    \end{macrocode}
 % Splitting the comma separated list of pairs is done by
 %    \begin{macrocode}
-\def\lst@GLI#1,#2\@nil{%
+\def\lst@GLI#1,#2\@nil{% GLI: get line interval
 %    \end{macrocode}
 % The list is split into two parts: the first element (\#1) of the list and
 % the rest of the list (\#2) which is stored in |\lst@linerange| to be
@@ -13911,21 +13976,23 @@
 %    \begin{macrocode}
 \def\lst@DefRangeB#1#2{\lst@DefRangeB@#1#2}
 \def\lst@DefRangeB@#1#2#3#4{%
-    \lst@CDef{#1{#2}{#3}}#4{}%
-    {\lst@ifincluderangemarker
-         \lst@LeaveMode
-         \let#1#4%
-         \lst@DefRangeEnd
-         \lst@InitLstNumber
-     \else
-         \@tempcnta\lst@lineno \advance\@tempcnta\@ne
-         \edef\lst@firstline{\the\@tempcnta\relax}%
-         \gdef\lst@OnceAtEOL{\let#1#4\lst@DefRangeEnd}%
-         \lst@InitLstNumber
-     \fi
-	 \global\let\lst@DefRange\lst@DefRangeEnd
-     \lst@CArgEmpty}%
-    \@empty}
+  \lst@CDef{#1{#2}{#3}}#4{}{%
+    \lst@ifincluderangemarker
+        \lst@LeaveMode
+        \let#1#4%
+        \lst@DefRangeEnd
+        \lst@InitLstNumber
+    \else
+        \@tempcnta\lst@lineno \advance\@tempcnta\@ne
+        \edef\lst@firstline{\the\@tempcnta\relax}%
+        \gdef\lst@OnceAtEOL{\let#1#4\lst@DefRangeEnd}%
+        \lst@InitLstNumber
+    \fi
+    \global\let\lst@DefRange\lst@DefRangeEnd
+    \lst@CArgEmpty%
+  }%
+  \@empty%
+}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -13935,33 +14002,34 @@
 % feature does not work with firstnumber}.
 %    \begin{macrocode}
 \def\lstpatch@labels{%
-\gdef\lst@SetFirstNumber{%
+  \gdef\lst@SetFirstNumber{%
     \ifx\lst@firstnumber\@undefined
         \@tempcnta 0\csname\@lst no@\lst@intname\endcsname\relax
         \ifnum\@tempcnta=\z@ \else
             \lst@nololtrue
             \advance\@tempcnta\lst@advancenumber
             \edef\lst@firstnumber{\the\@tempcnta\relax}%
-        \fi
-    \fi}%
+        \fi%
+    \fi%
+  }%
 }
 \def\lst@InitLstNumber{%
-     \global\c@lstnumber\lst@firstnumber
-     \global\advance\c@lstnumber\lst@advancenumber
-     \global\advance\c@lstnumber-\lst@advancelstnum
-     \ifx \lst@firstnumber\c@lstnumber
-         \global\advance\c@lstnumber-\lst@advancelstnum
-     \fi%
+  \global\c@lstnumber\lst@firstnumber
+  \global\advance\c@lstnumber\lst@advancenumber
+  \global\advance\c@lstnumber-\lst@advancelstnum
+  \ifx \lst@firstnumber\c@lstnumber
+      \global\advance\c@lstnumber-\lst@advancelstnum
+  \fi%
 %    \end{macrocode}
 % \lsthelper{Byron~K.~Boulton}{2013/11/21}{line numbers off by one}
 % reported, that the line numbers are off by one, if they are displayed when
 % a linerange is given by patterns and |includerangemarker=false| is
 % set. Adding this test corrects this behaviour.
 %    \begin{macrocode}
-     \lst@ifincluderangemarker\else%
-         \global\advance\c@lstnumber by 1%
-     \fi%
-     }
+  \lst@ifincluderangemarker\else%
+    \global\advance\c@lstnumber by 1%
+  \fi%
+}
 %    \end{macrocode}
 %
 %    The end-marker is defined if and only if it's not empty. The definition is
@@ -13970,28 +14038,28 @@
 %    version of |\lst@MProcessListing| above.
 %    \begin{macrocode}
 \def\lst@DefRangeEnd{%
-    \ifx\lst@rangeend\@empty\else
-        \expandafter\lst@CArgX\lst@rangeend\relax\lst@DefRangeE
-    \fi}
+  \ifx\lst@rangeend\@empty\else
+      \expandafter\lst@CArgX\lst@rangeend\relax\lst@DefRangeE
+  \fi}
 \def\lst@DefRangeE#1#2{\lst@DefRangeE@#1#2}
 \def\lst@DefRangeE@#1#2#3#4{%
-    \lst@CDef{#1#2{#3}}#4{}%
-    {\let#1#4%
-     \edef\lst@lastline{\the\lst@lineno\relax}%
-     \lst@DefRangeE@@}%
-    \@empty}
+  \lst@CDef{#1#2{#3}}#4{}%
+  {\let#1#4%
+    \edef\lst@lastline{\the\lst@lineno\relax}%
+    \lst@DefRangeE@@}%
+  \@empty}
 \def\lst@DefRangeE@@#1\@empty{%
-    \lst@ifincluderangemarker
-        #1\lst@XPrintToken
-    \fi
-    \lst@LeaveModeToPmode
-    \lst@BeginDropInput{\lst@Pmode}}
+  \lst@ifincluderangemarker
+    #1\lst@XPrintToken
+  \fi
+  \lst@LeaveModeToPmode
+  \lst@BeginDropInput{\lst@Pmode}}
 \def\lst@LeaveModeToPmode{%
-    \ifnum\lst@mode=\lst@Pmode
-        \expandafter\lsthk@EndGroup
-    \else
-        \expandafter\egroup\expandafter\lst@LeaveModeToPmode
-    \fi}
+  \ifnum\lst@mode=\lst@Pmode
+      \expandafter\lsthk@EndGroup
+  \else
+      \expandafter\egroup\expandafter\lst@LeaveModeToPmode
+  \fi}
 %    \end{macrocode}
 %
 % Sometimes it is good to have two or more excerpts of one program numbered
@@ -14056,15 +14124,6 @@
     \fi\fi}
 %    \end{macrocode}
 %
-% \begin{lstkey}{nolol}
-% is just a key here. We'll use it below, of course.
-%    \begin{macrocode}
-\lst@Key{nolol}{false}[t]{\lstKV@SetIf{#1}\lst@ifnolol}
-\def\lst@nololtrue{\let\lst@ifnolol\iftrue}
-\let\lst@ifnolol\iffalse % init
-%    \end{macrocode}
-% \end{lstkey}
-%
 %
 % \subsection{Floats, boxes and captions}
 %
@@ -14114,7 +14173,7 @@
 % the counter should be reset at each chapter before the counter is defined,
 % using the |numberbychapter| key.
 %    \begin{macrocode}
-\AtBeginDocument{
+\AtBeginDocument{%
   \@ifundefined{thechapter}{\let\lst@ifnumberbychapter\iffalse}{}
   \lst@ifnumberbychapter
       \newcounter{lstlisting}[chapter]
@@ -14182,6 +14241,13 @@
     \ifx\lst@@caption\@empty\else~\thelstlisting\fi}%
 }
 %    \end{macrocode}
+% Hardcoding the extension makes it hard to use a different one, e.g., for the
+% appendix. \lsthelper{Markus Kohm}{2023/09/05}{extended listings also
+% actively supporting tocbasic} suggested to define and use |\ext@lstlisting|
+% instead.
+%    \begin{macrocode}
+\def\ext@lstlisting{lol}
+%    \end{macrocode}
 % Captions are set only for display style listings -- thanks to
 % \lsthelper{Peter~L\"offler}{2004/04/24}{pdfTeX warning (dest): name{figure.1}
 % has been referenced but does not exist} for reporting the bug and to
@@ -14215,11 +14281,11 @@
                 \ifx\lst@caption\@empty
                     \ifx\lst@intname\@empty \else \def\lst@temp{ }%
                     \ifx\lst@intname\lst@temp \else
-                        \addcontentsline{lol}{lstlisting}\lst@name
+                        \addcontentsline{\ext@lstlisting}{lstlisting}\lst@name
                     \fi\fi
                 \fi
             \else
-                \addcontentsline{lol}{lstlisting}%
+                \addcontentsline{\ext@lstlisting}{lstlisting}%
                     {\protect\numberline{\thelstlisting}\lst@@caption}%
             \fi
         \fi
@@ -14269,8 +14335,10 @@
 % Axel proposed the first definition. The other two are default definitions.
 % They may be adjusted to make \packagename{listings} compatible with other
 % packages and classes.
+% Markus proposed to also define |\@captype|, so his
+% |\raggedlstlistingcaption| could be used.
 %    \begin{macrocode}
-\def\lst@makecaption{\@makecaption}
+\def\lst@makecaption{\def\@captype{lstlisting}\@makecaption}
 \def\lst@maketitle{\@makecaption\lst@title@dropdelim}
 \def\lst@title@dropdelim#1{\ignorespaces}
 %    \end{macrocode}
@@ -14599,20 +14667,20 @@
 % interval to input or not.
 %    \begin{macrocode}
 \def\lst@MProcessListing{%
-    \lst@XPrintToken \lst@EOLUpdate \lsthk@InitVarsBOL
-    \global\advance\lst@lineno\@ne
-    \ifnum \lst@lineno>\lst@lastline
-        \lst@ifdropinput \lst@LeaveMode \fi
-        \ifx\lst@linerange\@empty
-            \expandafter\expandafter\expandafter\lst@EndProcessListing
-        \else
-            \lst@interrange
-            \lst@GetLineInterval
-            \expandafter\expandafter\expandafter\lst@SkipToFirst
-        \fi
-    \else
-        \expandafter\lst@BOLGobble
-    \fi}
+  \lst@XPrintToken \lst@EOLUpdate \lsthk@InitVarsBOL
+  \global\advance\lst@lineno\@ne
+  \ifnum \lst@lineno>\lst@lastline
+      \lst@ifdropinput \lst@LeaveMode \fi
+      \ifx\lst@linerange\@empty
+          \expandafter\expandafter\expandafter\lst@EndProcessListing
+      \else
+          \lst@interrange
+          \lst@GetLineInterval
+          \expandafter\expandafter\expandafter\lst@SkipToFirst
+      \fi
+  \else
+      \expandafter\lst@BOLGobble
+  \fi}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -14745,16 +14813,18 @@
 %    \begin{macrocode}
 \lst@UserCommand\lstlistoflistings{\bgroup
     \let\contentsname\lstlistlistingname
-    \let\lst@temp\@starttoc \def\@starttoc##1{\lst@temp{lol}}%
+    \let\lst@temp\@starttoc
+    \def\@starttoc##1{\lst@temp{\ext@lstlisting}}%
     \tableofcontents \egroup}
 %    \end{macrocode}
-% For KOMA-script classes, we define it a la KOMA thanks to a bug report by
+% For \packagename{KOMA}-script classes, we define it a la \packagename{KOMA}
+% thanks to a bug report by
 % \lsthelper{Tino~Langer}{2003/11/01}{koma-script's listsleft option does not
 % affect lol}.  \lsthelper{Markus~Kohm}{2006/08/12}{koma-script support is
 % broken} suggested a much-improved version of this, which also works with
 % the \packagename{float} package.  The following few comments are from Markus.
 %
-% Make use of |\float@listhead| if defined (e.g. using float or KOMA-Script)
+% Make use of |\float@listhead| if defined (e.g. using float)
 %    \begin{macrocode}
 \@ifundefined{float@listhead}{}{%
   \renewcommand*{\lstlistoflistings}{%
@@ -14775,7 +14845,7 @@
 % needed), |\parfillskip| to 0pt plus 1fil (should be!).
 %    \begin{macrocode}
       \parskip\z@\parindent\z@\parfillskip \z@ \@plus 1fil%
-      \@starttoc{lol}%
+      \@starttoc{\ext@lstlisting}%
 %    \end{macrocode}
 % Switch back to twocolumn (see above).
 %    \begin{macrocode}
@@ -14786,6 +14856,16 @@
   }%
 }
 %    \end{macrocode}
+% Make use of package tocbasic if loaded:
+%    \begin{macrocode}
+\AtBeginDocument{%
+  \@ifpackageloaded{tocbasic}{%
+    \addtotoclist[float]{\ext@lstlisting}%
+    \renewcommand*{\lstlistoflistings}{\listoftoc[{\lstlistlistingname}]{lol}}%
+    \DeclareTOCStyleEntry[level=1,numwidth=2.3em,indent=1.5em]{default}{lstlisting}%
+  }{}%
+}
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\float@addtolists}
@@ -14804,12 +14884,15 @@
 % to Markus for the advice.
 %    \begin{macrocode}
 \AtBeginDocument{%
-  \@ifundefined{float@addtolists}%
-    {\gdef\float@addtolists#1{\addtocontents{lol}{#1}}}%
-    {\let\orig@float@addtolists\float@addtolists
-     \gdef\float@addtolists#1{%
-       \addtocontents{lol}{#1}%
-       \orig@float@addtolists{#1}}}%
+  \@ifundefined{KOMAClassName}{%
+    \@ifundefined{float@addtolists}{%
+      \gdef\float@addtolists#1{\addtocontents{\ext@lstlisting}{#1}}%
+    }{%
+      \let\orig@float@addtolists\float@addtolists
+      \gdef\float@addtolists#1{%
+        \addtocontents{\ext@lstlisting}{#1}%
+        \orig@float@addtolists{#1}}}%
+  }{}%
 }%
 %    \end{macrocode}
 % \end{macro}
@@ -14851,16 +14934,16 @@
 % \ref{uListingsArguments} on \pageref{uListingsArguments} and proposed
 % another solution which in turn broke the code needed by Luc:
 %\begin{verbatim}
-% % \renewcommand\lstinline[1][]{%
-% %   \leavevmode\bgroup % \hbox\bgroup --> \bgroup
-% %   \def\lst@boxpos{b}%
-% %   \lsthk@PreSet\lstset{flexiblecolumns,#1}%
-% %   \lsthk@TextStyle
-% %   \ifnum\iffalse{\fi`}=\z@\fi
-% %   \@ifnextchar\bgroup{%
-% %     \ifnum`{=\z@}\fi%
-% %     \afterassignment\lst@InlineG \let\@let@token}{%
-% %     \ifnum`{=\z@}\fi\lstinline@}}
+% \renewcommand\lstinline[1][]{%
+%   \leavevmode\bgroup % \hbox\bgroup --> \bgroup
+%   \def\lst@boxpos{b}%
+%   \lsthk@PreSet\lstset{flexiblecolumns,#1}%
+%   \lsthk@TextStyle
+%   \ifnum\iffalse{\fi`}=\z@\fi
+%   \@ifnextchar\bgroup{%
+%     \ifnum`{=\z@}\fi%
+%     \afterassignment\lst@InlineG \let\@let@token}{%
+%     \ifnum`{=\z@}\fi\lstinline@}}
 %\end{verbatim}
 % So finally the old code comes back and the people, who need a
 % |\lstinline| with braces, should use the workaround from section
@@ -15449,23 +15532,24 @@
 % This is a derivation of \LaTeX's |\@xargdef|. We expand the submacro's name,
 % use |\gdef| instead of |\def|, and hard code a kind of |\@protected@testopt|.
 %    \begin{macrocode}
-\def\lstenv@xargdef#1{
-    \expandafter\lstenv@xargdef@\csname\string#1\endcsname#1}
+\def\lstenv@xargdef#1{%
+  \expandafter\lstenv@xargdef@\csname\string#1\endcsname#1}
 \def\lstenv@xargdef@#1#2[#3][#4]#5{%
   \@ifdefinable#2{%
-       \gdef#2{%
-          \ifx\protect\@typeset@protect
-            \expandafter\lstenv@testopt
-          \else
-            \@x@protect#2%
-          \fi
-          #1%
-          {#4}}%
-       \@yargdef
-          #1%
-           \tw@
-           {#3}%
-           {#5}}}
+    \gdef#2{%
+      \ifx\protect\@typeset@protect
+          \expandafter\lstenv@testopt
+      \else
+          \@x@protect#2%
+      \fi
+      #1%
+      {#4}}%
+    \@yargdef%
+    #1%
+    \tw@%
+    {#3}%
+    {#5}}%
+}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -15763,7 +15847,7 @@
 % \end{macro}
 %
 %
-% \subsection{Extensions to \textsf{doc}}
+% \subsection{Extensions to \packagename{doc}}
 %
 % \begin{macro}{\m@cro@}
 % We need a slight modification of \packagename{doc}'s internal macro.
@@ -16453,7 +16537,7 @@
 % \end{aspect}
 %
 %
-% \subsection{\textsf{fancyvrb}}
+% \subsection{\packagename{fancyvrb}}
 %
 % \lsthelper{Denis~Girou}{1998/07/26}{fancyvrb} asked whether
 % \packagename{fancyvrb} and \packagename{listings} could work together.
@@ -16711,7 +16795,7 @@
 % \endgroup
 %
 %
-% \subsection{\textsf{LGrind}}
+% \subsection{\packagename{LGrind}}
 %
 % \begin{aspect}{lgrind}
 % \begin{macro}{\lst@LGGetNames}
@@ -16969,7 +17053,7 @@
 % \end{aspect}
 %
 %
-% \subsection{\textsf{hyperref}}
+% \subsection{\packagename{hyperref}}
 %
 % \begin{aspect}{hyper}
 %    \begin{macrocode}
@@ -17074,10 +17158,10 @@
 % is wrong. So we reset the catcodes to the correct values before loading
 % the files:
 %    \begin{macrocode}
+%<info>\lst@ReportAllocs
 \lst@RestoreCatcodes%
 \InputIfFileExists{listings.cfg}{}{}
 \InputIfFileExists{lstlocal.cfg}{}{}
-%<info>\lst@ReportAllocs
 %    \end{macrocode}
 %    \begin{macrocode}
 %</kernel>
@@ -17204,10 +17288,22 @@
 %   \item the configuration files |listings.cfg| and |lstlocal.cfg| are read
 %     with the correct catcode
 %   \item some documentation and layout enhancements.
+% \item[1.10] from 2024/02/15 on
+%   \item usage of |tocbasic| if loaded to improve compatibility with
+%   KOMA-Script and also enhance functionality.
 % \end{itemize}
 % \endgroup
 %
 %
 % \Finale
 %
+%    \begin{macrocode}
+%<*dev/null>
+%    \end{macrocode}
+%%% Local Variables:
+%%% ispell-local-dictionary: "english"
+%%% End:
+%    \begin{macrocode}
+%<*dev/null>
+%    \end{macrocode}
 \endinput
-- 
cgit v1.2.3

