aboutsummaryrefslogtreecommitdiffstats
path: root/incdec
AgeCommit message (Collapse)Author
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-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-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-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: 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-21incdec: Add a note for basic point handling when line length changesTeddy Wing
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
2021-08-08incdec: Increment the number on the current lineTeddy Wing
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
2021-08-08incdec: Increment the number and print the whole lineTeddy Wing
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
2021-08-08incdec: Ideas for operating on the full command lineTeddy Wing
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.
2021-08-07incdec: Ideas for bindings and getting point locationTeddy Wing
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.
2021-01-09Idea for a Readline binding to increment/decrement a numberTeddy Wing
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.