| Age | Commit message (Collapse) | Author |
|
|
|
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.
|
|
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.
|
|
Include the built `incdec.pl` code in the Bash file by generating it
from `incdec.pm`.
|
|
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
^
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
Got it working! Thanks to the Fzf Bash code for showing me that you can
assign to `READLINE_LINE` and `READLINE_POINT`:
https://github.com/junegunn/fzf/blob/7191ebb615f5d6ebbf51d598d8ec853a65e2274d/shell/key-bindings.bash
|
|
Thinking I might be able to echo the whole line to the command line
instead of working out how to replace just the number that we've
incremented.
Discovered how to increment a number in a regex substitution from this
Stack Overflow answer by Mark Setchell
(https://stackoverflow.com/users/2836621/mark-setchell):
https://stackoverflow.com/questions/54367360/how-to-increment-the-last-number-in-a-string-bash/54367784#54367784
|
|
If we have access to the full command line and modify the number in it,
we can print the whole thing with the number incremented onto the
working command line.
Probably going to need some Perl to do the regex and incrementing.
|
|
A long time ago, I was trying to get this to work, but wasn't able to.
Commit the code from then.
Not really sure exactly what that was about now.
|
|
Want something similar to <C-a> and <C-x> in Vim. This function matches
and increments the number, but I'm currently stymied on how to insert
the number into the current line. There doesn't appear to be a way to do
that, except perhaps with the `shell-expand-line` function, and I don't
want to use that because I just want to insert the number, not expand
other parts of the shell line.
The other sticking point is how to read the value of the
`universal-argument`. There doesn't currently seem to be a way to do
that in a custom function.
I had a new idea for the number insertion problem, though. It's possible
I could replace the number, <C-c> the line, and reinsert a new copy with
the incremented/decremented number on the new shell line. That still
wouldn't resolve the `universal-argument` problem.
|