Skip to content

Instantly share code, notes, and snippets.

@ssugiyama
Last active October 7, 2017 14:52
Show Gist options
  • Save ssugiyama/5ff88299efadd61415c5 to your computer and use it in GitHub Desktop.
Save ssugiyama/5ff88299efadd61415c5 to your computer and use it in GitHub Desktop.
class EmacsJp < Formula
desc "GNU Emacs text editor"
homepage "https://www.gnu.org/software/emacs/"
url "https://ftp.gnu.org/gnu/emacs/emacs-25.3.tar.xz"
mirror "https://ftpmirror.gnu.org/emacs/emacs-25.3.tar.xz"
sha256 "253ac5e7075e594549b83fd9ec116a9dc37294d415e2f21f8ee109829307c00b"
head do
url "https://github.com/emacs-mirror/emacs.git"
depends_on "autoconf" => :build
depends_on "gnu-sed" => :build
depends_on "texinfo" => :build
end
option "with-cocoa", "Build a Cocoa version of emacs"
option "with-ctags", "Don't remove the ctags executable that emacs provides"
option "without-libxml2", "Don't build with libxml2 support"
option "with-modules", "Compile with dynamic modules support"
option "without-japanese", "Don't build with better integration of japanese input methods"
stable do
patch do
url 'http://plamo.linet.gr.jp/~matsuki/mac/emacs-25.1-inline.patch.bz2'
sha256 'e9a771d4c5abb203a83c7790fec96dd993c4e0a88f83a43f6abbdb5f5a4741c0'
end if build.with? "japanese"
depends_on "autoconf" => :build if build.with? "japanese"
depends_on "automake" => :build if build.with? "japanese"
end
deprecated_option "cocoa" => "with-cocoa"
deprecated_option "keep-ctags" => "with-ctags"
deprecated_option "with-d-bus" => "with-dbus"
deprecated_option "imagemagick" => "imagemagick@6"
depends_on "pkg-config" => :build
depends_on "dbus" => :optional
depends_on "gnutls" => :optional
depends_on "librsvg" => :optional
# Emacs does not support ImageMagick 7:
# Reported on 2017-03-04: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25967
depends_on "imagemagick@6" => :optional
depends_on "mailutils" => :optional
def install
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--enable-locallisppath=#{HOMEBREW_PREFIX}/share/emacs/site-lisp
--infodir=#{info}/emacs
--prefix=#{prefix}
--without-x
]
if build.with? "libxml2"
args << "--with-xml2"
else
args << "--without-xml2"
end
if build.with? "dbus"
args << "--with-dbus"
else
args << "--without-dbus"
end
if build.with? "gnutls"
args << "--with-gnutls"
else
args << "--without-gnutls"
end
# Note that if ./configure is passed --with-imagemagick but can't find the
# library it does not fail but imagemagick support will not be available.
# See: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24455
if build.with? "imagemagick@6"
args << "--with-imagemagick"
else
args << "--without-imagemagick"
end
args << "--with-modules" if build.with? "modules"
args << "--with-rsvg" if build.with? "librsvg"
args << "--without-pop" if build.with? "mailutils"
if build.head?
ENV.prepend_path "PATH", Formula["gnu-sed"].opt_libexec/"gnubin"
system "./autogen.sh"
end
if build.with? "cocoa"
args << "--with-ns" << "--disable-ns-self-contained"
else
args << "--without-ns"
end
system "./configure", *args
system "make"
system "make", "install"
if build.with? "cocoa"
prefix.install "nextstep/Emacs.app"
# Replace the symlink with one that avoids starting Cocoa.
(bin/"emacs").unlink # Kill the existing symlink
(bin/"emacs").write <<-EOS.undent
#!/bin/bash
exec #{prefix}/Emacs.app/Contents/MacOS/Emacs "$@"
EOS
end
# Follow MacPorts and don't install ctags from Emacs. This allows Vim
# and Emacs and ctags to play together without violence.
if build.without? "ctags"
(bin/"ctags").unlink
(man1/"ctags.1.gz").unlink
end
end
def caveats
if build.with? "cocoa" then <<-EOS.undent
Please try the Cask for a better-supported Cocoa version:
brew cask install emacs
EOS
end
end
plist_options :manual => "emacs"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/emacs</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
assert_equal "4", shell_output("#{bin}/emacs --batch --eval=\"(print (+ 2 2))\"").strip
end
end
@ssugiyama
Copy link
Author

ssugiyama commented Oct 2, 2016

% brew install  https://gist.githubusercontent.com/ssugiyama/5ff88299efadd61415c5/raw/b7b496850386ef5638a7f4790c6edb8c68524500/emacs-jp.rb --with-cocoa --with-gnutls --with-modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment