<feed xmlns='http://www.w3.org/2005/Atom'>
<title>readline-incdec/incdec.pm, branch v0.0.1</title>
<subtitle>Readline bindings to increment and decrement numbers on the command line</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/'/>
<entry>
<title>incdec.pm: Clean up code from previous start position commit</title>
<updated>2021-08-28T22:48:35+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-28T22:45:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=40289847cae91a317a660d38ec4c6a48164f58f6'/>
<id>40289847cae91a317a660d38ec4c6a48164f58f6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Always return start position when backwards is on</title>
<updated>2021-08-28T22:47:56+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-28T22:28:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=e56b8c2e88c8c5444f66634dbe3c511a5f37a3d6'/>
<id>e56b8c2e88c8c5444f66634dbe3c511a5f37a3d6</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Return both line and start position</title>
<updated>2021-08-28T17:42:31+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-28T17:42:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=729cdbe8c41598aaa70c7c71d708953dd72a6866'/>
<id>729cdbe8c41598aaa70c7c71d708953dd72a6866</id>
<content type='text'>
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()`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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()`.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Fix an issue where first number wasn't incremented backwards</title>
<updated>2021-08-28T16:25:23+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-28T16:08:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=88cc7f664a2c582c4fb08a4c3f927da7863ce9fc'/>
<id>88cc7f664a2c582c4fb08a4c3f927da7863ce9fc</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add license (GNU GPLv3+)</title>
<updated>2021-08-24T21:22:58+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-24T21:22:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=ee898b113f54911e9e2719c3f6b73dcf42139a0e'/>
<id>ee898b113f54911e9e2719c3f6b73dcf42139a0e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Remove recent debug prints</title>
<updated>2021-08-23T18:56:26+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-23T18:56:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=6fb6965372d71676d3d8246204f82bd91391123a'/>
<id>6fb6965372d71676d3d8246204f82bd91391123a</id>
<content type='text'>
Remove the debug prints when I was trying to work out the problem with
negative numbers and the last number in the line.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove the debug prints when I was trying to work out the problem with
negative numbers and the last number in the line.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Add descriptions for the backwards handling</title>
<updated>2021-08-22T18:55:46+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-22T18:55:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=250252e775486f9d60652a4b4490caac6756e767'/>
<id>250252e775486f9d60652a4b4490caac6756e767</id>
<content type='text'>
Describe why we set `$point_position` the way we do.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Describe why we set `$point_position` the way we do.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec: Fix negative number handling when number is second of two</title>
<updated>2021-08-22T18:32:27+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-22T18:17:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=ebce4b2272bcb8299d0ab4fa1524b6f4af9976c3'/>
<id>ebce4b2272bcb8299d0ab4fa1524b6f4af9976c3</id>
<content type='text'>
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`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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`.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec.pm: Handle negative numbers</title>
<updated>2021-08-21T19:13:59+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-21T19:12:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=54218fbf53e7077fdd3740456be434893253b183'/>
<id>54218fbf53e7077fdd3740456be434893253b183</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>incdec: Comment out test code from backward match fix</title>
<updated>2021-08-19T21:48:57+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2021-08-19T21:48:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/readline-incdec/commit/?id=c16d56b927ad786f8fa299b9ce5b746f7434a2e7'/>
<id>c16d56b927ad786f8fa299b9ce5b746f7434a2e7</id>
<content type='text'>
Commenting this out instead of removing it for the moment while I add
test cases in case I need to keep debugging.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commenting this out instead of removing it for the moment while I add
test cases in case I need to keep debugging.
</pre>
</div>
</content>
</entry>
</feed>
