Created
March 11, 2011 18:28
-
-
Save kyleburton/866324 to your computer and use it in GitHub Desktop.
Emacs, Slime Helper to augment 'swank' bash function and trigger emacs to connect to the fresh swank server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' # Sockets are in standard library | |
$hostname = 'localhost' | |
$port = (ARGV[0] || "4005").to_i | |
attempts = 100 | |
$s = nil | |
$retry = true | |
while $retry && (attempts > 0) | |
begin | |
$stderr.print '.' | |
attempts -= 1 | |
$s = TCPSocket.open($host, $port) | |
$stderr.puts "connected" | |
break | |
rescue | |
if $!.to_s =~ /Connection refused/i | |
$retry = true | |
sleep 0.25 | |
else | |
$stderr.puts "Error: #$!" | |
$retry = false | |
end | |
end | |
end | |
if $s | |
$s.close | |
$stderr.puts "connected" | |
exec %Q|emacsclient -e '(progn (setq slime-protocol-version "20100404") (slime-connect "localhost" #{$port}))'| | |
else | |
exit -1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment