"whitespace". This is disabled if nanorc support is disabled
or if we're in tiny mode. (Mike Frysinger; minor changes and
adaptations by DLR)
+ - Add the ability to change the closing punctuation and closing
+ brackets used to control justification, via the rcfile
+ entries "punct" and "brackets". (DLR)
- files.c:
add_open_file()
- Rearrange the NANO_SMALL #ifdef so that the code to set the
- Document the smart home key option. (DLR)
- Document the whitespace option. (DLR, adapted from
documentation by Mike Frysinger)
+ - Document the punct and brackets options. (DLR)
- nano.texi:
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
Meta-< and Meta-> aren't toggles. (DLR)
\fBset backupdir "\fIdirectory\fP"\fP
Set the directory where \fBnano\fP puts the backup files if file backups
are enabled.
+\fBset brackets "\fIstring\fP"\fP
+Set the characters treated as closing brackets. They cannot contain
+tabs or spaces. Only closing punctuation, optionally followed by
+closing brackets, can end sentences.
.TP
\fBset/unset const\fP
Constantly display the cursor position in the status bar.
\fBset/unset preserve\fP
Preserve the XON and XOFF keys (^Q and ^S).
.TP
+\fBset punct "\fIstring\fP"\fP
+Set the characters treated as closing punctuation. They cannot contain
+tabs or spaces. Only closing punctuation, optionally followed by
+closing brackets, can end sentences.
+.TP
\fBset quotestr "\fIstring\fP"\fP
The email-quote string, used to justify email-quoted paragraphs. This
is an "extended regular expression" if your system supports them,
## The directory to put the backup files in.
# set backupdir ""
+## The characters treated as closing brackets. They cannot contain tabs
+## or spaces. Only closing punctuation, optionally followed by closing
+## brackets, can end sentences.
+##
+# set brackets "'")}]>"
+
## Constantly display the cursor position in the status bar.
# set const
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
+## The characters treated as closing punctuation. They cannot contain
+## tabs or spaces. Only closing punctuation, optionally followed by
+## closing brackets, can end sentences.
+##
+# set punct ".?!"
+
## The email-quote string, used to justify email-quoted paragraphs.
## This is an extended regular expression if your system supports them,
## otherwise a literal string. Default:
## highlight possible errors and parameters
#color brightwhite "^ *(set|unset|syntax|color).*$"
## set, unset and syntax
-#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
+#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|brackets|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
#color green "^ *(set|unset|syntax)\>"
## colors
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
#endif
#ifndef DISABLE_JUSTIFY
+char *punct = NULL; /* Closing punctuation that can end
+ sentences. */
+char *brackets = NULL; /* Closing brackets that can follow
+ closing punctuation and can end
+ sentences. */
char *quotestr = NULL; /* Quote string. The default value is
set in main(). */
#endif
* line[skip + 1] must not be whitespace. */
void justify_format(filestruct *line, size_t skip)
{
- const char *punct = ".?!";
- const char *brackets = "'\")}]>";
char *back, *front;
/* These four asserts are assumptions about the input data. */
#endif
#ifndef DISABLE_JUSTIFY
+ if (punct == NULL)
+ punct = mallocstrcpy(punct, ".?!");
+
+ if (brackets == NULL)
+ brackets = mallocstrcpy(brackets, "'\")}]>");
+
if (quotestr == NULL)
#ifdef HAVE_REGEX_H
quotestr = mallocstrcpy(NULL, "^([ \t]*[|>:}#])+");
extern int currslen;
#ifndef DISABLE_JUSTIFY
+extern char *punct;
+extern char *brackets;
extern char *quotestr;
#endif
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backupdir", 0},
+#endif
+#ifndef DISABLE_JUSTIFY
+ {"brackets", 0},
#endif
{"const", CONSTUPDATE},
#ifndef NANO_SMALL
#endif
{"preserve", PRESERVE},
#ifndef DISABLE_JUSTIFY
+ {"punct", 0},
{"quotestr", 0},
#endif
{"rebinddelete", REBIND_DELETE},
}
/* The keywords operatingdir, backupdir, fill, tabsize, speller,
- * quotestr, and whitespace take an argument when set. Among these,
- * operatingdir, backupdir, speller, quotestr, and whitespace have to
- * allow tabs and spaces in the argument. Thus, if the next word starts
- * with a ", we say it ends with the last " of the line. Otherwise, the
- * word is interpreted as usual. That is so the arguments can contain
- * "s too. */
+ * punct, brackets, quotestr, and whitespace take an argument when set.
+ * Among these, operatingdir, backupdir, speller, punct, brackets,
+ * quotestr, and whitespace have to allow tabs and spaces in the
+ * argument. Thus, if the next word starts with a ", we say it ends
+ * with the last " of the line. Otherwise, the word is interpreted as
+ * usual. That is so the arguments can contain "s too. */
char *parse_argument(char *ptr)
{
const char *ptr_bak = ptr;
|| !strcasecmp(rcopts[i].name, "fill")
#endif
#ifndef DISABLE_JUSTIFY
+ || !strcasecmp(rcopts[i].name, "punct")
+ || !strcasecmp(rcopts[i].name, "brackets")
|| !strcasecmp(rcopts[i].name, "quotestr")
#endif
#ifndef NANO_SMALL
} else
#endif
#ifndef DISABLE_JUSTIFY
- if (!strcasecmp(rcopts[i].name, "quotestr"))
+ if (!strcasecmp(rcopts[i].name, "punct")) {
+ punct = mallocstrcpy(NULL, option);
+ if (strchr(punct, '\t') != NULL || strchr(punct, ' ') != NULL) {
+ rcfile_error(_("Non-tab and non-space characters required"));
+ free(punct);
+ punct = NULL;
+ }
+ } else if (!strcasecmp(rcopts[i].name, "brackets")) {
+ brackets = mallocstrcpy(NULL, option);
+ if (strchr(brackets, '\t') != NULL || strchr(brackets, ' ') != NULL) {
+ rcfile_error(_("Non-tab and non-space characters required"));
+ free(brackets);
+ brackets = NULL;
+ }
+ } else if (!strcasecmp(rcopts[i].name, "quotestr"))
quotestr = mallocstrcpy(NULL, option);
- else
#endif
#ifndef NANO_SMALL
if (!strcasecmp(rcopts[i].name, "backupdir"))