Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Last active August 29, 2015 14:02
Show Gist options
  • Save takekazuomi/8c894eca20b54e153937 to your computer and use it in GitHub Desktop.
Save takekazuomi/8c894eca20b54e153937 to your computer and use it in GitHub Desktop.
emacs startup helper for windows emacs
$EMACS_HOME="C:\opt\emacs-24.3-20130503"
$Env:Path = "$EMACS_HOME\bin;$Env:Path"
function emacs() {
param([string[]]$p = ".");
$emacs_server_path = "~/.emacs.d\server\server"
if (test-path $emacs_server_path) {
$s=Get-Content "$emacs_server_path"
$s[0] -match "^([0-9\.]+):([0-9]+) ([0-9]+)"
if($matches.Count -ge 3 ){
try {
$c=Get-NetTCPConnection -State "Listen" -LocalAddress $matches[1] -LocalPort $matches[2] -ErrorAction Stop
}
catch [Exception] {
Remove-Item $emacs_server_path
echo "$emacs_server_path removed"
}
}
}
emacsclient.exe -a runemacs.exe -n $p
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment