pashi
pashi copied to clipboard
Add option to restart line numbering between files
Currently, when two or more files are concatenated, line numbers continue. It would be useful if line numbering could be restarted between files.
We also need to consider whether or not to number the separator lines between files at all.
With regard to inhibiting numbering of separator lines see issue ~~#48~~ #62.
RE
We also need to consider whether or not to number the separator lines between files at all.
AND
With regard to inhibiting numbering of separator lines see issue ~~#48~~ #62.
How about a new Boolean --separator-line-numbering option that enables / disables numbering of separator lines? The default would be off and it would be ignored if --line-numbering is off.
How about a new Boolean
--separator-line-numberingoption that enables / disables numbering of separator lines? The default would beoffand it would be ignored if--line-numberingisoff.
The separator-line-numbering proposal has been split out into its own issue (#62) and won't be considered further here.
This issue will concentrate only on its original topic, i.e. on options to restart line numbering between files.
It's worth considering if the existing --line-number-start command can be extended.
Presently the command takes a single parameter, the number on which to start numbering lines. This number is incremented by one for each line and continues being incremented across each file.
Here are some ideas for parameters that might make the command usable to reset line numbering:
-
X(where X is a number in range 1...9999):Xis the number on which to start numbering the 1st file. Numbers increase across all files without resetting. This is the current usage of the command, except that 0 is now permitted as the lowest line number instead of 1. -
*X(where X is a number in range 0...9999): All files are numbered starting from lineX. Numbers reset toXat the start of the next file. -
[X1,X2,..,Xn](where allXs are numbers in range 0..9999): A comma separated, non-empty, list of line numbers. Numbering of the 1st file starts atX1, the 2nd file atX2, etc. If there are fewer numbers in the list than files then the last value,Xn, is used for all files for which no number is specified. If there are too many numbers in the list then excess list entries are ignored. -
X+Y(where X is a number in the range 0..9999 and Y is a number in the range 1..1000): Files are numbered starting from lineX + (N - 1) × Y, whereNis the number of the file, starting at 1. So, ifX=1andY=100, file 1 starts numbering at1, file 2 starts at101, file 3 starts at201, and so on. -
X^Y(whereXis a number in range 0..9999 &Yis a number in range 1..3): The first file is numbered starting from lineX. Files after the first are numbered starting from lineZ × 10^Y + X, whereZis the smallest number such thatL < Z × 10^YandLis the greatest line number in the previous file. For e.g. ifL=349,X=1andY=2thenZis chosen so that349 < Z × 100. The smallestZsatisfying this condition isZ=4, so the starting line for the file is4 × 100 + 1=401. IfL=249thenZ=3and the next starting line is301, or ifL=500thenZ=6and the next line is601.
Any of the above parameters can be followed by /X, where X is the gap between adjacent line numbers, in the range 1..100. If /X is omitted then X is taken to be 1. As a simple example, the parameter 10/10 starts lines numbering from 10 and increments in steps of 10 without resetting between files - shades of BASIC! A more complex example would be [10,1010,2010]/10 will number file 1 from 10 in steps of 10, file 2 from 1010 in steps of 10 and file 3 from 2010 in steps of 10.
The default parameter is 1/1 (= 1) which is functionally the same as the current default.
A more complex example would be
[10,1010,2010]/10will number file 1 from 10 in steps of 10, file 2 from 1010 in steps of 10 and file 3 from 2010 in steps of 10.
Could we also support different line steps for each file by using something like [10/10,1020/20,2000/100] to number file 1 from 10 in steps of 10, file 2 from 1020 in steps of 20 and file 3 from 2000 in steps of 100?