commit 70cbbda87cbd19972fd79ec23e5ff4f908d8746f
parent 95e1f55574fa3b809f349bece413cb8b36d7adfd
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 4 Aug 2015 18:49:57 +0000
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
Diffstat:
9 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -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>
* src/rcfile.c (parse_binding): Check the value of shortcut->toggle
only if it actually is a toggle. Found with valgrind.
diff --git a/doc/man/nano.1 b/doc/man/nano.1
@@ -222,6 +222,11 @@ Use this alternative spell checker command.
Always save a changed buffer without prompting. Same as Pico's \fB\-t\fP
option.
.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
View-file (read-only) mode.
.TP
diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5
@@ -242,6 +242,11 @@ Valid color names for foreground and background are:
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
.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
Disallow file modification.
.TP
diff --git 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|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 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:]]*$"
diff --git a/doc/texinfo/nano.texi b/doc/texinfo/nano.texi
@@ -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
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
@itemx --view
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.
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
Disallow file modification.
diff --git a/src/files.c b/src/files.c
@@ -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)",
"Read %lu lines (Warning: No write permission)",
(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
diff --git a/src/nano.c b/src/nano.c
@@ -2168,6 +2168,7 @@ int main(int argc, char **argv)
{"speller", 1, NULL, 's'},
#endif
{"tempfile", 0, NULL, 't'},
+ {"unix", 0, NULL, 'u'},
{"view", 0, NULL, 'v'},
#ifndef DISABLE_WRAPPING
{"nowrap", 0, NULL, 'w'},
@@ -2228,11 +2229,11 @@ int main(int argc, char **argv)
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
- "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$",
+ "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL)
#else
getopt(argc, argv,
- "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$")
+ "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
#endif
) != -1) {
switch (optchr) {
@@ -2396,6 +2397,9 @@ int main(int argc, char **argv)
case 't':
SET(TEMP_FILE);
break;
+ case 'u':
+ SET(MAKE_IT_UNIX);
+ break;
case 'v':
SET(VIEW_MODE);
break;
diff --git a/src/nano.h b/src/nano.h
@@ -531,7 +531,8 @@ enum
SOFTWRAP,
POS_HISTORY,
LOCKING,
- NOREAD_MODE
+ NOREAD_MODE,
+ MAKE_IT_UNIX
};
/* Flags for the menus in which a given function should be present. */
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -82,6 +82,7 @@ static const rcoption rcopts[] = {
{"suspend", SUSPEND},
{"tabsize", 0},
{"tempfile", TEMP_FILE},
+ {"unix", MAKE_IT_UNIX},
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"allow_insecure_backup", INSECURE_BACKUP},