Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have installed emacs with homebrew, with the --cocoa flag, which makes homebrew create an .app bundle in /usr/local/Cellar/emacs/<version>/Emacs.app. I have symlinked the .app bundle into /Applications/, to make it easy to open. The problem is that when I try setting file associations for files, I can't set Emacs.app as the default (the Add button is greyed out):

Unable to select open with emacs

Now I could just copy or move the .app bundle into /Applications/, but that would require me to copy it over again every time emacs is updated via homebrew. Is there some other way to solve this?

share|improve this question

5 Answers 5

I don't know why, but I have figured it out that if I make the symlink to the Contents directory, then associations work fine.

That is I do the following in a terminal window, using my personal Applications folder as an example:

% mkdir ~/Applications/Emacs.app
% ln -s /usr/local/Cellar/emacs/23.2/Emacs.app/Contents ~/Applications/Emacs.app

Something about putting the symlink inside the Emacs.app gets the bundle recognized.

share|improve this answer

Weird. I just installed emacs through brew and it automatically updated the "open with" dialog to include Emacs.app ; But you should be able to do the following: Directly after opening the "choose an application" dialog, press "/" to get a "go to folder" window. Enter the following path:

/usr/local/Cellar/emacs/

and from there navigate to the Emacs.app (at the current version this should be /usr/local/Cellar/emacs/23.2/Emacs.app) and select it as default application.

========

Could you please run the following command to see whether Emacs is registered in your LaunchServices DB?

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | grep Emacs

share|improve this answer
    
I already suggested that. But it won't work anymore when emacs is update (the version is in the path) –  Loïc Wolff Feb 4 '11 at 13:30
    
Does it actually work if you navigate to the real path of emacs? Are you sure it's only the symlink/alias that doesn't work? –  zevlag Feb 4 '11 at 17:26
    
Yes, you could try this for example by symlinking TextEdit: ln -s /Applications/TextEdit.app /Applications/Test.app - now you can´t select it in the "choose an application" dialog anymore. Please see my original answer above for another idea regarding LaunchServices. –  Asmus Feb 4 '11 at 17:40
    
It seems like it is: pastie.org/pastes/1529411 (the target of the link, at least), along with some other Emacs.app bundles I have deleted at some point. What does this mean? –  oyvindio Feb 4 '11 at 20:49
    
That LaunchServices command you ran showed all Emacs variants your Mac "got to know" over the time, even if you deleted them. You might either want to rebuild your LaunchServices DB and then (after opening Emacs for the "first" time) it should become available immediately in the "open with" dialog - but this might let your Mac forget the other custom file assignments you made over time. Or you might try the first solution I (and Loïc) suggested: assigning Emacs from /usr/local… in the "open with" dialog –  Asmus Feb 4 '11 at 23:33

If it's not something you do often, you can navigate to the place where Emacs.app is really and assign it from there.

Did you try to change the "Enable: Recommended Applications" dropdown? I believe there's a "All applications" option. Maybe this one will let you select your alias.

You said you symlinked the .app. Did you use ln -s? If so, did you try using an alias instead?

--
I don't know homebrew very well, but it look like you can extend homebrew with external commands.

Try to look if you can get the updated .app file and cp to /Applications.

share|improve this answer
    
Yes, I used ln -s from the commmand line. I tried using an alias aswell, but that didn't work either. Selecting "All applications" doesn't help, as I can already select Emacs.app, I just can't click 'Add'. I guess I could navigate to the "real" Emacs.app bundle, but the thing is that the version number is part of the path, so it would change when emacs is updated... –  oyvindio Feb 4 '11 at 10:28
    
@oyvindio added a new idea –  Loïc Wolff Feb 4 '11 at 11:17

My solution is to create a symlink of /usr/local/Cellar in /Applications. Then, you can find the emacs.app you need to use with the "Open with" dialog (in /Applications/Cellar).

Alternatively, you may use RCDefault (a freeware app) to config the file extension association.

share|improve this answer

The exact paths to your applications shouldn't matter. Once you open the application and close it once, it should add it to your LaunchServices database.

Try rebuilding your LaunchServices database by entering the following terminal command:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\
LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain\
local -domain system -domain user

After doing this, open MacVim. It should then populate the Open With... options. Note that MacVim does not automatically associate itself with many file types (unlike, say, BBEdit, which shows up as a default option for almost any file type), only text, code, and html-type files tend to

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.