Permalink
157 lines (132 sloc) 6.25 KB
class EmacsMac < Formula
desc "YAMAMOTO Mitsuharu's Mac port of GNU Emacs"
homepage "https://www.gnu.org/software/emacs/"
url "https://bitbucket.org/mituharu/emacs-mac/get/emacs-26.1-mac-7.2.tar.bz2"
version "emacs-26.1-z-mac-7.2"
sha256 "c2a50477e603ba52d23679f3a0205838d438b2a9b2b43f8b22c343ecf1a3f05b"
head "https://bitbucket.org/mituharu/emacs-mac.git", branch: "work"
option "with-dbus", "Build with d-bus support"
option "with-modules", "Build with dynamic modules support"
option "with-xml2", "Build with libxml2 support"
option "with-ctags", "Don't remove the ctags executable that emacs provides"
option "with-no-title-bars", "Build with a patch for no title bars on frames (--HEAD is not supported)"
option "with-natural-title-bar", "Build with a patch for title bar color inferred by your theme (--HEAD is not supported)"
option "with-modern-icon", "Using a modern style Emacs icon by @tpanum"
option "with-spacemacs-icon", "Using the spacemacs Emacs icon by Nasser Alshammari"
option "without-gnutls", "Build without gnutls support"
# Update list from
# https://raw.githubusercontent.com/emacsfodder/emacs-icons-project/master/icons.json
emacs_icons_project_icons = {
"EmacsIcon1" => "50dbaf2f6d67d7050d63d987fe3743156b44556ab42e6d9eee92248c56011bd0",
"EmacsIcon2" => "8d63589b0302a67f13ab94b91683a8ad7c2b9e880eabe008056a246a22592963",
"EmacsIcon3" => "80dd2a4776739a081e0a42008e8444c729d41ba876b19fa9d33fde98ee3e0ebf",
"EmacsIcon4" => "8ce646ca895abe7f45029f8ff8f5eac7ab76713203e246b70dea1b8a21a6c135",
"EmacsIcon5" => "ca415df7ad60b0dc495626b0593d3e975b5f24397ad0f3d802455c3f8a3bd778",
"EmacsIcon6" => "12a1999eb006abac11535b7fe4299ebb3c8e468360faf074eb8f0e5dec1ac6b0",
"EmacsIcon7" => "f5067132ea12b253fb4a3ea924c75352af28793dcf40b3063bea01af9b2bd78c",
"EmacsIcon8" => "d330b15cec1bcdfb8a1e8f8913d8680f5328d59486596fc0a9439b54eba340a0",
"EmacsIcon9" => "f58f46e5ef109fff8adb963a97aea4d1b99ca09265597f07ee95bf9d1ed4472e",
"emacs-card-blue-deep" => "6bdb17418d2c620cf4132835cfa18dcc459a7df6ce51c922cece3c7782b3b0f9",
"emacs-card-british-racing-green" => "ddf0dff6a958e3b6b74e6371f1a68c2223b21e75200be6b4ac6f0bd94b83e1a5",
"emacs-card-carmine" => "4d34f2f1ce397d899c2c302f2ada917badde049c36123579dd6bb99b73ebd7f9",
"emacs-card-green" => "f94ade7686418073f04b73937f34a1108786400527ed109af822d61b303048f7",
}
emacs_icons_project_icons.keys.each do |icon|
option "with-emacs-icons-project-#{icon}", "Using Emacs icon project #{icon}"
end
deprecated_option "keep-ctags" => "with-ctags"
deprecated_option "icon-official" => "with-official-icon"
deprecated_option "icon-modern" => "with-modern-icon"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "pkg-config" => :build
depends_on "texinfo" => :"build"
depends_on "d-bus" if build.with? "dbus"
depends_on "libxml2" if build.with? "xml2"
depends_on "glib" => :optional
depends_on "gnutls" => :optional
depends_on "imagemagick" => :optional
emacs_icons_project_icons.each do |icon, sha|
resource "emacs-icons-project-#{icon}" do
url "https://raw.githubusercontent.com/emacsfodder/emacs-icons-project/master/#{icon}.icns"
sha256 sha
end
end
resource "modern-icon" do
url "https://s3.amazonaws.com/emacs-mac-port/Emacs.icns.modern"
sha256 "eb819de2380d3e473329a4a5813fa1b4912ec284146c94f28bd24fbb79f8b2c5"
end
resource "spacemacs-icon" do
url "https://github.com/nashamri/spacemacs-logo/blob/master/spacemacs.icns?raw=true"
sha256 "b3db8b7cfa4bc5bce24bc4dc1ede3b752c7186c7b54c09994eab5ec4eaa48900"
end
if build.with? "no-title-bars"
patch do
url "https://gist.github.com/railwaycat/71b3f23ed6159b5dbf59389ae56f06e1/raw/360554bc055144d3a8801b39b6ef7f5c1d868484/emacs-26.1-rc1-mac-6.90-no-title-bar.patch"
sha256 "6937ec98ddca68e7c937d57ea2dc52af6b60d3438a0a5d30abc6ad719234a30f"
end
end
if build.with? "natural-title-bar"
patch do
url "https://gist.github.com/railwaycat/d42c0a9f79aa8adbc646e8a725fcc690/raw/f3fce4fe560f8468370c5fa51a13edb8dc0d89ee/emacs-mac-title-bar.patch"
sha256 '9c42c00515d70e52f06336f5fa50317a9d92caa45256ebb14c17cbc2c9451947'
end
end
def install
args = [
"--enable-locallisppath=#{HOMEBREW_PREFIX}/share/emacs/site-lisp",
"--infodir=#{info}/emacs",
"--prefix=#{prefix}",
"--with-mac",
"--enable-mac-app=#{prefix}",
]
args << "--with-modules" if build.with? "modules"
if build.with? "gnutls"
args << "--with-gnutls"
else
args << "--without-gnutls"
end
icons_dir = buildpath/"mac/Emacs.app/Contents/Resources"
(%w[EmacsIcon1 EmacsIcon2 EmacsIcon3 EmacsIcon4
EmacsIcon5 EmacsIcon6 EmacsIcon7 EmacsIcon8
EmacsIcon9 emacs-card-blue-deep emacs-card-british-racing-green
emacs-card-carmine emacs-card-green].map { |i| "emacs-icons-project-#{i}" } +
%w[modern-icon spacemacs-icon]).each do |icon|
next if build.without? icon
rm "#{icons_dir}/Emacs.icns"
resource(icon).stage do
icons_dir.install Dir["*.icns*"].first => "Emacs.icns"
end
end
system "./autogen.sh"
system "./configure", *args
system "make"
system "make", "install"
prefix.install "NEWS-mac"
# Follow Homebrew and don't install ctags from Emacs. This allows Vim
# and Emacs and exuberant ctags to play together without violence.
if build.without? "ctags"
(bin/"ctags").unlink
(share/man/man1/"ctags.1.gz").unlink
end
end
def caveats
<<~EOS
This is YAMAMOTO Mitsuharu's "Mac port" addition to
GNU Emacs 26. This provides a native GUI support for Mac OS X
10.6 - 10.13. After installing, see README-mac and NEWS-mac
in #{prefix} for the port details.
Emacs.app was installed to:
#{prefix}
To link the application to default Homebrew App location:
ln -s #{prefix}/Emacs.app /Applications
Other ways please refer:
https://github.com/railwaycat/homebrew-emacsmacport/wiki/Alternative-way-of-place-Emacs.app-to-Applications-directory
For an Emacs.app CLI starter, see:
https://gist.github.com/4043945
EOS
end
test do
assert_equal "4", shell_output("#{bin}/emacs --batch --eval=\"(print (+ 2 2))\"").strip
end
end