diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3file.dtx | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx index 8a5ab688d68..4dfb03bd13c 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx @@ -37,7 +37,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3file.dtx 5714 2015-07-30 00:51:47Z bruno $ +\GetIdInfo$Id: l3file.dtx 5786 2015-08-05 16:18:39Z bruno $ {L3 File and I/O operations} %</driver|package> %<*driver> @@ -136,7 +136,7 @@ % files. The assignment is local. % The \meta{path} is processed in the same way as a \meta{file name}, % \emph{i.e.}, with \texttt{x}-type expansion except active -% characters. Spaces are not allowed in the \meta{path}. +% characters. % \end{function} % % \begin{function}[updated = 2012-07-04]{\file_path_remove:n} @@ -147,7 +147,7 @@ % files. The assignment is local. % The \meta{path} is processed in the same way as a \meta{file name}, % \emph{i.e.}, with \texttt{x}-type expansion except active -% characters. Spaces are not allowed in the \meta{path}. +% characters. % \end{function} % % \begin{function}{\file_list:} @@ -234,7 +234,7 @@ % to other programmers. % \end{function} % -% \begin{function}[updated = 2012-09-09]{\ior_list_streams:, \iow_list_streams:} +% \begin{function}[updated = 2015-08-01]{\ior_list_streams:, \iow_list_streams:} % \begin{syntax} % \cs{ior_list_streams:} % \cs{iow_list_streams:} @@ -414,7 +414,7 @@ % % \subsection{Wrapping lines in output} % -% \begin{function}[added = 2012-06-28]{\iow_wrap:nnnN} +% \begin{function}[added = 2012-06-28, updated = 2015-08-05]{\iow_wrap:nnnN} % \begin{syntax} % \cs{iow_wrap:nnnN} \Arg{text} \Arg{run-on text} \Arg{set up} \meta{function} % \end{syntax} @@ -422,9 +422,11 @@ % characters per line. At the start of each line which is wrapped, % the \meta{run-on text} will be inserted. The line character count % targeted will be the value of \cs{l_iow_line_count_int} minus the -% number of characters in the \meta{run-on text}. The \meta{text} and -% \meta{run-on text} are exhaustively expanded by the function, with the -% following substitutions: +% number of characters in the \meta{run-on text} for all lines except +% the first, for which the target number of characters is simply +% \cs{l_iow_line_count_int} since there is no run-on text. The +% \meta{text} and \meta{run-on text} are exhaustively expanded by the +% function, with the following substitutions: % \begin{itemize} % \item |\\| may be used to force a new line, % \item \verb*|\ | may be used to represent a forced space @@ -1124,20 +1126,20 @@ % \begin{macro}{\ior_list_streams:} % \begin{macro}[aux]{\@@_list_streams:Nn} % Show the property lists, but with some \enquote{pretty printing}. -% See the \pkg{l3msg} module. If there are no open read streams, -% issue the message \texttt{show-no-stream}, and show an empty -% token list. If there are open read streams, format them with -% \cs{__msg_show_item_unbraced:nn}, and with the message -% \texttt{show-open-streams}. +% See the \pkg{l3msg} module. The first argument of the message is +% |ior| (as opposed to |iow|) and the second is empty if no read +% stream is open and non-empty (in fact a question mark) otherwise. +% The code of the message \texttt{show-streams} takes care of +% translating |ior|/|iow| to English. The list of streams is +% formatted using \cs{__msg_show_item_unbraced:nn}. % \begin{macrocode} \cs_new_protected_nopar:Npn \ior_list_streams: - { \@@_list_streams:Nn \g_@@_streams_prop { input } } + { \@@_list_streams:Nn \g_@@_streams_prop { ior } } \cs_new_protected:Npn \@@_list_streams:Nn #1#2 { - \__msg_term:nnn { LaTeX / kernel } - { \prop_if_empty:NTF #1 { show-no-stream } { show-open-streams } } - {#2} - \__msg_show_variable:n + \__msg_show_pre:nnxxxx { LaTeX / kernel } { show-streams } + {#2} { \prop_if_empty:NF #1 { ? } } { } { } + \__msg_show_wrap:n { \prop_map_function:NN #1 \__msg_show_item_unbraced:nn } } % \end{macrocode} @@ -1357,7 +1359,7 @@ % Done as for input, but with a copy of the auxiliary so the name is correct. % \begin{macrocode} \cs_new_protected_nopar:Npn \iow_list_streams: - { \@@_list_streams:Nn \g_@@_streams_prop { output } } + { \@@_list_streams:Nn \g_@@_streams_prop { iow } } \cs_new_eq:NN \@@_list_streams:Nn \__ior_list_streams:Nn % \end{macrocode} % \end{macro} @@ -1407,7 +1409,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\iow_now:Nn,\iow_now:Nx,\iow_now:cn,\iow_now:cx} +% \begin{macro}{\iow_now:Nn, \iow_now:Nx, \iow_now:cn, \iow_now:cx} % This routine writes the second argument onto the output stream without % expansion. If this stream isn't open, the output goes to the terminal % instead. If the first argument is no output stream at all, we get an @@ -1653,19 +1655,17 @@ %</package> % \end{macrocode} % To warn users that \cs{iow_indent:n} only works in the first argument -% of \cs{iow_wrap:nnnN} reset \cs{iow_indent:n} to its error definition. -% This is a bit of a hack to measure the string length of the run on text -% without the \pkg{l3str} module (which is still experimental). This should -% be replaced once the string module is finalised with something a little -% cleaner. +% of \cs{iow_wrap:nnnN} reset \cs{iow_indent:n} to its error +% definition. Then store a newline character and the run-on text as a +% string in \cs{l_@@_newline_tl}, and set some variables. The first +% line's target count is equal to the length of the whole line. The +% value \cs{l_@@_target_count_int} is altered later on by +% \cs{@@_wrap_set_target:}. % \begin{macrocode} \cs_set_eq:NN \iow_indent:n \@@_indent_error:n \tl_set:Nx \l_@@_newline_tl { \iow_newline: #2 } \tl_set:Nx \l_@@_newline_tl { \tl_to_str:N \l_@@_newline_tl } - \tl_replace_all:Nnn \l_@@_newline_tl { ~ } { \c_space_tl } - \int_set:Nn \l_@@_target_count_int - { \l_iow_line_count_int - \tl_count:N \l_@@_newline_tl + \c_one } - \int_zero:N \l_@@_current_indentation_int + \int_set_eq:NN \l_@@_target_count_int \l_iow_line_count_int \tl_clear:N \l_@@_current_indentation_tl \int_zero:N \l_@@_current_line_int \tl_set:Nn \l_@@_current_line_tl { \use_none:n } @@ -1702,6 +1702,34 @@ % \end{macro} % \end{macro} % +% \begin{macro}[aux]{\@@_wrap_set_target:} +% This is called at the beginning of every line (both those forced by +% |\\| and those due to line-breaking). The initial call does +% nothing except redefine \cs{@@_wrap_set_target:} itself (within the +% group in which \cs{iow_wrap:nnnN} works). The next call (at the +% beginning of the second line) disables any later call and sets the +% \cs{l_@@_target_count_int} to the correct value, namely the +% \cs{l_iow_line_count_int} shortened by the length of the run-on +% text (the shift by~$1$ is due to the presence of \cs{iow_newline:} +% in \cs{l_@@_newline_tl}). +% This is a bit of a hack to measure the string length of the run on text +% without the \pkg{l3str} module (which is still experimental). This should +% be replaced once the string module is finalised with something a little +% cleaner. +% \begin{macrocode} +\cs_new_protected_nopar:Npn \@@_wrap_set_target: + { + \cs_set_protected_nopar:Npn \@@_wrap_set_target: + { + \cs_set_protected_nopar:Npn \@@_wrap_set_target: { } + \tl_replace_all:Nnn \l_@@_newline_tl { ~ } { \c_space_tl } + \int_set:Nn \l_@@_target_count_int + { \l_iow_line_count_int - \tl_count:N \l_@@_newline_tl + \c_one } + } + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[aux]{\@@_wrap_loop:w} % The loop grabs one word in the input, and checks whether it is % the special marker, or a normal word. @@ -1754,6 +1782,7 @@ } \cs_new_protected_nopar:Npn \@@_wrap_word_newline: { + \@@_wrap_set_target: \tl_put_right:Nx \l_@@_wrap_tl { \l_@@_current_line_tl \l_@@_newline_tl } \int_set:Nn \l_@@_current_line_int @@ -1797,6 +1826,7 @@ } \cs_new_protected_nopar:Npn \@@_wrap_newline: { + \@@_wrap_set_target: \tl_put_right:Nx \l_@@_wrap_tl { \l_@@_current_line_tl \l_@@_newline_tl } \int_zero:N \l_@@_current_line_int |