tihirvon / dex

Dextrous text editor
GNU General Public License v2.0
165 stars 13 forks source link

Option to not skip newlines as "special characters" #25

Closed craigbarnes closed 9 years ago

craigbarnes commented 9 years ago

The commands word-fwd -s, word-bwd -s, erase-word -s, etc. currently all skip across newlines. If there were an option to skip "special characters" but not newlines, it would be possible to exactly replicate the behaviour used by most GUI applications (for familiarity/consistency purposes).

The following basic patch seems to work:

diff --git a/move.c b/move.c
index 85492ce..1a7f329 100644
--- a/move.c
+++ b/move.c
@@ -232,7 +232,7 @@ long word_fwd(struct block_iter *bi, bool skip_non_word)
        if (!get_current_char_type(bi, &type))
            return count;

-       if (count && (!skip_non_word || type == CT_WORD))
+       if (count && (!skip_non_word || type == CT_WORD || type == CT_NEWLINE))
            return count;

        count += skip_fwd_char_type(bi, type);

Would you be willing to accept a more complete patch for this if it was implemented as an optional flag?

tihirvon commented 9 years ago

This makes sense, but there's no need to make it optional.

craigbarnes commented 9 years ago

Sorry, I meant to submit a patch for this and then completely forgot about it. I see you've already implemented it in 91c6773. Thanks!