aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
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.
2021-08-22Add incdec.plTeddy Wing
This was from when I extracted the `incdec` function to a standalone Perl script to test what was wrong with negative numbers in the second position.
2021-08-22incdec: Move point if negative hyphen is added or removedTeddy Wing
Previously, point would stay in the same position, causing it to look like it moved when incrementing or decrementing between a negative number and a positive number. This moves point by one to the right when decrementing to a negative integer, or by one to the left when incrementing to a positive integer. That makes the point seem like it hasn't moved and making it look more natural. For example, now point behaves like this: $ test 12 0 ^ _decrement_ $ test 12 -1 ^ $ test 12 -1 ^ _increment_ $ test 12 0 ^ Before, it would do: $ test 12 0 ^ _decrement_ $ test 12 -1 ^ $ test 12 -1 ^ _increment_ $ test 12 0 ^
2021-08-22incdec.pm: Add descriptions for the backwards handlingTeddy Wing
Describe why we set `$point_position` the way we do.
2021-08-22incdec: Idea for point moving when changing from positive to negativeTeddy Wing
If we change between negative and positive numbers, point moves: $ test 12 0 ^ _decrement_ $ test 12 -1 ^ I think point should instead be $ test 12 -1 ^ Not sure that we should be moving point when changing from negative to positive, though.
2021-08-22incdec: Try new negative last number handling in the Readline bindingsTeddy Wing
This works! Also, a while ago, I changed the Perl program to not use hyphenated command line arguments and quoted variable names `${"increment-by"}` because this seemed to be causing unexpected issues.
2021-08-22incdec: Fix negative number handling when number is second of twoTeddy Wing
When the negative number is the last of two numbers, the first number would be incremented or decremented instead of the second one. Fix this by: * Removing the `\b` word boundaries in the search pattern. This caused the match start position to not include the hyphen that designates a negative number (instead starting at one after the hyphen). * Setting `$start_position` to the start position of the current match (`$-[0]`) on every match loop iteration. This ensures the start position is set to an appropriate index when the number we want to increment is the last one in the line. Since the condition in the loop depends on there being a previous match position, it wouldn't set the start position correctly in all cases for the last number in the line. * Remove the special case to handle the last number in the line when searching backward with the cursor in the last position. That case is now handled directly in the loop by always setting `$start_position`.
2021-08-22100-increment-decrement: Add new second number negative integer testsTeddy Wing
The previous negative integer tests worked, but it turns out that when the negative integer isn't the first one, there's a problem.
2021-08-21100-increment-decrement: Add test to decrement a negative integerTeddy Wing
2021-08-21incdec: Add a note for basic point handling when line length changesTeddy Wing
2021-08-21incdec.pm: Handle negative numbersTeddy Wing
Include "-" in the pattern that matches numbers. Wrap the pattern in word boundaries also. This passes the test I added previously to increment a negative number.
2021-08-21100-increment-decrement: Doesn't work for negative numbersTeddy Wing
Our pattern matcher doesn't increment or decrement negative numbers because it doesn't look for a "-" prefix.
2021-08-21incdec: Add increment and decrement bindingsTeddy Wing
2021-08-21incdec: Get increment working in a Readline bindingTeddy Wing
Copy-pasted the `incdec` subroutine from `incdec.pm` into the Bash function. Eventually I'll have a Make rule for this. Add some new Perl code to the `perl -e` call that calls the `incdec()` subroutine with arguments from the shell environment. Set the current Readline line to the result of `incdec()` to increment a number. I was getting an error "bash_execute_unix_command: cannot find keymap for command" when I tried to assign the binding to "\C-xa". Not sure what's going on there but assigned it to a different one in the meantime.
2021-08-20Add idea for command line point start/end behaviourTeddy Wing