[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [RFC] improved word bounds
From: |
Brand Huntsman |
Subject: |
[Nano-devel] [RFC] improved word bounds |
Date: |
Fri, 27 Jul 2018 19:36:17 -0600 |
Current issues with word bounds:
nano +10 NEWS
... with the linter.
2018.05.15 - GNU nano 2.9.7 "Hvide Sande" adds ...
^
The prevword bind jumps to "linter." and nextword bind jumps to
"2018.05.15". But using cutwordright on "linter." not only removes the word but
also all punctuation, whitespace and newlines. This makes it useless for
cutting the last word on a line, because you probably never want the next
paragraph/block to be moved up. And prevword/nextword would be better if they
stopped at the end of the "linter." line.
nano +1951,20 nano.c
int main(int argc, char **argv)
^
{
int stdin_flags, optchr;
Press cutwordright twice, first press consumes "char **" and second press
consumes "argv(\n{\n\t". Both cuts consume more than expected or wanted.
nano +1095 global.c
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
^ ^ ^ ^ ^ ^ ^
It ignores all punctuation, even when completely wrapped in whitespace (the " &
").
I propose the following changes:
Alphanumeric set includes wordchars option, and whitespace/newlines is not
included in the non-alphanumeric set.
Scanning right grabs word and whitespace but:
1) stop scanning when transitioning between newline and non-newline
2) stop scanning when transitioning from whitespace to non-whitespace
3) stop scanning when transitioning between alphanumeric and non-alphanumeric
Scanning left grabs whitespace and word but:
1) stop scanning when transitioning between newline and non-newline
2) stop scanning when transitioning from non-whitespace to whitespace
3) stop scanning when transitioning between alphanumeric and non-alphanumeric
Treating all newlines as a word would cut "linter." without also cutting all
newlines after it. A second cut would cut all the newlines and bring the next
block up to current line.
Stopping the scan when transitioning from whitespace to non-whitespace avoids
consuming multiple words, even if those words aren't alphanumeric. You could
jump to the "&" and start of string parameter on the add_to_sclist line. And
only "char " would be cut instead of "char **" on the main() line.
Treating non-alphanumeric as words fixes cutting issues and improves word jump
points. The period in "linter." becomes a separate word, you could jump to it
and insert more words or cut the last word in a sentence without removing any
punctuation after it. Commas and parens in function parameter lists become
separate words (unless an operator is touching the paren or comma) to jump to
and a few left/right word cuts can precisely remove an entire parameter.
The non-alphanumeric set would be empty if wordbounds is enabled, and step 3
would be skipped.
I think all three changes would produce expected results for all cases in any
kind of text file.
Thoughts?