Index: /trunk/dports/aqua/emacs-mac-app/Portfile
===================================================================
--- /trunk/dports/aqua/emacs-mac-app/Portfile	(revision 98848)
+++ /trunk/dports/aqua/emacs-mac-app/Portfile	(revision 98848)
@@ -0,0 +1,92 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id$
+
+PortSystem          1.0
+
+name                emacs-mac-app
+version             3.2
+categories          aqua editors
+maintainers         hum openmaintainer
+
+description         Emacs Mac port
+
+long_description    ${name} is "Mac port" addition to GNU Emacs 24. This provides a native \
+                    GUI support for Mac OS X 10.4 - 10.8.
+
+homepage            http://www.gnu.org/software/emacs/
+platforms           darwin
+license             GPL-3+
+
+set emacs_version   24.2
+distname            emacs-${emacs_version}
+dist_subdir         emacs
+
+set mac_distname    emacs-${emacs_version}-mac-${version}
+set mac_distfile    ${mac_distname}${extract.suffix}
+distfiles-append    ${mac_distfile}:mac
+
+master_sites        gnu:emacs \
+                    ftp://ftp.math.s.chiba-u.ac.jp/emacs/:mac
+
+checksums           ${distname}${extract.suffix} \
+                    rmd160  26f6c2b671ed7f160875d62e47c89afec085110f \
+                    sha256  6d9892dff6e1761d4a5eba20712beba4f37d77a196f8021081a2e69fcb5bd357 \
+                    ${mac_distfile} \
+                    rmd160  b04dd09365007a6db16d32df16cf2c29c2b08b5c \
+                    sha256  5a887718c4576f74c26817d473ad6a6e37ceeb72056a7941cce9a689eb21b965
+
+conflicts           emacs emacs22 emacs23 emacs-snapshot xemacs emacs-app emacs-app-devel
+
+depends_lib         port:ncurses
+
+patchfiles          patch-src_emacs.c.diff
+
+set mac_path        ${workpath}/${mac_distname}
+
+post-extract {
+    # merge mac port files into emacs distribution.
+    copy ${mac_path}/mac ${worksrcpath}
+    copy ${worksrcpath}/nextstep/Cocoa/Emacs.base/Contents/Resources/Emacs.icns \
+         ${worksrcpath}/mac/Emacs.app/Contents/Resources/Emacs.icns
+    foreach f [glob ${mac_path}/etc/images/*] {
+        copy ${f} ${worksrcpath}/etc/images
+    }
+    foreach f [glob ${mac_path}/src/*] {
+        copy ${f} ${worksrcpath}/src
+    }
+    copy ${mac_path}/lisp/term/mac-win.el ${worksrcpath}/lisp/term
+}
+
+post-patch {
+    # postprocess for patch-src_emacs.c.diff.
+    reinplace "s|__PREFIX__|${prefix}|" ${worksrcpath}/src/emacs.c
+    # apply mac port patch.
+    system -W ${worksrcpath} "patch -p 0 < ${mac_path}/patch-mac"
+}
+
+universal_variant   no
+
+configure.args      --with-mac \
+                    --enable-mac-app=${applications_dir} \
+                    --prefix=${prefix}
+
+if {${os.major} >= 11 && ${os.platform} == "darwin"} {
+    configure.cflags-append -fobjc-arc
+}
+
+post-destroot {
+    # install additional documents.
+    xinstall -d ${destroot}${prefix}/share/doc/${name}
+    xinstall -m 644 -W ${mac_path} \
+        COPYING NEWS-mac README-mac \
+        ${destroot}${prefix}/share/doc/${name}
+    # install site-start.el.
+    file copy ${filespath}/site-start.el \
+        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp
+    reinplace "s|__PREFIX__|${prefix}|g" \
+        ${destroot}${applications_dir}/Emacs.app/Contents/Resources/site-lisp/site-start.el
+}
+
+livecheck.type      regex
+livecheck.url       ftp://ftp.math.s.chiba-u.ac.jp/emacs/
+livecheck.regex     emacs-\\d+\\.\\d+\\w*-mac-(\\d+\\.\\d+\\w*)\\.tar
Index: /trunk/dports/aqua/emacs-mac-app/files/patch-src_emacs.c.diff
===================================================================
--- /trunk/dports/aqua/emacs-mac-app/files/patch-src_emacs.c.diff	(revision 98848)
+++ /trunk/dports/aqua/emacs-mac-app/files/patch-src_emacs.c.diff	(revision 98848)
@@ -0,0 +1,37 @@
+--- src/emacs.c.orig	2011-01-09 02:45:14.000000000 +0900
++++ src/emacs.c	2011-09-09 23:13:44.000000000 +0900
+@@ -23,6 +23,8 @@
+ #include <signal.h>
+ #include <errno.h>
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
+ 
+ #include <sys/types.h>
+ #include <sys/file.h>
+@@ -839,6 +841,25 @@
+ #ifdef DARWIN_OS
+   if (!initialized)
+     unexec_init_emacs_zone ();
++
++  /* Imaxima won't work properly if PATH does not contain the
++     MacPorts directory. The following code is a workaround to
++     avoid this problem. */
++  {
++    char *oldpath = getenv("PATH");
++    if (!oldpath) {oldpath = "";}
++    size_t oldpathsize = strlen(oldpath) + 1;
++    if (!strstr(oldpath, "__PREFIX__/bin")) {
++      char *newpath;
++      size_t newpathsize = oldpathsize + strlen("__PREFIX__/bin:");
++      if ((newpath = (char *)malloc(newpathsize)) != NULL) {
++        strlcpy(newpath, "__PREFIX__/bin:", newpathsize);
++        strlcat(newpath, oldpath, newpathsize);
++        setenv("PATH", newpath, 1);
++        free(newpath);
++      }
++    }
++  }
+ #endif
+ 
+   sort_args (argc, argv);
Index: /trunk/dports/aqua/emacs-mac-app/files/site-start.el
===================================================================
--- /trunk/dports/aqua/emacs-mac-app/files/site-start.el	(revision 98848)
+++ /trunk/dports/aqua/emacs-mac-app/files/site-start.el	(revision 98848)
@@ -0,0 +1,12 @@
+;; load-path contains ${prefix}/share/emacs/site-lisp and its subdirecotries.
+;; See #12115, #29232, #32146.
+(setq load-path (cons "__PREFIX__/share/emacs/site-lisp" load-path))
+(if (file-readable-p "__PREFIX__/share/emacs/site-lisp")
+    (let ((default-directory "__PREFIX__/share/emacs/site-lisp"))
+      (if (file-readable-p "__PREFIX__/share/emacs/site-lisp/subdirs.el")
+          (load "__PREFIX__/share/emacs/site-lisp/subdirs.el")
+        (if (fboundp 'normal-top-level-add-subdirs-to-load-path)
+            (normal-top-level-add-subdirs-to-load-path)))))
+
+;; Info-directory-list contains ${prefix}/share/info. See #32148.
+(setq Info-default-directory-list (cons "__PREFIX__/share/info" Info-default-directory-list))
