| Age | Commit message (Collapse) | Author | 
|---|
|  |  | 
|  |  | 
|  | Add a ".bash" extension to the main include script make explicit the
intent for it to be used with Bash. | 
|  | 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. | 
|  |  | 
|  | 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. | 
|  |  | 
|  | 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. | 
|  | 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. | 
|  | Put the file after the option argument since it's more common to order
them that way. | 
|  | 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. | 
|  | Put build targets above the test target. | 
|  | 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. | 
|  | Include the built `incdec.pl` code in the Bash file by generating it
from `incdec.pm`. | 
|  | 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. | 
|  | I created this file for testing. We no longer need it. | 
|  | Remove the debug prints when I was trying to work out the problem with
negative numbers and the last number in the line. | 
|  | 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. | 
|  | 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
               ^ | 
|  | Describe why we set `$point_position` the way we do. | 
|  | 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. | 
|  | 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. | 
|  | 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`. | 
|  | The previous negative integer tests worked, but it turns out that when
the negative integer isn't the first one, there's a problem. | 
|  |  | 
|  |  | 
|  | 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. | 
|  | Our pattern matcher doesn't increment or decrement negative numbers
because it doesn't look for a "-" prefix. | 
|  |  | 
|  | 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. | 
|  |  | 
|  |  | 
|  | Commenting this out instead of removing it for the moment while I add
test cases in case I need to keep debugging. | 
|  | Turns out the backward increment/decrement didn't work in all cases. I
hadn't tested a multi-digit number in the second position from the left.
That didn't work with the old code. Adjust it and simplify it. Didn't
need to be so complicated. Now we set the start position to the $-[0] of
the previous match if the current match is to the right of point. | 
|  | A new subrouting argument that defines by how much the number should be
incremented, or decremented if a negative step value is given.
Add a few new tests to verify the decrementing behaviour. The final test
where point is in the middle of the number fails. | 
|  |  | 
|  |  | 
|  | Set up the proper condition to get the start index of the number just
before point. | 
|  |  | 
|  | Update the condition that increments the last number if the point is at
the end. | 
|  | Doesn't work for middle numbers yet. | 
|  |  | 
|  | Still a bunch of old code to clean up, but this is a lot shorter than
what I had before, and I think it will be easier to extend it for
backwards searching. | 
|  | This updated loop gets the start position of the appropriate number
nearest to point. It currently only works left to right, but seems like
it should be easy enough to extend to be right to left. | 
|  | Not what I was thinking when I wrote that looping code. | 
|  | Set `pos()` to enable us to increment a number in the middle of a
string. | 
|  | Looking into a different algorithm for incrementing matches that's
easier to use in both forward and backward contexts.
Got a few ideas to get a match nearest to the cursor position. We could
then take that value and increment it, and replace the original
substring with the new incremented value. | 
|  |  | 
|  |  | 
|  | Here, we really just want to exit the loop. There's no reason to change
`$point_position`. |