1

I installed emacs on my MacBook Air running Mac OS X 10.6.5 from this site http://emacsformacosx.com/. I believe this is what used to be called cocoa emacs. I dragged it into my Application folder and it works fine when I run it from there. I want to be able to run it from the Terminal. After some googling, I tried open -a /Application/Emacs.app foo.txt (foo.txt was and existing file). I got two emacs windows - one with welcome screen and one with foo.txt loaded. I tried a few applications in the /Applications directory and they did not seem to behave like this. I had installed it using my own account (an admin account) so after doing ls -l on /Application I noticed that the owner and group were different from the other entries in this folder. I recursively changed the owner and group to root and wheel, like the others, but this did not help. The only thing that looks funny now is that there that ls -l show a @ character which has something to do with extended attributes but I don't know how to check these.

Any suggestions on what to check next?

Is using the open command the only to run the program? Can I simulate what it does using a shell script?

1
  • do you want emacs to load /in/ the Terminal window? Or do you want it to spawn window like you described? I figure, if you're in Terminal, you might just want to run emacs in Terminal, but I could be wrong. Asmus' suggestion would work if you want the former. May 19, 2012 at 9:21

2 Answers 2

0

You misunderstand how open works: With your command open /Application/Emacs.app foo.txt you tell open to open two files, namely Emacs and the txt file, but these are two different operations: First, emacs will be started, and then foo.txt will be loaded with the default program for .txt files, which is apparently Emacs in your case.

As long as Emacs is the default for this file type, just using open foo.txt would open the file in Emacs, but if it is not the default, you would have to use open foo.txt -a /Applications/Emacs.app (the -a switch tells open what application to use) or maybe you could hand it over as a parameter with the --args option like this: open /Applications/Emacs.app --args foo.txt.

1
  • He is using the -a switch.
    – Daniel Beck
    Feb 6, 2011 at 8:03
0

This actually is a bit strange; for my installation (which I did with homebrew), open -a Emacs file.txt works fine… maybe you should rebuild your LaunchServices database? But anyway, you should be able to call the executable directly with

/Applications/Emacs.app/Contents/MacOS/Emacs file.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .