aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2022-05-26incdec.pm: Remove single quotes for Bash inclusionHEADv0.0.2masterTeddy Wing
The single quotes caused a syntax error in the Bash script when included because the Perl script is included in a Bash single-quoted string. Remove the single quotes to fix the Bash inclusion.
2022-05-26Increase version v0.0.1 -> v0.0.2Teddy Wing
2022-05-26Merge branch 'keep-leading-zeros'Teddy Wing
2022-05-26Update copyright yearkeep-leading-zerosTeddy Wing
2022-05-26Add CHANGELOGTeddy Wing
2022-05-26incdec.bash: Recompile with latest changesTeddy Wing
2022-05-26100-increment-decrement: Add a more complex leading zero testTeddy Wing
2022-05-25incdec.pm: Extract number matching regex to a variableTeddy Wing
So it can be re-used in both the find and the replace steps without being duplicated now that it's become more complicated.
2022-05-25incdec.pm: Fix increment for single-digit zero at the end of the lineTeddy Wing
This just adds another "or" option to match a zero at the end of the string. Wonder if there's a nicer way to do this.
2022-05-25incdec.pm: Idea for correctly excluding leading zeroTeddy Wing
This passes the two leading zero tests, but fails the test that tries to increment a single-digit "0" at the last position in the string. Also fix the test's expected start position.
2022-05-25100-increment-decrement: Add tests for integers with leading zeroTeddy Wing
2022-05-25incdec.pm: Fix leading-zero handling for single-digit "0"Teddy Wing
Incrementing or decrementing "0" didn't work with the leading-zero idea I had.
2022-05-25incdec.pm: Idea to keep leading zeros in numbersTeddy Wing
2021-09-07README: Add installation instructions for MacPortsTeddy Wing
2021-09-07100-increment-decrement: Swap "want" and "got"Teddy Wing
When I refactored the tests to add `@want` and `@got` variables, I made a mistake with the names. Swap the two variables to make their contents reflect the meaning of the words.
2021-08-29Add man pagev0.0.1Teddy Wing
2021-08-29Idea.txt: Add name ideasTeddy Wing
2021-08-29Remove pos.plTeddy Wing
No longer need this test file.
2021-08-29README: Complete the Install sectionTeddy Wing
2021-08-29README: Add a section describing default bindingsTeddy Wing
2021-08-29README: Add demo screencastTeddy Wing
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-28100-increment-decrement: Want to return real start position from incdecTeddy Wing
In order to set up point moving only when point is on or after the start position of the changed number, I want the second return value from `incdec()` to always give me the correct start position. Currently, it returns 0 as the start position when backwards is on and point is before the first number. It should return the start position of the first number.
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.bash: Add TODO about moving pointTeddy Wing
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-28100-increment-decrement: Add failing test for backward first numberTeddy Wing
When point is before the first number, that number should be incremented or decremented. This doesn't work correctly with more complex, real world commands.
2021-08-28README: Add ideas for demo commandsTeddy Wing
2021-08-28README: Add ideas for the demo animationTeddy Wing
2021-08-25README: Add ideas for demo explanation and install instructionsTeddy Wing
2021-08-25Add a version number to included scriptsTeddy Wing
2021-08-25Start writing READMETeddy 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.
2021-08-25incdec: Move bindings to a new fileTeddy Wing
Split the bindings from the function definitions. This will allow users to source the functions and define their own bindings. The bindings file can be sourced to get the default bindings.
2021-08-24Add license (GNU GPLv3+)Teddy Wing
2021-08-24incdec: Change default bindings to `C-x a` and `C-x x`Teddy Wing
I had used `C-x +` and `C-x -` during testing because I had an existing non-"-x" binding that was prefixed with `C-x a`, and when I tried to add the `C-x a` "-x" binding, it caused the following error: bash_execute_unix_command: cannot find keymap for command Switch the default bindings to `C-x a` and `C-x x` because those are the ones I originally wanted, since they don't appear to conflict with any existing default Readline bindings, and they're similar to the Vim increment and decrement commands.
2021-08-24incdec: Add comments to describe Bash functionsTeddy Wing
2021-08-24incdec: Remove old codeTeddy Wing
Now that we have this working, remove the old functions, binding definitions, and TODOs. All TODOs here are handled. The old Bash functions and bindings were for a Bash-only implementation. The point-moving code in `__readline_incdec_decrement` wasn't applicable to decrementing numbers.
2021-08-24Rename `incdec.pl.m4` to `incdec.m4.pl`Teddy Wing
Like we did for the `incdec.m4` Bash include, rename the Perl M4 file to give it a `.pl` extension so we get Perl syntax highlighting. Similarly define an include macro so quoting doesn't mess up highlighting.
2021-08-24Makefile: Swap m4 argumentsTeddy Wing
Put the file after the option argument since it's more common to order them that way.
2021-08-23Turn off strict and warnings in final `perl -e` scriptTeddy Wing
Those caused the following errors: Variable "$line" is not imported at -e line 45. Variable "$increment_by" is not imported at -e line 45. Variable "$point_position" is not imported at -e line 45. Variable "$backward" is not imported at -e line 45. Global symbol "$line" requires explicit package name (did you forget to declare "my $line"?) at -e line 45. Global symbol "$increment_by" requires explicit package name (did you forget to declare "my $increment_by"?) at -e line 45. Global symbol "$point_position" requires explicit package name (did you forget to declare "my $point_position"?) at -e line 45. Global symbol "$backward" requires explicit package name (did you forget to declare "my $backward"?) at -e line 45. Execution of -e aborted due to compilation errors. I suppose I could have kept warnings, as only strict caused the errors, but decided to remove it anyway. Not sure what makes the most sense.
2021-08-23Makefile: Reorganise targetsTeddy Wing
Put build targets above the test target.
2021-08-23Highlight `incdec.m4` as a Bash fileTeddy Wing
When I changed the file to an M4 file, it removed Bash syntax highlighting, and the `include()` call interfered with Bash quote matching. Use a different macro to include the Perl file so we can get Bash syntax highlighting.
2021-08-23Generate `incdec` from `incdec.m4`Teddy Wing
Include the built `incdec.pl` code in the Bash file by generating it from `incdec.pm`.
2021-08-23Build final Perl program from `incdec.pm`Teddy Wing
Build an intermediary Perl file that includes the extra lines that call `incdec()`. This whole file should be included in the final Bash function `perl -e` call.
2021-08-23Remove incdec.plTeddy Wing
I created this file for testing. We no longer need it.
2021-08-23incdec.pm: Remove recent debug printsTeddy Wing
Remove the debug prints when I was trying to work out the problem with negative numbers and the last number in the line.