Index: Padre/lib/Padre/Wx/Main.pm
===================================================================
--- Padre/lib/Padre/Wx/Main.pm	(revision 7222)
+++ Padre/lib/Padre/Wx/Main.pm	(working copy)
@@ -4312,7 +4312,9 @@
 
 	if ( $editor->insert_from_file($file) ) {
 		my $document = $editor->{Document};
-		$document->set_mimetype( Padre::MimeTypes->mime_type_by_extension($extension) );
+		my $mime_type = Padre::MimeTypes->mime_type_by_extension($extension);
+		$mime_type = $mime_type->() if ref($mime_type) eq 'CODE'; # call sub if needed
+		$document->set_mimetype( $mime_type );
 		$document->editor->padre_setup;
 		$document->rebless;
 	} else {
