diff --git a/ChangeLog b/ChangeLog index 8078c058b62b11ee83020602713da209eaad1c2e..d708a54872697dbfa9df614827fd92636ca0b86f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,7 +17,7 @@ 2016-02-22 Chris Allegretta <chrisa@asty.org> * Add the ability to kill the trailing spaces when justifying text, - by adding a new nanorc option 'kill_spaces_on_justify' -- we'll see + by adding a new nanorc option 'justifytrim' -- we'll see whether this warrants a command-line flag or not. Now with slightly better logic for multi-spaced lines. diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5 index a231b0c8201c513977b1b3f93c8c47ac17eb91a2..1bc3800463a03ed96c8125a4bd0d0418157d3442 100644 --- a/doc/man/nanorc.5 +++ b/doc/man/nanorc.5 @@ -111,6 +111,9 @@ See \fBset titlecolor\fR for more details. Enable the use of \fB~/.nano/search_history\fP for saving and reading search/replace strings. .TP +.B set justifytrim +When justifying text, trailing newlines will automatically be removed. +.TP .B set keycolor \fIfgcolor\fR,\fIbgcolor\fR Specify the color combination to use for the shortcut key combos in the two help lines at the bottom of the screen. diff --git a/doc/nanorc.sample.in b/doc/nanorc.sample.in index 374f4c8949371411702dfc06c3833e89a01ff3f2..cd8f32ee7bab3893cebecbc181aa0bce0f5f4426 100644 --- a/doc/nanorc.sample.in +++ b/doc/nanorc.sample.in @@ -60,6 +60,9 @@ ## Remember the used search/replace strings for the next session. # set historylog +## Have the justify command kill whitespace at the end of lines +# set justifytrim + ## Enable vim-style lock-files. This is just to let a vim user know you ## are editing a file [s]he is trying to edit and vice versa. There are ## no plans to implement vim-style undo state in these files. diff --git a/doc/syntax/nanorc.nanorc b/doc/syntax/nanorc.nanorc index 589ed3832000a81d6b64323088cfc96a7fa3246a..af3e94f94de992fbc45717061957b15773cbb47d 100644 --- a/doc/syntax/nanorc.nanorc +++ b/doc/syntax/nanorc.nanorc @@ -6,7 +6,7 @@ syntax "nanorc" "\.?nanorc$" icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|i?color|extendsyntax).*$" # Keywords -icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds|kill_spaces_on_justify)\>" +icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds|justify_trim)\>" icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor|statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>" icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+" icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9^_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(2|with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)" diff --git a/src/nano.h b/src/nano.h index 987ebd2f480b2169986d8824e50fa89ceb168105..0099c37d28ae53f084fca2a3e219c37fd8600314 100644 --- a/src/nano.h +++ b/src/nano.h @@ -518,7 +518,7 @@ enum LOCKING, NOREAD_MODE, MAKE_IT_UNIX, - KILL_TRAILING_SPACES + JUSTIFY_TRIM }; /* Flags for the menus in which a given function should be present. */ diff --git a/src/rcfile.c b/src/rcfile.c index 5e3963ba35e2d3b88d100de50ee633513ae22820..db1a129ad8f5c262ec0b20859825aaffe228d686 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -90,7 +90,7 @@ static const rcoption rcopts[] = { {"backwards", BACKWARDS_SEARCH}, {"casesensitive", CASE_SENSITIVE}, {"cut", CUT_TO_END}, - {"kill_spaces_on_justify", KILL_TRAILING_SPACES}, + {"justifytrim", JUSTIFY_TRIM}, {"locking", LOCKING}, {"matchbrackets", 0}, {"noconvert", NO_CONVERT}, diff --git a/src/text.c b/src/text.c index e419616a7b2121d35a4423be6968f9c2c0bccfcb..b8370256938d50955e1522a37ad16669907537bb 100644 --- a/src/text.c +++ b/src/text.c @@ -1279,7 +1279,7 @@ bool do_wrap(filestruct *line) /* If after_break doesn't end in a blank, make sure it ends in a * space. */ - if (!is_blank_mbchar(end) && !ISSET(KILL_TRAILING_SPACES)) { + if (!is_blank_mbchar(end) && !ISSET(JUSTIFY_TRIM)) { #ifndef NANO_TINY add_undo(ADD); #endif @@ -2176,7 +2176,7 @@ void do_justify(bool full_justify) #endif /* Break the current line. */ - if (ISSET(KILL_TRAILING_SPACES)) { + if (ISSET(JUSTIFY_TRIM)) { while (break_pos > 0 && is_blank_mbchar(&openfile->current->data[break_pos-1])) { break_pos--;