diff --git a/srcpkgs/emacs-gtk3 b/srcpkgs/emacs-gtk3
new file mode 120000
index 0000000000..a7642dd168
--- /dev/null
+++ b/srcpkgs/emacs-gtk3
@@ -0,0 +1 @@
+emacs
\ No newline at end of file
diff --git a/srcpkgs/emacs/files/musl.patch b/srcpkgs/emacs/files/musl.patch
new file mode 100644
index 0000000000..a541a7b064
--- /dev/null
+++ b/srcpkgs/emacs/files/musl.patch
@@ -0,0 +1,87 @@
+--- configure
++++ configure
+@@ -2092,7 +2092,7 @@
+ 
+ system_malloc=$emacs_cv_sanitize_address
+ 
+-hybrid_malloc=
++hybrid_malloc=yes
+ 
+ case "$opsys" in
+   ## darwin ld insists on the use of malloc routines in the System framework.
+--- src/Makefile.in
++++ src/Makefile.in
+@@ -373,6 +373,7 @@
+ 	region-cache.o sound.o atimer.o \
+ 	doprnt.o intervals.o textprop.o composite.o xml.o $(NOTIFY_OBJ) \
+ 	profiler.o decompress.o \
++	sheap.o \
+ 	$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
+ 	$(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ)
+ obj = $(base_obj) $(NS_OBJC_OBJ)
+--- src/gmalloc.c
++++ src/gmalloc.c
+@@ -72,7 +72,7 @@
+ #define free gfree
+ #endif  /* HYBRID_MALLOC */
+ 
+-#ifdef CYGWIN
++//#ifdef CYGWIN
+ extern void *bss_sbrk (ptrdiff_t size);
+ extern int bss_sbrk_did_unexec;
+ extern char bss_sbrk_buffer[];
+@@ -80,7 +80,7 @@
+ #define DUMPED bss_sbrk_did_unexec
+ #define ALLOCATED_BEFORE_DUMPING(P) \
+   ((P) < bss_sbrk_buffer_end && (P) >= (void *) bss_sbrk_buffer)
+-#endif
++//#endif
+ 
+ #ifdef	__cplusplus
+ extern "C"
+@@ -1525,16 +1525,19 @@
+ __default_morecore (ptrdiff_t increment)
+ {
+   void *result;
+-#if defined (CYGWIN)
++//#if defined (CYGWIN)
+   if (!DUMPED)
+     {
+       return bss_sbrk (increment);
+     }
+-#endif
++//#endif
++#if 0
+   result = (void *) __sbrk (increment);
+   if (result == (void *) -1)
+     return NULL;
+   return result;
++#endif
++  return NULL;
+ }
+ /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+ 
+--- src/print.c
++++ src/print.c
+@@ -755,7 +755,7 @@
+   print_output_debug_flag = x;
+ }
+ 
+-#if defined (GNU_LINUX)
++#if defined (GNU_LINUX) && defined (__GLIBC__)
+ 
+ /* This functionality is not vitally important in general, so we rely on
+    non-portable ability to use stderr as lvalue.  */
+--- src/unexelf.c
++++ src/unexelf.c
+@@ -632,6 +632,9 @@
+   off_t new_file_size;
+   void *new_break;
+ 
++  extern int bss_sbrk_did_unexec;
++  bss_sbrk_did_unexec = 1;
++
+   /* Pointers to the base of the image of the two files.  */
+   caddr_t old_base, new_base;
+ 
+
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 68e8b6add8..73ec3a531b 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -1,11 +1,12 @@
 # Template file for 'emacs'
 pkgname=emacs
-version=24.5
+version=25.1
 revision=1
 nocross=yes
 nopie=yes
 hostmakedepends="pkg-config"
-makedepends="ncurses-devel libXaw-devel gtk+-devel $(vopt_if dbus dbus-devel)
+makedepends="ncurses-devel libXaw-devel gtk+-devel gtk+3-devel webkitgtk-devel
+$(vopt_if dbus dbus-devel)
 $(vopt_if jpeg libjpeg-turbo-devel) $(vopt_if tiff tiff-devel)
 $(vopt_if gif giflib-devel) $(vopt_if png libpng-devel) $(vopt_if xpm libXpm-devel)
 $(vopt_if svg librsvg-devel) $(vopt_if imagemagick libmagick-devel)
@@ -23,7 +24,7 @@ maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
 license="GPL-3"
 homepage="http://www.gnu.org/software/${pkgname}/"
 distfiles="${GNU_SITE}/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=dd47d71dd2a526cf6b47cb49af793ec2e26af69a0951cc40e43ae290eacfc34e
+checksum=19f2798ee3bc26c95dca3303e7ab141e7ad65d6ea2b6945eeba4dbea7df48f33
 
 # Package build options
 build_options="dbus jpeg tiff gif png xpm svg xml imagemagick gnutls sound"
@@ -31,6 +32,12 @@ desc_option_xpm="Enable support for XPM images"
 desc_option_sound="Enable support for sound"
 build_options_default="jpeg tiff gif png xpm svg xml gnutls sound"
 
+post_extract() {
+	case "$XBPS_TARGET_MACHINE" in
+		*-musl) patch -p0 <${FILESDIR}/musl.patch
+	esac
+}
+
 pre_configure() {
 	# Just configuring in different directories results in
 	# spurious emacs rebuilds with incompatible build numbers.
@@ -38,6 +45,7 @@ pre_configure() {
 	mv * nox || true
 	cp -a nox x11
 	cp -a nox gtk2
+	cp -a nox gtk3
 }
 
 do_configure() {
@@ -49,12 +57,16 @@ do_configure() {
 
 	cd $wrksrc/gtk2
 	./configure --with-x-toolkit=gtk2 ${configure_args}
+
+	cd $wrksrc/gtk3
+	./configure --with-x-toolkit=gtk3 --with-xwidgets ${configure_args}
 }
 
 do_build() {
 	make ${makejobs} -C nox
 	make ${makejobs} -C x11
 	make ${makejobs} -C gtk2
+	make ${makejobs} -C gtk3
 }
 
 do_install() {
@@ -103,3 +115,16 @@ emacs-gtk2_package() {
 		rm -rf ${PKGDESTDIR}/var/games/emacs
 	}
 }
+
+emacs-gtk3_package() {
+	depends="emacs-common-${version}_${revision} desktop-file-utils hicolor-icon-theme"
+	provides="emacs-${version}_${revision}"
+	replaces="emacs>=0"
+	short_desc+=" - GTK+3 version"
+	pkg_install() {
+		make DESTDIR=${PKGDESTDIR} -C ${wrksrc}/gtk3 install
+		rm -f ${PKGDESTDIR}/usr/bin/ctags
+		rm -rf ${PKGDESTDIR}/usr/share/{emacs,man,info}
+		rm -rf ${PKGDESTDIR}/var/games/emacs
+	}
+}