Skip to content

Instantly share code, notes, and snippets.

@cbilson
Last active August 29, 2015 14:07
Show Gist options
  • Save cbilson/92de3f957635e4f6a47e to your computer and use it in GitHub Desktop.
Save cbilson/92de3f957635e4f6a47e to your computer and use it in GitHub Desktop.
function Find-MaybeChocolateyProgram($Path, $Name, $ChocolateyPackageName) {
if (!$Path) {
$commandFromEnvPath = Get-Command $Name
if ($commandFromEnvPath -ne $null) {
return $commandFromEnvPath.Definition
}
if (!(Test-Path env:ChocolateyInstall)) {
throw "Chocolately not installed. Please tell me where $Name is."
}
$Path = Join-Path $env:ChocolateyInstall "bin\$Name"
if (!(Test-Path $Path)) {
throw "$Name not installed or not installed via chocolatey. " `
+ "Please ``choco install $ChocolateyPackageName`` or tell me where $Name is."
}
} elseif (!(Test-Path $Path)) {
throw "$Name not found at $Path. Please check path or install $Name."
} else {
$Path
}
}
function Install-EmacsExplorerIntegration(
$EmacsPath,
$Extensions=('.asm',
'.c', '.clj', '.cljs', '.cljx', '.config', '.cpp', '.cs', '.csproj',
'.d',
'.el',
'.fs', '.fsi',
'.h', '.hpp', '.hs',
'.java',
'.log', '.lisp',
'.markdown', '.md', '.ml',
'.org',
'.pl', '.proj', '.ps1', '.psd1', '.psm1', '.py',
'.rb',
'.tex', '.txt',
'.xml'),
[switch] $NoDiredHere)
{
$EmacsPath = Find-MaybeChocolateyProgram $EmacsPath 'emacsclient.exe' 'emacs'
if (!$NoDiredHere) {
$diredHerePath = 'Registry::HKEY_CLASSES_ROOT\Directory\shell\DiredHere'
New-Item $diredHerePath -Force
Set-Item $diredHerePath 'Open Emacs Dired Here'
$commandPath = Join-Path $diredHerePath 'command'
New-Item $commandPath -Force
Set-Item $commandPath -Value "$EmacsPath '%L'"
}
foreach ($ext in $Extensions) {
$diredHerePath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$ext\UserChoice"
# [HKEY_CLASSES_ROOT\*\Shell\Open In Emacs\Command]
#@="\"C:\\bin\\Emacs-23.1\\bin\\emacsclientw.exe\" -a \"C:\\bin\\Emacs-23.1\\bin\\runemacs.exe\" \"%1\""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment