| Age | Commit message (Collapse) | Author |
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
So it can be re-used in both the find and the replace steps without
being duplicated now that it's become more complicated.
|
|
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.
|
|
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.
|
|
|
|
Incrementing or decrementing "0" didn't work with the leading-zero idea
I had.
|
|
|
|
|
|
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.
|
|
|
|
|
|
No longer need this test file.
|
|
|
|
|
|
|
|
This works now.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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()`.
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|