From 4f03daff918cc97a58dd59d060f8fb586f2f1175 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 10 Aug 2005 22:12:28 +0000 Subject: [PATCH] add new -W/--wordbounds command line option, and new "wordbounds" rcfile option, to control whether the word movement functions treat punctuation characters as part of a word git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2983 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ doc/nanorc.sample | 6 +++++- src/move.c | 4 ++-- src/nano.c | 14 ++++++++++++-- src/nano.h | 3 ++- src/rcfile.c | 1 + 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 306e2b90..c7f9f944 100644 --- a/ChangeLog +++ b/ChangeLog @@ -148,6 +148,12 @@ CVS code - and add an updated FAQ entry about its use. Changes to window_init(), usage(), main(), get_verbatim_kbinput(), nanorc.sample, and faq.html. (DLR) + - Add new -W/--wordbounds command line option, and new + "wordbounds" rcfile option, to control whether + the word movement functions treat punctuation characters as + part of a word. Changes to do_next_word_void(), + do_prev_word_void(), usage(), main(), and nanorc.sample. (DLR, + suggested by Mike Frysinger) - color.c: - Remove unneeded fcntl.h include. (DLR) - chars.c: diff --git a/doc/nanorc.sample b/doc/nanorc.sample index bd772fa5..135e6ea8 100644 --- a/doc/nanorc.sample +++ b/doc/nanorc.sample @@ -144,6 +144,10 @@ ## (00B7 hexadecimal) seem to be good values for these. # set whitespace " " +## Detect word boundaries more accurately by treating punctuation +## characters as part of a word. +# set wordbounds + ## Color setup ## ## Format: @@ -324,7 +328,7 @@ ## highlight possible errors and parameters # icolor brightwhite "^[[:space:]]*(set|unset|syntax|i?color).*$" ## set, unset and syntax -# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quickblank|quotestr|rebinddelete)\>" "^[[:space:]]*(set|unset)[[:space:]]+(rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace)\>" +# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quickblank|quotestr|rebinddelete)\>" "^[[:space:]]*(set|unset)[[:space:]]+(rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>" # icolor green "^[[:space:]]*(set|unset|syntax)\>" ## colors # icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" diff --git a/src/move.c b/src/move.c index 69b6b6cb..b982f222 100644 --- a/src/move.c +++ b/src/move.c @@ -297,7 +297,7 @@ bool do_next_word(bool allow_punct, bool allow_update) void do_next_word_void(void) { - do_next_word(FALSE, TRUE); + do_next_word(ISSET(WORD_BOUNDS), TRUE); } /* Move to the previous word in the current filestruct. If allow_punct @@ -428,7 +428,7 @@ bool do_prev_word(bool allow_punct, bool allow_update) void do_prev_word_void(void) { - do_prev_word(FALSE, TRUE); + do_prev_word(ISSET(WORD_BOUNDS), TRUE); } #endif /* !NANO_SMALL */ diff --git a/src/nano.c b/src/nano.c index b1900925..1998ea9f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1077,6 +1077,10 @@ void usage(void) #endif print1opt("-V", "--version", N_("Print version information and exit")); +#ifndef NANO_SMALL + print1opt("-W", "--wordbounds", + N_("Detect word boundaries more accurately")); +#endif #ifdef ENABLE_COLOR print1opt(_("-Y [str]"), _("--syntax=[str]"), N_("Syntax definition to use")); @@ -1918,6 +1922,7 @@ int main(int argc, char **argv) {"noconvert", 0, NULL, 'N'}, {"smooth", 0, NULL, 'S'}, {"quickblank", 0, NULL, 'U'}, + {"wordbounds", 0, NULL, 'W'}, {"autoindent", 0, NULL, 'i'}, {"cut", 0, NULL, 'k'}, #endif @@ -1958,11 +1963,11 @@ int main(int argc, char **argv) while ((optchr = #ifdef HAVE_GETOPT_LONG getopt_long(argc, argv, - "h?ABC:EFHIKNOQ:RST:UVY:abcdefgijklmo:pr:s:tvwxz", + "h?ABC:EFHIKNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz", long_options, NULL) #else getopt(argc, argv, - "h?ABC:EFHIKNOQ:RST:UVY:abcdefgijklmo:pr:s:tvwxz") + "h?ABC:EFHIKNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz") #endif ) != -1) { switch (optchr) { @@ -2042,6 +2047,11 @@ int main(int argc, char **argv) case 'V': version(); exit(0); +#ifndef NANO_SMALL + case 'W': + SET(WORD_BOUNDS); + break; +#endif #ifdef ENABLE_COLOR case 'Y': syntaxstr = mallocstrcpy(syntaxstr, optarg); diff --git a/src/nano.h b/src/nano.h index 945b4e3a..61b8d307 100644 --- a/src/nano.h +++ b/src/nano.h @@ -313,7 +313,8 @@ typedef struct rcoption { #define MORE_SPACE (1<<26) #define TABS_TO_SPACES (1<<27) #define QUICK_BLANK (1<<28) -#define USE_UTF8 (1<<29) +#define WORD_BOUNDS (1<<29) +#define USE_UTF8 (1<<30) /* Control key sequences. Changing these would be very, very bad. */ #define NANO_CONTROL_SPACE 0 diff --git a/src/rcfile.c b/src/rcfile.c index ec356349..d5140c60 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -88,6 +88,7 @@ const static rcoption rcopts[] = { {"smooth", SMOOTH_SCROLL}, {"tabstospaces", TABS_TO_SPACES}, {"whitespace", 0}, + {"wordbounds", WORD_BOUNDS}, #endif {NULL, 0} }; -- 2.39.5