From 81eedecc5aad951f445e6e5d813890b36c9ac679 Mon Sep 17 00:00:00 2001 From: Alex Dunn Date: Sun, 5 Jul 2015 14:45:26 -0700 Subject: [PATCH] Automatic caveats for emacs lisp files - The name of the subdirectory under site-lisp may not be exactly the same as the name of the package - `(normal-top-level-add-subdirs-to-load-path)` adds every subdirectory of `default-directory` to the load-path, so users don't have to update their load-path for every package they install. Closes Homebrew/homebrew#42309. --- Library/Homebrew/caveats.rb | 14 ++++++++++++++ Library/Homebrew/keg.rb | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index 7d0d3d0dea..53cdd155c1 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -16,6 +16,7 @@ class Caveats caveats << plist_caveats caveats << python_caveats caveats << app_caveats + caveats << elisp_caveats caveats.compact.join("\n") end @@ -132,6 +133,19 @@ class Caveats end end + def elisp_caveats + if keg && keg.elisp_installed? + <<-EOS.undent + Emacs Lisp files have been installed to: + #{HOMEBREW_PREFIX}/share/emacs/site-lisp/ + + Add the following to your init file to have packages installed by Homebrew added to your load-path: + (let ((default-directory "#{HOMEBREW_PREFIX}/share/emacs/site-lisp/")) + (normal-top-level-add-subdirs-to-load-path)) + EOS + end + end + def plist_caveats s = [] if f.plist or (keg and keg.plist_installed?) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index cf4be6cc05..dbcf613e44 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -243,6 +243,10 @@ class Keg Dir["#{path}/{,libexec/}*.app"].any? end + def elisp_installed? + Dir["#{path}/share/emacs/site-lisp/**/*.el"].any? + end + def version require 'pkg_version' PkgVersion.parse(path.basename.to_s)