Created
January 24, 2014 03:18
-
-
Save jaeschliman/8591515 to your computer and use it in GitHub Desktop.
change the Emacs.app application icon while it's running
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
/* | |
I typically run several emacs instances at once, | |
One handling IM and my timecard etc, | |
and one for each project I'm currently working on. | |
This way I can tailor a given instance of emacs to a given project | |
as much as I want without interfering with the others, | |
it simplifies buffer-switching and desktop saving etc. | |
But it gets to be a PITA command-tabbing between them as they all have the same icon. | |
This fixes that. | |
*/ | |
// in src/nsfns.m, at ~L 2150, before DEFUN("ns-do-applescript"... | |
DEFUN ("ns-set-application-icon", Fns_set_application_icon, Sns_set_application_icon, 1, 1, 0, | |
doc: /* Set the running application's icon to PATH, | |
and return true, or return nil if it fails. */) | |
(Lisp_Object path) | |
{ | |
CHECK_STRING (path); | |
char *s = SSDATA(path); | |
NSString *ns = [[NSString stringWithUTF8String:s] stringByExpandingTildeInPath]; | |
NSURL *url = [NSURL fileURLWithPath:ns]; | |
if(!url) { | |
NSLog(@"could not create url for path: %@", ns); | |
return Qnil; | |
} | |
NSImage *img = [[NSImage alloc] initWithContentsOfURL: url]; | |
if(!img) { | |
NSLog(@"could not create image from url: %@", url); | |
return Qnil; | |
} | |
NSLog(@"setting application icon"); | |
[NSApp setApplicationIconImage:img]; | |
return Qt; | |
} | |
//=========================================================================== | |
//and then above defsubr (&Sns_do_applescript); inside the #ifdef NS_IMPL_COCOA, export it: | |
defsubr (&Sns_set_application_icon); | |
somehow just seeing this now -- yep that's fine with me 👍
not sure how to get this, but it would be a welcome addition in emacs-plus
Is this a file that gets included when Emacs is built? I don't recognize the extension. I know it's not elist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @jaeschliman -- this function is great! Any chance you want to add it to the homebrew formula https://github.com/d12frosted/homebrew-emacs-plus? If not, any chance you'd be okay with me doing so (with prominent attribution to your gist)?