diff --git a/src/text.c b/src/text.c
index 7fc582081461d6827688039cb7b613cf3b456b1d..10415d7ae2a4d9b77247cfe3a1102c7cb2de242a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1140,7 +1140,9 @@ bool execute_command(const char *command)
 void discard_until(const undo *thisitem, openfilestruct *thefile)
 {
     undo *dropit = thefile->undotop;
+#ifdef ENABLE_COMMENT
     undo_group *group;
+#endif
 
     while (dropit != NULL && dropit != thisitem) {
 	thefile->undotop = dropit->next;