From 82e1e59c4e15406c36656eb183ce90be95ad40a3 Mon Sep 17 00:00:00 2001 From: Toni Reina Date: Mon, 3 Mar 2014 18:48:00 +0100 Subject: [PATCH 1/2] Create symlink for emacsclient in use! method. --- .gitignore | 2 ++ lib/evm.rb | 2 ++ lib/evm/package.rb | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a50c5ad..1cce453 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /evm-*.gem /bin/emacs /bin/evm-emacs +/bin/emacsclient +/bin/evm-emacsclient diff --git a/lib/evm.rb b/lib/evm.rb index acf77df..0561d86 100644 --- a/lib/evm.rb +++ b/lib/evm.rb @@ -5,6 +5,8 @@ module Evm LOCAL_PATH = File.join('/', 'usr', 'local', 'evm') EMACS_PATH = File.join(ROOT_PATH, 'bin', 'emacs') EVM_EMACS_PATH = File.join(ROOT_PATH, 'bin', 'evm-emacs') + EMACSCLIENT_PATH = File.join(ROOT_PATH, 'bin', 'emacs') + EVM_EMACSCLIENT_PATH = File.join(ROOT_PATH, 'bin', 'evm-emacs') def self.abort(*args) STDERR.puts args.join(' ') diff --git a/lib/evm/package.rb b/lib/evm/package.rb index 2e10617..8894c80 100644 --- a/lib/evm/package.rb +++ b/lib/evm/package.rb @@ -22,11 +22,21 @@ def bin end end + def client_bin + Evm::Os.osx? ? nil : File.join(path, 'bin', 'emacsclient') + end + def use! - FileUtils.ln_sf(bin, Evm::EVM_EMACS_PATH) - unless File.symlink?(Evm::EMACS_PATH) - FileUtils.ln_sf(Evm::EVM_EMACS_PATH, Evm::EMACS_PATH) - end + create_symlinks(bin, "EMACS") + create_symlinks(client_bin, "EMACSCLIENT") unless Evm::Os.osx? + end + + def create_symlinks(binary_path, type) + evm_path = Evm.const_get("EVM_#{type}_PATH") + path = Evm.const_get("#{type}_PATH") + + FileUtils.ln_sf(binary_path, evm_path) + FileUtils.ln_sf(evm_path, path) unless File.symlink?(path) end def install! From 7257dc963a9b1706278fc203fd8769974f4ba818 Mon Sep 17 00:00:00 2001 From: Toni Reina Date: Wed, 5 Mar 2014 21:21:31 +0100 Subject: [PATCH 2/2] Create symlinks for extra binaries. --- .gitignore | 6 ++---- lib/evm.rb | 7 +++---- lib/evm/package.rb | 31 +++++++++++++++++++++---------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 1cce453..da0ab7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ /evm-*.gem -/bin/emacs -/bin/evm-emacs -/bin/emacsclient -/bin/evm-emacsclient +/bin/* +!bin/evm \ No newline at end of file diff --git a/lib/evm.rb b/lib/evm.rb index 0561d86..61bdc33 100644 --- a/lib/evm.rb +++ b/lib/evm.rb @@ -3,10 +3,9 @@ module Evm ROOT_PATH = File.expand_path('..', File.dirname(__FILE__)) LOCAL_PATH = File.join('/', 'usr', 'local', 'evm') - EMACS_PATH = File.join(ROOT_PATH, 'bin', 'emacs') - EVM_EMACS_PATH = File.join(ROOT_PATH, 'bin', 'evm-emacs') - EMACSCLIENT_PATH = File.join(ROOT_PATH, 'bin', 'emacs') - EVM_EMACSCLIENT_PATH = File.join(ROOT_PATH, 'bin', 'evm-emacs') + EMACS_BIN_PATH = File.join(ROOT_PATH, 'bin') + EMACS_PATH = File.join(EMACS_BIN_PATH, 'emacs') + EVM_EMACS_PATH = File.join(EMACS_BIN_PATH, 'evm-emacs') def self.abort(*args) STDERR.puts args.join(' ') diff --git a/lib/evm/package.rb b/lib/evm/package.rb index 8894c80..390482a 100644 --- a/lib/evm/package.rb +++ b/lib/evm/package.rb @@ -22,21 +22,32 @@ def bin end end - def client_bin - Evm::Os.osx? ? nil : File.join(path, 'bin', 'emacsclient') + def extra_binaries + bin_path = if Evm::Os.osx? + File.join(path, 'Emacs.app', 'Contents', 'MacOS', 'bin') + else + File.join(path, 'bin') + end + + Dir.glob(File.join(bin_path, "*")) end - def use! - create_symlinks(bin, "EMACS") - create_symlinks(client_bin, "EMACSCLIENT") unless Evm::Os.osx? + def clear_bin_dir + current = Dir.glob(File.join(Evm::EMACS_BIN_PATH, '*')).reject do |bin_path| + File.basename(bin_path) == "evm" + end + + FileUtils.rm_f(current) end - def create_symlinks(binary_path, type) - evm_path = Evm.const_get("EVM_#{type}_PATH") - path = Evm.const_get("#{type}_PATH") + def use! + clear_bin_dir - FileUtils.ln_sf(binary_path, evm_path) - FileUtils.ln_sf(evm_path, path) unless File.symlink?(path) + FileUtils.ln_sf(extra_binaries, Evm::EMACS_BIN_PATH) + FileUtils.ln_sf(bin, Evm::EVM_EMACS_PATH) + unless File.symlink?(Evm::EMACS_PATH) + FileUtils.ln_sf(Evm::EVM_EMACS_PATH, Evm::EMACS_PATH) + end end def install!