windres -O coff icon.rc icon.res
gcc icon.res startemacs.c -o startemacs
Created
May 23, 2012 03:09
-
-
Save yangg/2773051 to your computer and use it in GitHub Desktop.
Start emacsclient across multi plaform
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
1 ICON "emacs.ico" |
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
#include <stdio.h> | |
int main (int argc, char *argv[]) | |
{ | |
char *filename, appname[255]; | |
size_t size = 200; | |
sprintf(appname, "%s/%s", getcwd(appname, size), argv[0]); | |
if(argc > 1) { | |
filename = argv[1]; | |
} else { | |
filename = "newfile"; | |
} | |
printf("%s\n%s\n", appname, filename); | |
if(!strcmp(filename, "--install")) { | |
char cmd[500]; | |
sprintf(cmd, "reg add \"HKCR\\*\\shell\\openwithemacs\\command\" /ve /d \"\\\"%s\\\" \\\"%%1\\\"\" /f", appname); | |
system("reg add \"HKCR\\*\\shell\\openwithemacs\" /ve /d \"Edit With Emacs\" /f"); | |
system(cmd); | |
} else if(!strcmp(filename, "--uninstall")) { | |
system("reg delete \"HKCR\\*\\shell\\openwithemacs\" /f"); | |
} else { | |
char cmd[255]; | |
sprintf(cmd, "emacsclientw.exe --alternate-editor=\"runemacs.exe\" \"%s\"", filename); | |
// TODO: quote & cmd window & waitexit | |
system(cmd); | |
} | |
return 0; | |
} | |
// exec http://www.gnu.org/software/libc/manual/html_node/Executing-a-File.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment