diff --git a/ChangeLog b/ChangeLog
index 8ac2543cd4dc8b42589ee29aae0b55234766d333..b56268c98d38526be4704ff83e46a1bf11774f05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@ Current CVS:
 - nano.c:
   main():
 	- TABSIZE now set before first call to edit_refresh (Bill Soudan)
+  die():
+	- More intelligent emergency-save filename selection (Rob)
 - search.c:
   search_init():
 	- Added " (to replace)" statement to end of search string if 
diff --git a/nano.c b/nano.c
index d0b414775db470d8c46bf69cca1a052078fa3599..c02ba86ec1f78848747c8b6072ef9bb5588142a6 100644
--- a/nano.c
+++ b/nano.c
@@ -94,10 +94,15 @@ void die(char *msg, ...)
     va_end(ap);
 
     /* if we can't save we have REAL bad problems,
-     * but we might as well TRY.  FIXME: This should probabally base it
-     * off of the current filename */
-    write_file("nano.save", 0);
-
+     * but we might as well TRY. */
+    if(filename[0] == '\0') {
+	write_file("nano.save", 0);
+    } else {
+	char buf[BUFSIZ];
+	strncpy(buf,filename,BUFSIZ);
+	strncat(buf,".save",BUFSIZ - strlen(buf));
+	write_file(buf, 0);
+    }
     /* Restore the old term settings */
     tcsetattr(0, TCSANOW, &oldterm);