diff --git a/ChangeLog b/ChangeLog
index ae6b507d77f899b807948b38c6bac25741e13514..dd13ca30647ad36606d972d89f4361dcc5af8df2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
 	Use the now correct parsing of header regexes also for parsing magic
 	regexes.  This fixes Savannah bug #47292 and saves 50 lines of code.
 	* src/rcfile.c (grab_and_store): Rename a variable and densify.
+	* src/rcfile.c (grab_and_store): Do not drop regexes that were
+	gathered earlier.  This fixes Savannah bug #47285.
 
 2016-02-26  Benno Schulenberg  <bensberg@justemail.net>
 	* doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc,
diff --git a/src/rcfile.c b/src/rcfile.c
index 073615e5a6054f3f40e71a2da7facd75a29fbe98..fd747c60f0b5715807e3229cf508e65c2b6ec42a 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -860,7 +860,7 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
  * by ptr, and store them quoteless in the passed storage place. */
 void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
 {
-    regexlisttype *lastthing = NULL;
+    regexlisttype *lastthing;
 
     if (syntaxes == NULL) {
 	rcfile_error(
@@ -873,6 +873,12 @@ void grab_and_store(char *ptr, const char *kind, regexlisttype **storage)
 	return;
     }
 
+    lastthing = *storage;
+
+    /* If there was an earlier command, go to the last of those regexes. */
+    while (lastthing != NULL && lastthing->next != NULL)
+	lastthing = lastthing->next;
+
     /* Now load the regexes into their part of the struct. */
     while (*ptr != '\0') {
 	const char *regexstring;