diff --git a/ChangeLog b/ChangeLog
index cfb470121546848562f299b8bb7d12e30c8e702f..9ab2643a6e623869ad7cf11fa29fe2af2a05c90f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -101,6 +101,9 @@ CVS code -
 	  "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
@@ -374,6 +377,7 @@ CVS code -
 	- 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)
diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5
index 69a2e015c09b3d91ef25be40d46c8c23d80bdcbb..dcbee33ee61efd7d2af2683cf6e344e482fd1129 100644
--- a/doc/man/nanorc.5
+++ b/doc/man/nanorc.5
@@ -50,6 +50,10 @@ Create backup files in
 \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.
@@ -90,6 +94,11 @@ feature is turned off.
 \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,
diff --git a/doc/nanorc.sample b/doc/nanorc.sample
index f7a79608388318c7dcbfaef7be0fb39d85091d3d..058223af17363876c31a42812151f2227ed0ef87 100644
--- a/doc/nanorc.sample
+++ b/doc/nanorc.sample
@@ -17,6 +17,12 @@
 ## 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
 
@@ -64,6 +70,12 @@
 ## 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:
@@ -219,7 +231,7 @@
 ## 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))?\>"
diff --git a/src/global.c b/src/global.c
index 465a65c7e427aef737f1060348c74765f4e9c377..9b0334b55fe5aa715f806584a19df5dc29537fcb 100644
--- a/src/global.c
+++ b/src/global.c
@@ -67,6 +67,11 @@ openfilestruct *open_files = NULL;	/* The list of open files */
 #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
diff --git a/src/nano.c b/src/nano.c
index 62bc130706f16aa4602b34cc735eaf62f18a112e..e8addff099f34f982ffd85aa416c18f244371ee9 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1902,8 +1902,6 @@ size_t indent_length(const char *line)
  * 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. */
@@ -3392,6 +3390,12 @@ int main(int argc, char *argv[])
 #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]*[|>:}#])+");
diff --git a/src/proto.h b/src/proto.h
index f4cf99bc4df33a59c3e44e94f581e9fc83cf4b83..e38ae6416821fe4dc7ef37b4244795cf489a4d09 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -47,6 +47,8 @@ extern int search_offscreen;
 extern int currslen;
 
 #ifndef DISABLE_JUSTIFY
+extern char *punct;
+extern char *brackets;
 extern char *quotestr;
 #endif
 
diff --git a/src/rcfile.c b/src/rcfile.c
index b30c62a826b70233f1303d120e41e0627b4d6474..0dbad5fb082460a889bbeb6e52a8c79c05973664 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -43,6 +43,9 @@ const static rcoption rcopts[] = {
     {"autoindent", AUTOINDENT},
     {"backup", BACKUP_FILE},
     {"backupdir", 0},
+#endif
+#ifndef DISABLE_JUSTIFY
+    {"brackets", 0},
 #endif
     {"const", CONSTUPDATE},
 #ifndef NANO_SMALL
@@ -73,6 +76,7 @@ const static rcoption rcopts[] = {
 #endif
     {"preserve", PRESERVE},
 #ifndef DISABLE_JUSTIFY
+    {"punct", 0},
     {"quotestr", 0},
 #endif
     {"rebinddelete", REBIND_DELETE},
@@ -152,12 +156,12 @@ char *parse_next_word(char *ptr)
 }
 
 /* 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;
@@ -545,6 +549,8 @@ void parse_rcfile(FILE *rcstream)
 				|| !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
@@ -589,9 +595,22 @@ void parse_rcfile(FILE *rcstream)
 			    } 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"))