aboutsummaryrefslogtreecommitdiffstats
path: root/incdec.bash
AgeCommit message (Collapse)Author
2021-08-29incdec.bash: Remove start position debug prints and TODOTeddy Wing
This works now.
2021-08-29incdec.pm: Clean up code from previous start position commitTeddy Wing
2021-08-29incdec.pm: Always return start position when backwards is onTeddy Wing
Previously, if backwards was on and point was before the first number on the line, the start position would be set to 0 (when it gets set to `$previous_match_start`). This means the start position wouldn't get set to the actual start position of the first number. We want the actual start position of that number so we can move point only if it's on or after the current number when changing between negative and positive numbers. Also, the `\G` pattern didn't work on some of the `sed` tests because it matches a number at that position. Since the position wasn't one that was followed by the number, the regex didn't match a number, and the increment didn't happen. We can get rid of the special handling for start position at 0 now.
2021-08-28incdec.bash: Set up point moving after start positionTeddy Wing
This doesn't work yet as it turns out it requires a change to the `incdec()` Perl subroutine. We want to move point when switching between positive and negative numbers (adding or removing a hypen negative sign), but only if point is on or after the start of the number being incremented. If point is before that, it looks like it's moving. Read the start index from the `incdec()` subroutine and prefix it to the output line in the format: "${start_position}#${output_line}". We can then use the "#" to split the two values and extract them in the Bash functions. Needed to move setting `$READLINE_LINE` to the increment and decrement Bash functions because I now run `__readline_incdec` in a subshell, meaning the current line can't be manipulated with that variable in that function. In the increment and decrement Bash functions, we now check if the start position of the incremented number is less than or equal to `$READLINE_POINT` before trying to move point.
2021-08-28incdec.pm: Return both line and start positionTeddy Wing
I want access to the start position of the number being operated on. This will allow me to determine if point should be moved or not. Refactor everything to accept an array from `incdec()`.
2021-08-28incdec.pm: Fix an issue where first number wasn't incremented backwardsTeddy Wing
When `$start_position` was 0 going backwards, the `sed` test command line failed to increment the first number in the line. Can't figure out exactly what was wrong, but there seemed to be a problem with using the `\G` assertion for that test case. Decided to remove `\G` when `$start_position` position is 0 to work around the problem. Not sure if there's a more concise solution to this that wouldn't require me to have two separate subtitution lines. Also simplified the substitution regular expression. It turns out I didn't need the first capture group, and it was incorrect in matching /[^-\d]*/ because we really wanted /(?!-?\d+)/, not either or of the characters in the group. Completely removing it still allows everything to work. Don't remember if I added that when I was still using the substringing algorithm, but whatever happens, it's not necessary now.
2021-08-25Add a version number to included scriptsTeddy Wing
2021-08-25Rename `incdec` to `incdec.bash`Teddy Wing
Add a ".bash" extension to the main include script make explicit the intent for it to be used with Bash.