Adding the option --unix (and 'set unix'),

to save a file by default in Unix format.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5342 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-08-04 18:49:57 +00:00
parent 95e1f55574
commit 70cbbda87c
9 changed files with 39 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2015-08-04 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main), src/files.c (read_file), src/rcfile.c,
doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Add
the option --unix, to save a file by default in Unix format.
2015-08-03 Benno Schulenberg <bensberg@justemail.net> 2015-08-03 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c (parse_binding): Check the value of shortcut->toggle * src/rcfile.c (parse_binding): Check the value of shortcut->toggle
only if it actually is a toggle. Found with valgrind. only if it actually is a toggle. Found with valgrind.

View File

@ -222,6 +222,11 @@ Use this alternative spell checker command.
Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP
option. option.
.TP .TP
.BR \-u ", " \-\-unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fB\-\-noconvert\fR.)
.TP
.BR \-v ", " \-\-view .BR \-v ", " \-\-view
View-file (read-only) mode. View-file (read-only) mode.
.TP .TP

View File

@ -242,6 +242,11 @@ Valid color names for foreground and background are:
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan . .BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out. And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
.TP .TP
.B set unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fBset noconvert\fR.)
.TP
.B set view .B set view
Disallow file modification. Disallow file modification.
.TP .TP

View File

@ -6,7 +6,7 @@ syntax "nanorc" "\.?nanorc$"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|i?color|extendsyntax).*$" icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|i?color|extendsyntax).*$"
# Keywords # 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|nofollow|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|view|wordbounds)\>" icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const(antshow)?|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|pos(ition)?log|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|unix|view|wordbounds)\>"
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 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:]]*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:]]*$" 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:]]*$"

View File

@ -325,6 +325,12 @@ Don't ask whether or not to save the current contents of the file when
exiting, assume yes. This is most useful when using @command{nano} as the exiting, assume yes. This is most useful when using @command{nano} as the
composer of a mailer program. composer of a mailer program.
@item -u
@item --unix
Save a file by default in Unix format. This overrides nano's
+default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{--noconvert}.)
@item -v @item -v
@itemx --view @itemx --view
Don't allow the contents of the file to be altered. Note that this Don't allow the contents of the file to be altered. Note that this
@ -799,6 +805,11 @@ Valid color names for foreground and background are:
white, black, red, blue, green, yellow, magenta, and cyan. white, black, red, blue, green, yellow, magenta, and cyan.
And either @var{fgcolor} or @var{,bgcolor} may be left out. And either @var{fgcolor} or @var{,bgcolor} may be left out.
@item set unix
Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{set noconvert}.)
@item set view @item set view
Disallow file modification. Disallow file modification.

View File

@ -908,6 +908,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
statusbar(P_("Read %lu line (Warning: No write permission)", statusbar(P_("Read %lu line (Warning: No write permission)",
"Read %lu lines (Warning: No write permission)", "Read %lu lines (Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines); (unsigned long)num_lines), (unsigned long)num_lines);
if (ISSET(MAKE_IT_UNIX))
openfile->fmt = NIX_FILE;
} }
/* Open the file (and decide if it exists). If newfie is TRUE, display /* Open the file (and decide if it exists). If newfie is TRUE, display

View File

@ -2168,6 +2168,7 @@ int main(int argc, char **argv)
{"speller", 1, NULL, 's'}, {"speller", 1, NULL, 's'},
#endif #endif
{"tempfile", 0, NULL, 't'}, {"tempfile", 0, NULL, 't'},
{"unix", 0, NULL, 'u'},
{"view", 0, NULL, 'v'}, {"view", 0, NULL, 'v'},
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
{"nowrap", 0, NULL, 'w'}, {"nowrap", 0, NULL, 'w'},
@ -2228,11 +2229,11 @@ int main(int argc, char **argv)
while ((optchr = while ((optchr =
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv, getopt_long(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$", "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL) long_options, NULL)
#else #else
getopt(argc, argv, getopt(argc, argv,
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$") "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
#endif #endif
) != -1) { ) != -1) {
switch (optchr) { switch (optchr) {
@ -2396,6 +2397,9 @@ int main(int argc, char **argv)
case 't': case 't':
SET(TEMP_FILE); SET(TEMP_FILE);
break; break;
case 'u':
SET(MAKE_IT_UNIX);
break;
case 'v': case 'v':
SET(VIEW_MODE); SET(VIEW_MODE);
break; break;

View File

@ -531,7 +531,8 @@ enum
SOFTWRAP, SOFTWRAP,
POS_HISTORY, POS_HISTORY,
LOCKING, LOCKING,
NOREAD_MODE NOREAD_MODE,
MAKE_IT_UNIX
}; };
/* Flags for the menus in which a given function should be present. */ /* Flags for the menus in which a given function should be present. */

View File

@ -82,6 +82,7 @@ static const rcoption rcopts[] = {
{"suspend", SUSPEND}, {"suspend", SUSPEND},
{"tabsize", 0}, {"tabsize", 0},
{"tempfile", TEMP_FILE}, {"tempfile", TEMP_FILE},
{"unix", MAKE_IT_UNIX},
{"view", VIEW_MODE}, {"view", VIEW_MODE},
#ifndef NANO_TINY #ifndef NANO_TINY
{"allow_insecure_backup", INSECURE_BACKUP}, {"allow_insecure_backup", INSECURE_BACKUP},