diff -rup gedit-2.15.5-orig/configure.ac gedit-2.15.5/configure.ac
--- gedit-2.15.5-orig/configure.ac	2006-08-10 12:25:58.000000000 -0400
+++ gedit-2.15.5/configure.ac	2006-08-10 15:16:02.000000000 -0400
@@ -87,6 +87,12 @@ AC_SUBST(PSPELL_LIBS)
 
 
 dnl ================================================================
+dnl libattr checks
+dnl ================================================================
+
+AC_CHECK_LIB(attr, attr_copy_fd)
+
+dnl ================================================================
 dnl Start of pkg-config checks
 dnl ================================================================
 
Only in gedit-2.15.5: configure.ac.xattrs
diff -rup gedit-2.15.5-orig/gedit/gedit-document-saver.c gedit-2.15.5/gedit/gedit-document-saver.c
--- gedit-2.15.5-orig/gedit/gedit-document-saver.c	2006-05-18 18:55:16.000000000 -0400
+++ gedit-2.15.5/gedit/gedit-document-saver.c	2006-08-10 15:16:08.000000000 -0400
@@ -42,6 +42,12 @@
 #include <glib/gfileutils.h>
 #include <libgnomevfs/gnome-vfs.h>
 
+#ifdef HAVE_LIBATTR
+# include <attr/libattr.h>
+#else
+# define attr_copy_fd(x1, x2, x3, x4, x5, x6) (errno = ENOSYS, -1)
+#endif
+
 #include "gedit-document-saver.h"
 #include "gedit-debug.h"
 #include "gedit-convert.h"
@@ -457,6 +463,15 @@ get_slow_mime_type (const char *text_uri
 
 /* ----------- local files ----------- */
 
+#ifdef HAVE_LIBATTR
+static int all_xattrs(const char *xattr, struct error_context *err)
+{ /* Save everything: user/root xattrs, SELinux, ACLs. */
+  (void)xattr;
+  (void)err;
+  return 1;
+}
+#endif
+
 static gboolean
 save_existing_local_file (GeditDocumentSaver *saver)
 {
@@ -597,6 +612,22 @@ save_existing_local_file (GeditDocumentS
 			goto fallback_strategy;
 		}
 
+                /* copy the xattrs, like user.mime_type, over. Also ACLs and
+                   SELinux context. */
+                if ((attr_copy_fd (saver->priv->local_path, saver->priv->fd,
+                                   tmp_filename, tmpfd,
+                                   all_xattrs, NULL) == -1) &&
+                    (errno != EOPNOTSUPP) && (errno != ENOSYS))
+                {
+			gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
+
+			close (tmpfd);
+			unlink (tmp_filename);
+			g_free (tmp_filename);
+
+			goto fallback_strategy;
+                }
+
 		if (!write_document_contents (tmpfd,
 					      GTK_TEXT_BUFFER (saver->priv->document),
 			 	 	      saver->priv->encoding,
@@ -751,6 +782,18 @@ save_existing_local_file (GeditDocumentS
 			}
 		}
 
+                /* copy the xattrs, like user.mime_type, over. Also ACLs and
+                   SELinux context. */
+                if ((attr_copy_fd (saver->priv->local_path, saver->priv->fd,
+                                   backup_filename, bfd,
+                                   all_xattrs, NULL) == -1) &&
+                    (errno != EOPNOTSUPP) && (errno != ENOSYS))
+                {
+			gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
+
+			goto out; /* is it better to save or not save? */
+                }
+
 		if (!copy_file_data (saver->priv->fd, bfd, NULL))
 		{
 				gedit_debug_message (DEBUG_SAVER, "could not copy data into the backup");
Only in gedit-2.15.5/gedit: gedit-document-saver.c.xattrs
