Index: src/nautilus-window-private.h
===================================================================
--- src/nautilus-window-private.h	(revisione 13853)
+++ src/nautilus-window-private.h	(copia locale)
@@ -101,6 +101,7 @@ struct NautilusWindowDetails
 
         NautilusWindowShowHiddenFilesMode show_hidden_files_mode;
         gboolean search_mode;
+        gboolean key_theme_is_emacs;
 
         GCancellable *find_mount_cancellable;
 };
Index: src/nautilus-window.c
===================================================================
--- src/nautilus-window.c	(revisione 13853)
+++ src/nautilus-window.c	(copia locale)
@@ -79,6 +79,7 @@
 #define MAX_HISTORY_ITEMS 50
 
 #define EXTRA_VIEW_WIDGETS_BACKGROUND "#a7c6e1"
+#define SETTINGS_CONNECTION_DATA_KEY	"NautilusWindowSettings"
 
 /* FIXME bugzilla.gnome.org 41245: hardwired sizes */
 #define SIDE_PANE_MINIMUM_WIDTH 1
@@ -525,6 +526,42 @@ nautilus_window_set_initial_window_geome
 				          max_height_for_screen));
 }
 
+static void
+settings_change_notify (GtkSettings *settings,
+			NautilusWindow  *window)
+{
+	NautilusWindowDetails *details = window->details;
+	char *key_theme_name;
+
+	g_object_get (settings,
+		      "gtk-key-theme-name", &key_theme_name,
+		      NULL);
+
+	details->key_theme_is_emacs =
+		key_theme_name &&
+		g_ascii_strcasecmp (key_theme_name, "Emacs") == 0;
+
+	g_free (key_theme_name);
+}
+
+static void
+settings_changed_cb (GtkSettings *settings)
+{
+	GList *list, *l;
+
+	list = gtk_window_list_toplevels ();
+
+	for (l = list; l != NULL; l = l->next)
+	{
+		if (NAUTILUS_IS_WINDOW (l->data))
+		{
+			settings_change_notify (settings, l->data);
+		}
+	}
+
+	g_list_free (list);
+}
+
 void
 nautilus_window_constructed (NautilusWindow *window)
 {
@@ -653,6 +690,8 @@ nautilus_window_constructor (GType type,
 			     GObjectConstructParam *construct_params)
 {
 	GObject *object;
+	GtkSettings *settings;
+	guint settings_connection;
 	NautilusWindow *window;
 
 	object = (* G_OBJECT_CLASS (nautilus_window_parent_class)->constructor) (type,
@@ -660,6 +699,23 @@ nautilus_window_constructor (GType type,
 										 construct_params);
 
 	window = NAUTILUS_WINDOW (object);
+	
+	/* Initialize the listener for the key theme
+	 */
+	settings = gtk_settings_get_default ();
+	settings_connection = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (settings),
+								   SETTINGS_CONNECTION_DATA_KEY));
+	if (settings_connection == 0)
+	{
+		settings_connection =
+			g_signal_connect (settings, "notify::gtk-key-theme-name",
+					  G_CALLBACK (settings_changed_cb), NULL);
+		g_object_set_data (G_OBJECT (settings), SETTINGS_CONNECTION_DATA_KEY,
+				   GUINT_TO_POINTER (settings_connection));
+
+	}
+
+	settings_change_notify (settings, window);
 
 	nautilus_window_initialize_menus_constructed (window);
 
@@ -749,9 +805,15 @@ nautilus_window_key_press_event (GtkWidg
 				 GdkEventKey *event)
 {
 	NautilusWindow *window;
+	NautilusWindowDetails *details;
+	gboolean shortcircuit, handled, force_chain;
+	guint modifier;
 	int i;
 
 	window = NAUTILUS_WINDOW (widget);
+	details = window->details;
+	modifier = event->state & gtk_accelerator_get_default_mod_mask ();
+	shortcircuit = handled = force_chain = FALSE;
 
 	for (i = 0; i < G_N_ELEMENTS (extra_window_keybindings); i++) {
 		if (extra_window_keybindings[i].keyval == event->keyval) {
@@ -775,6 +837,36 @@ nautilus_window_key_press_event (GtkWidg
 			break;
 		}
 	}
+	
+	/* This snippet is copied from Epiphany, and allows us to properly handle
+	 * widgets keybindings when in Emacs mode. See ephy-window.c key-press-event
+	 * handler and http://bugzilla.gnome.org/show_bug.cgi?id=314431.
+	 */
+	
+	if (event->keyval == GDK_Escape && modifier == 0) {
+		/* Always pass Escape to both the widget, and the parent */
+		shortcircuit = TRUE;
+		force_chain = TRUE;
+	} else if (details->key_theme_is_emacs && 
+		   (modifier == GDK_CONTROL_MASK) &&
+		   event->length > 0) {
+		/* Pass CTRL+letter characters to the widget */
+		shortcircuit = TRUE;
+	}
+
+	if (shortcircuit) {
+		GtkWidget *focus_widget;
+		focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+		if (GTK_IS_WIDGET (focus_widget)) {
+			handled = gtk_widget_event (focus_widget,
+						    (GdkEvent*) event);
+		}
+
+		if (handled && !force_chain) {
+			return handled;
+		}
+	}
 
 	return GTK_WIDGET_CLASS (nautilus_window_parent_class)->key_press_event (widget, event);
 }
