2015-05-08 14:37:15 +08:00
|
|
|
class EmacsRequirement < Requirement
|
|
|
|
fatal true
|
|
|
|
default_formula "emacs"
|
|
|
|
|
|
|
|
def initialize(tags)
|
2016-09-11 17:42:43 +01:00
|
|
|
@version = tags.shift if /\d+\.*\d*/ =~ tags.first
|
2015-05-08 14:37:15 +08:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2016-09-17 15:32:44 +01:00
|
|
|
satisfy build_env: false do
|
2015-10-27 18:27:57 -07:00
|
|
|
next false unless which "emacs"
|
|
|
|
next true unless @version
|
2015-05-08 14:37:15 +08:00
|
|
|
emacs_version = Utils.popen_read("emacs", "--batch", "--eval", "(princ emacs-version)")
|
2016-07-11 16:09:35 +03:00
|
|
|
Version.create(emacs_version) >= Version.create(@version)
|
2015-05-08 14:37:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
env do
|
|
|
|
ENV.prepend_path "PATH", which("emacs").dirname
|
2015-10-29 19:36:48 -07:00
|
|
|
ENV["EMACS"] = "emacs"
|
2015-05-08 14:37:15 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
2015-10-27 18:27:57 -07:00
|
|
|
if @version
|
|
|
|
s = "Emacs #{@version} or later is required."
|
|
|
|
else
|
|
|
|
s = "Emacs is required."
|
|
|
|
end
|
2015-05-08 14:37:15 +08:00
|
|
|
s += super
|
|
|
|
s
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
|
|
|
|
end
|
|
|
|
end
|