Last active
August 29, 2015 14:02
-
-
Save takekazuomi/8c894eca20b54e153937 to your computer and use it in GitHub Desktop.
emacs startup helper for windows emacs
This file contains 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
$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