do_page_down(), do_para_end(), do_next_word(), do_prev_word(),
do_up(), do_down(), do_scroll_down(), do_right(), do_mouse(),
do_gotolinecolumn(), do_delete(), and find_paragraph(). (DLR)
+ - Add new -L/--nonewlines command line option, and new
+ "nonewlines" rcfile option, to control whether nano adds
+ magiclines to the ends of files. Changes to read_file(),
+ write_marked_file(), move_to_filestruct(),
+ copy_from_filestruct(), usage(), do_output(), main(),
+ do_replace_loop(), do_delete(), nano.1, nanorc.5, nano.texi,
+ and nanorc.sample. (DLR, suggested by re2823@Safe-mail.net)
- files.c:
read_file()
- Remove apparently unneeded logic to handle a case where
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
-.TH NANO 1 "version 1.3.9" "September 27, 2005"
+.TH NANO 1 "version 1.3.9" "November 5, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
.TP
+.B \-L (\-\-nonewlines)
+Don't add newlines to the ends of files.
+.TP
.B \-N (\-\-noconvert)
Disable automatic conversion of files from DOS/Mac format.
.TP
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
-.TH NANORC 5 "version 1.3.9" "September 27, 2005"
+.TH NANORC 5 "version 1.3.9" "November 5, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
.B set/unset nohelp
Don't display the help lists at the bottom of the screen.
.TP
+.B set/unset nonewlines
+Don't add newlines to the ends of files.
+.TP
.B set/unset nowrap
Don't wrap text at all.
.TP
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
+## Don't add newlines to the ends of files.
+# set nonewlines
+
## Don't wrap text at all.
# set nowrap
## 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|wordbounds)\>"
+# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct|quickblank)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quotestr|rebinddelete|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))?\>"
@smallbook
@set EDITION 0.1
@set VERSION 1.3.9
-@set UPDATED 04 Nov 2005
+@set UPDATED 05 Nov 2005
@dircategory Editors
@direntry
should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
+@item -L, --nonewlines
+Don't add newlines to the ends of files.
+
@item -N, --noconvert
Don't convert files from DOS/Mac format.
openfile->totsize += get_totsize(openfile->fileage,
openfile->filebot);
- /* If text has been added to the magicline (i.e, a file that doesn't
- * end in a newline has been inserted at the end of the current
- * buffer), add a new magicline, and move the current line down to
- * it. */
- if (openfile->filebot->data[0] != '\0') {
+ /* If the NO_NEWLINES flag isn't set, and text has been added to
+ * the magicline (i.e, a file that doesn't end in a newline has been
+ * inserted at the end of the current buffer), add a new magicline,
+ * and move the current line down to it. */
+ if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') {
new_magicline();
openfile->current = openfile->filebot;
openfile->current_x = 0;
int retval = -1;
bool old_modified = openfile->modified;
/* write_file() unsets the modified flag. */
- bool added_magicline;
+ bool added_magicline = FALSE;
/* Whether we added a magicline after filebot. */
filestruct *top, *bot;
size_t top_x, bot_x;
(const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
- /* If the line at filebot is blank, treat it as the magicline and
- * hence the end of the file. Otherwise, add a magicline and treat
- * it as the end of the file. */
- if ((added_magicline = (openfile->filebot->data[0] != '\0')))
+ /* Handle the magicline if the NO_NEWLINES flag isn't set. If the
+ * line at filebot is blank, treat it as the magicline and hence the
+ * end of the file. Otherwise, add a magicline and treat it as the
+ * end of the file. */
+ if (!ISSET(NO_NEWLINES) &&
+ (added_magicline = (openfile->filebot->data[0] != '\0')))
new_magicline();
retval = write_file(name, f_open, tmp, append, TRUE);
- /* If we added a magicline, remove it now. */
- if (added_magicline)
+ /* If the NO_NEWLINES flag isn't set, and we added a magicline,
+ * remove it now. */
+ if (!ISSET(NO_NEWLINES) && added_magicline)
remove_magicline();
/* Unpartition the filestruct so that it contains all the text
* partition. */
renumber(top_save);
- /* If the text doesn't end with a magicline, add a new magicline. */
- if (openfile->filebot->data[0] != '\0')
+ /* If the NO_NEWLINES flag isn't set, and the text doesn't end with
+ * a magicline, add a new magicline. */
+ if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
* partition. */
renumber(top_save);
- /* If the text doesn't end with a magicline, add a new magicline. */
- if (openfile->filebot->data[0] != '\0')
+ /* If the NO_NEWLINES flag isn't set, and the text doesn't end with
+ * a magicline, add a new magicline. */
+ if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
#endif
print1opt("-K", "--rebindkeypad",
N_("Fix numeric keypad key confusion problem"));
+ print1opt("-L", "--nonewlines",
+ N_("Don't add newlines to the ends of files"));
#ifndef NANO_SMALL
print1opt("-N", "--noconvert",
N_("Don't convert files from DOS/Mac format"));
if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len))
continue;
- /* When a character is inserted on the current magicline, it
- * means we need a new one! */
- if (openfile->filebot == openfile->current)
+ /* If the NO_NEWLINES flag isn't set, when a character is
+ * added to the magicline, it means we need a new magicline! */
+ if (!ISSET(NO_NEWLINES) && openfile->filebot ==
+ openfile->current)
new_magicline();
/* More dangerousness fun =) */
{"ignorercfiles", 0, NULL, 'I'},
#endif
{"rebindkeypad", 0, NULL, 'K'},
+ {"nonewlines", 0, NULL, 'L'},
{"morespace", 0, NULL, 'O'},
#ifndef DISABLE_JUSTIFY
{"quotestr", 1, NULL, 'Q'},
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
- "h?ABC:EFHIKNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
+ "h?ABC:EFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
long_options, NULL)
#else
getopt(argc, argv,
- "h?ABC:EFHIKNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
+ "h?ABC:EFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
#endif
) != -1) {
switch (optchr) {
case 'K':
SET(REBIND_KEYPAD);
break;
+ case 'L':
+ SET(NO_NEWLINES);
+ break;
#ifndef NANO_SMALL
case 'N':
SET(NO_CONVERT);
#define TABS_TO_SPACES (1<<27)
#define QUICK_BLANK (1<<28)
#define WORD_BOUNDS (1<<29)
-#define USE_UTF8 (1<<30)
+#define NO_NEWLINES (1<<30)
+#define USE_UTF8 (1<<31)
/* Control key sequences. Changing these would be very, very bad. */
#define NANO_CONTROL_SPACE 0
{"morespace", MORE_SPACE},
{"nofollow", NOFOLLOW_SYMLINKS},
{"nohelp", NO_HELP},
+ {"nonewlines", NO_NEWLINES},
#ifndef DISABLE_WRAPPING
{"nowrap", NO_WRAP},
#endif
}
#endif
- /* If text has been added to the magicline, make a new magicline. */
- if (openfile->filebot->data[0] != '\0')
+ /* If the NO_NEWLINES flag isn't set, and text has been added to the
+ * magicline, make a new magicline. */
+ if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
return numreplaced;
wrap_reset();
#endif
- /* If text has been added to the magicline as a result of
- * deleting at the end of the line before filebot, add a new
- * magicline. */
- if (openfile->current == openfile->filebot &&
- openfile->current->data[0] != '\0')
+ /* If the NO_NEWLINES flag isn't set, and text has been added to
+ * the magicline as a result of deleting at the end of the line
+ * before filebot, add a new magicline. */
+ if (!ISSET(NO_NEWLINES) && openfile->current ==
+ openfile->filebot && openfile->current->data[0] != '\0')
new_magicline();
} else
return;